Job Operations
Submit Job
The submit_job function submits a new job to the Perseus server for a previously uploaded file.
Synchronous
submit_job
def submit_job(
file_id: str,
ontology_id: Optional[str] = None,
) -> Job:Submits a job for a given file and optional ontology.
Arguments
| Name | Type | Description | Default |
|---|---|---|---|
file_id | str | The ID of the file to process. | - |
ontology_id | Optional[str] | The ID of the ontology to use. | None |
Returns
| Type | Description |
|---|---|
Job | A Job object representing the submitted job. |
Example
import perseus_client
# Assume you have a file_id and an optional ontology_id
file_id = "your_file_id"
ontology_id = "your_ontology_id" # or None
try:
job = perseus_client.submit_job(file_id, ontology_id)
print(f"Job submitted successfully with ID: {job.id}")
except Exception as e:
print(f"An error occurred: {e}")Asynchronous
submit_job_async
async def submit_job_async(
file_id: str,
ontology_id: Optional[str] = None,
) -> Job:Asynchronously submits a job for a given file and optional ontology.
Arguments
| Name | Type | Description | Default |
|---|---|---|---|
file_id | str | The ID of the file to process. | - |
ontology_id | Optional[str] | The ID of the ontology to use. | None |
Returns
| Type | Description |
|---|---|
Job | A Job object representing the submitted job. |
Example
import asyncio
import perseus_client
# Assume you have a file_id and an optional ontology_id
file_id = "your_file_id"
ontology_id = "your_ontology_id" # or None
async def main():
try:
job = await perseus_client.submit_job_async(file_id, ontology_id)
print(f"Job submitted successfully with ID: {job.id}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
await perseus_client.close_async()
if __name__ == "__main__":
asyncio.run(main())