Skip to content

Commit

Permalink
be explicit about which job run logs are being retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan116 committed Jun 25, 2024
1 parent 0b9d982 commit 901ebef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions anyscale_provider/hooks/anyscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ def terminate_service(self, service_name: str, time_delay: int) -> bool:
raise AirflowException(f"Service termination failed with error: {e}")
return True

def get_job_logs(self, job_id: str) -> str:
def get_job_logs(self, job_id: str, run: str | None) -> str:
"""
Fetch the logs for a job.
:param job_id: Required. The ID of the job.
"""
logs: str = self.client.job.get_logs(id=job_id)
logs: str = self.client.job.get_logs(id=job_id, run=run)
return logs
5 changes: 4 additions & 1 deletion anyscale_provider/triggers/anyscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ async def run(self) -> AsyncIterator[TriggerEvent]:
await asyncio.sleep(self.poll_interval)

# Fetch and print logs
job_status = self.hook.get_job_status(self.job_id)
loop = asyncio.get_running_loop()
logs = await loop.run_in_executor(None, partial(self.hook.get_job_logs, job_id=self.job_id))
logs = await loop.run_in_executor(
None, partial(self.hook.get_job_logs, job_id=self.job_id, run=job_status.runs[-1].name)
)
for log in logs.split("\n"):
self.log.info(log)

Expand Down

0 comments on commit 901ebef

Please sign in to comment.