hymir.job module

class hymir.job.CheckLater(*, wait_for: int = None, context: dict[str, Any] = None)

Bases: JobResult

The job has not yet completed, and should be checked later.

This result can be used to indicate that the job is waiting for an external event to occur before it can be completed. The workflow engine should periodically check the job to see if it has completed, and will not continue until the job has completed.

Note

This result is _not_ a retry, and does not count towards the maximum number of retries for a job.

Parameters:
  • wait_for – The number of seconds to wait before checking again.

  • context – A dictionary of context to pass back to the job when it is checked again.

class hymir.job.Failure(result: Any = None)

Bases: JobResult

The job completed with a failure, potentially with a value which can be used to return information about the error.

class hymir.job.Job(name: str, identity: int = None, args: tuple = <factory>, kwargs: dict = <factory>, output: str = None, inputs: list[str] = None, meta: dict = None)

Bases: object

A job is a single unit of work in the workflow.

args: tuple
classmethod deserialize(data: dict)

Deserialize a job from a dictionary.

classmethod from_function(f: Callable[[...], Any]) Job

Create a job from a function.

identity: int = None
inputs: list[str] = None
kwargs: dict
meta: dict = None
name: str
output: str = None
serialize()

Serialize the job to a dictionary.

set(*args, **kwargs: Any) Job

Set the arguments for the job.

with_inputs(*inputs: str) Job

Bind the inputs of this job to the outputs of other jobs.

Parameters:

inputs – The names of the outputs to bind to the inputs.

with_meta(**meta: Any) Job

Add metadata to the job.

with_output(name: str) Job

Capture the output of this job in a variable, replacing any existing output variable if one is set.

Parameters:

name – The name of the variable to capture the output in.

class hymir.job.JobResult

Bases: object

Base class for the return value of a job.

class hymir.job.Retry(*, wait_min: int = None, wait_max: int = None, max_retries: int = None)

Bases: JobResult

The job failed, but the workflow should be retried.

This result can be used to indicate that the job failed due to a transient error, and the job should be retried.

Parameters:
  • wait_min – The lower bounds of random jitter to apply to the retry interval.

  • wait_max – The upper bounds of random jitter to apply to the retry interval.

  • max_retries – The maximum number of times to retry the job.

class hymir.job.Success(result: Any = None)

Bases: JobResult

The job completed successfully, potentially with a value to be returned.

hymir.job.job(*, inputs: list[str] = None, output: str = None, meta: dict = None)

Convenience decorator to create a job from a function.

The wrapped function should return a Success, Failure, CheckLater, or Retry object to explicitly indicate the result of the job.

Some inputs are reserved. The inputs “workflow_id”, “job_id”, “workflow”, “job_state”, and “workflow_state” can be requested to get information about the currently running job.

Note

PyCharm will not recognize the return type of this decorator, and will not provide autocompletion for the Job. This is a limitation of PyCharm’s type system and is bug PY-40071.