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

NameTypeDescriptionDefault
job_idstrThe ID of the job to wait for.-
polling_intervalintThe interval in seconds between status checks.5
timeoutintThe maximum time in seconds to wait.3600

Returns

TypeDescription
JobThe 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

NameTypeDescriptionDefault
job_idstrThe ID of the job to wait for.-
polling_intervalintThe interval in seconds between status checks.5
timeoutintThe maximum time in seconds to wait.3600

Returns

TypeDescription
JobThe 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())