Job Operations

Find Latest Job

The find_latest_job function finds the most recent job (regardless of status) for a given file and optional ontology.

Synchronous

find_latest_job

def find_latest_job(
    file_id: str,
    ontology_id: Optional[str] = None,
) -> Optional[Job]:

Finds the latest job for a file and optional ontology.

Arguments

NameTypeDescriptionDefault
file_idstrThe ID of the file.-
ontology_idOptional[str]The ID of the ontology used.None

Returns

TypeDescription
Optional[Job]The latest Job object if one exists, else None.

Example

import perseus_client

file_id = "your_file_id"

try:
    latest_job = perseus_client.find_latest_job(file_id)
    if latest_job:
        print(f"Latest job ID: {latest_job.id}, Status: {latest_job.status.value}")
    else:
        print("No job found for this file.")
except Exception as e:
    print(f"An error occurred: {e}")

Asynchronous

find_latest_job_async

async def find_latest_job_async(
    file_id: str,
    ontology_id: Optional[str] = None,
) -> Optional[Job]:

Asynchronously finds the latest job for a file and optional ontology.

Arguments

NameTypeDescriptionDefault
file_idstrThe ID of the file.-
ontology_idOptional[str]The ID of the ontology used.None

Returns

TypeDescription
Optional[Job]The latest Job object if one exists, else None.

Example

import asyncio
import perseus_client

file_id = "your_file_id"

async def main():
    try:
        latest_job = await perseus_client.find_latest_job_async(file_id)
        if latest_job:
            print(f"Latest job ID: {latest_job.id}, Status: {latest_job.status.value}")
        else:
            print("No job found for this file.")
    except Exception as e:
        print(f"An error occurred: {e}")
    finally:
        await perseus_client.close_async()

if __name__ == "__main__":
    asyncio.run(main())