Job Operations
Run Job
The run_job function waits for a submitted job to complete by polling its status.
Synchronous
run_job
def run_job(
job_id: str,
polling_interval: int = 5,
timeout: int = 3600,
) -> Job:Waits for a job to complete.
Arguments
| Name | Type | Description | Default |
|---|---|---|---|
job_id | str | The ID of the job to wait for. | - |
polling_interval | int | The interval in seconds between status checks. | 5 |
timeout | int | The maximum time in seconds to wait. | 3600 |
Returns
| Type | Description |
|---|---|
Job | The completed Job object with its final status. |
Example
import perseus_client
# Assume you have just submitted a job and have its ID
job_id = "your_submitted_job_id"
try:
print("Waiting for job to complete...")
job = perseus_client.run_job(job_id)
print(f"Job finished with status: {job.status.value}")
except Exception as e:
print(f"An error occurred: {e}")Asynchronous
run_job_async
async def run_job_async(
job_id: str,
polling_interval: int = 5,
timeout: int = 3600,
) -> Job:Asynchronously waits for a job to complete.
Arguments
| Name | Type | Description | Default |
|---|---|---|---|
job_id | str | The ID of the job to wait for. | - |
polling_interval | int | The interval in seconds between status checks. | 5 |
timeout | int | The maximum time in seconds to wait. | 3600 |
Returns
| Type | Description |
|---|---|
Job | The completed Job object with its final status. |
Example
import asyncio
import perseus_client
# Assume you have just submitted a job and have its ID
job_id = "your_submitted_job_id"
async def main():
try:
print("Waiting for job to complete...")
job = await perseus_client.run_job_async(job_id)
print(f"Job finished with status: {job.status.value}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
await perseus_client.close_async()
if __name__ == "__main__":
asyncio.run(main())