gravitino.api.job.supports_jobs.SupportsJobs¶
- class gravitino.api.job.supports_jobs.SupportsJobs¶
Bases:
ABC
Interface for job management operations. This interface will be mixed with GravitinoClient to provide the ability to manage job templates and jobs within the Gravitino system.
- __init__()¶
Methods
__init__
()cancel_job
(job_id)Cancels a running job by its ID.
delete_job_template
(job_template_name)Deletes a job template by its name.
get_job
(job_id)Retrieves a job by its ID.
get_job_template
(job_template_name)Retrieves a job template by its name.
Lists all the registered job templates in Gravitino.
list_jobs
([job_template_name])Lists all the jobs in Gravitino.
register_job_template
(job_template)Register a job template with the specified job template to Gravitino.
run_job
(job_template_name, job_conf)Run a job with the template name and configuration.
- abstract cancel_job(job_id: str) JobHandle ¶
Cancels a running job by its ID. This operation will attempt to cancel the job if it is still running. This method will return immediately, user could use the job handle to check the status of the job after invoking this method.
- Args:
job_id: The ID of the job to cancel.
- Raises:
NoSuchJobException: If no job with the specified ID exists.
- abstract delete_job_template(job_template_name: str) bool ¶
Deletes a job template by its name. This will remove the job template from Gravitino, and it will no longer be available for execution. Only when all the jobs associated with this job template are completed, failed or cancelled, the job template can be deleted successfully, otherwise it will return false.
The deletion of a job template will also delete all the jobs associated with this template.
- Args:
job_template_name: The name of the job template to delete.
- Returns:
bool: True if the job template was deleted successfully, False if the job template does not exist.
- Raises:
InUseException: If there are still queued or started jobs associated with this job template.
- abstract get_job(job_id: str) JobHandle ¶
Retrieves a job by its ID.
- Args:
job_id: The ID of the job to retrieve.
- Returns:
JobHandle: The handle representing the job with the specified ID.
- Raises:
NoSuchJobException: If no job with the specified ID exists.
- abstract get_job_template(job_template_name: str) JobTemplate ¶
Retrieves a job template by its name.
- Args:
job_template_name: The name of the job template to retrieve.
- Returns:
The job template if found, otherwise raises an exception.
- Raises:
NoSuchJobTemplateException: If no job template with the specified name exists.
- abstract list_job_templates() List[JobTemplate] ¶
Lists all the registered job templates in Gravitino.
- Returns:
List of job templates.
- list_jobs(job_template_name: str | None = None) List[JobHandle] ¶
Lists all the jobs in Gravitino. If a job template name is provided, it will filter the jobs by that template.
- Args:
job_template_name: Optional; if provided, only jobs associated with this template will be listed.
- Returns:
List of JobHandle objects representing the jobs.
- abstract register_job_template(job_template) None ¶
Register a job template with the specified job template to Gravitino. The registered job will be maintained in Gravitino, allowing it to be executed later.
- Args:
job_template: The job template to register.
- Raises:
JobTemplateAlreadyExists: If a job template with the same name already exists.
- abstract run_job(job_template_name: str, job_conf: Dict[str, str]) JobHandle ¶
Run a job with the template name and configuration. The jobConf is a map of key-value contains the variables that will be used to replace the templated parameters in the job template.
- Args:
job_template_name: The name of the job template to run. job_conf: A dictionary containing the job configuration parameters.
- Returns:
JobHandle: A handle to the running job, which can be used to monitor or manage the job.
- Raises:
NoSuchJobTemplateException: If no job template with the specified name exists.