Task

class caliber.Task(function: Callable | None = None, name: str | None = None, args: List | None = None, kwargs: Dict | None = None)[source]

A task which can be part of a process.

Parameters:
  • function (function) – The function that will be run by the task.

  • name (str) – The name of the task.

  • args (list) – The positional arguments of function. If the task is part of a BranchProcess, args should be a list of lists.

  • kwargs (dict) – The keyword arguments of the function. If the task is part of a BranchProcess, kwargs should be a list of dicts.

run()[source]

Run the function referred to by the Task object.

Returns:

The return of the function referred to by the Task object.

to_dict() Dict[source]

Return dictionary representation of the Task object.

to_json(out_file: str | TextIO) None[source]

Export to a json-file.

Parameters:

out_file (str or file-like object) – The file to write to.

copy()[source]

Create a copy of the task.

static from_json(infile: str) Task | None[source]

Initiate a Task from a json file.

Parameters:

infile (str) – The name of the json file.