tugboat.references package

Reference management utilities for workflows and templates.

This module helps you track and validate variable references that are available in different workflow scopes. The core component is the Context class, which maintains collections of available references for a specific scope.

For detailed information about references, see Workflow Variables in the Argo Workflows documentation.

class tugboat.references.Context(*, parameters: ~typing.Annotated[~tugboat.references.context.ReferenceCollection, ~pydantic.functional_validators.InstanceOf()] = <factory>, artifacts: ~typing.Annotated[~tugboat.references.context.ReferenceCollection, ~pydantic.functional_validators.InstanceOf()] = <factory>)

Data class for storing available references within a given scope.

You can use the in syntax to check if a reference exists in the context. For example:

ctx = get_workflow_context(workflow)
if ("inputs", "parameters", "message") in ctx.parameters:
    print("The variable `inputs.parameters.message` is available.")
artifacts: InstanceOf[ReferenceCollection]

Collection of available artifacts.

parameters: InstanceOf[ReferenceCollection]

Collection of available parameters.

class tugboat.references.ReferenceCollection(iterable: Iterable[_TR] = ())

A set-like collection of references, handling the special logic of AnyStr.

add(value)

Add an element.

discard(value)

Remove an element. Do not raise an exception if absent.

find_closest(target: _TR) _TR

Find the closest match for a given reference in a list of reference.

tugboat.references.get_global_context() Context

Returns a context with the available global references.

tugboat.references.get_step_context(workflow: Workflow | WorkflowTemplate, template: Template, step: Step) Context

Retrieve the context for a specific step.

tugboat.references.get_task_context(workflow: Workflow | WorkflowTemplate, template: Template, task: DagTask) Context

Retrieves the context for a DAG task.

tugboat.references.get_template_context(workflow: Workflow | WorkflowTemplate, template: Template) Context

Returns a context with the available references for the given template.

tugboat.references.get_workflow_context(workflow: Workflow | WorkflowTemplate) Context

Returns a context with the available references for the given workflow.