qlauncher.workflow.base_job_manager#
Summary#
Classes:
Abstract base class for job managers that execute functions. |
Reference#
- class qlauncher.workflow.base_job_manager.BaseJobManager[source]#
Bases:
ABCAbstract base class for job managers that execute functions. on different compute backends.
- abstractmethod submit(function: Callable, **kwargs) str[source]#
Submit a function job to the scheduler.
- Parameters:
function (Callable) – Function to be executed.
cores – Number of CPU cores per task.
**kwargs – Manager-specific additional arguments.
- Returns:
Job ID as a string.
- Return type:
str
- abstractmethod wait_for_a_job(job_id: str | None = None, timeout: float | None = None) str | None[source]#
Wait for a job to finish and return its ID.
- Parameters:
job_id (str | None) – ID of the job to wait for. If None, wait for any job.
timeout (float | None) – Maximum time to wait in seconds. If None, wait indefinitely.
- Returns:
Job ID of the finished job.
- Raises:
ValueError – If no jobs are available to wait for.
TimeoutError – If timeout is exceeded.
- Return type:
str | None
- abstractmethod read_results(job_id: str) Any[source]#
Read the result of a finished job.
- Parameters:
job_id (str) – Job ID returned by submit().
- Returns:
Result object produced by the job.
- Raises:
KeyError – If job_id is not known to this manager.
FileNotFoundError – If the result file does not exist.
- Return type:
Any
- abstractmethod cancel(job_id: str)[source]#
Cancel a given job
- Parameters:
job_id (str) – id of the job to cancel.
- Raises:
KeyError – If job with a given id was not submitted by this manager.
- Returns:
None
- abstractmethod clean_up() None[source]#
Clean up temporary files and resources created by the manager.
- run(function: Callable, **kwargs) Any[source]#
Convenience method: submit job, wait for completion, read results, and cleanup.
This method handles the complete lifecycle of a job execution.
- Parameters:
function (Callable) – Function to be executed.
cores – Number of CPU cores per task.
**kwargs – Manager-specific additional arguments.
- Returns:
Result object produced by the job.
- Return type:
Any