cpalgnodes.wrappers module

Helper classes to allow other objects to be interpreted as nodes

class cpalgnodes.wrappers.PreconfiguredNode(name: str, preconfigured, priority: int = 0, produces_aux: Dict[str, Set[str]] | None = None, produces_containers: Dict[str, str] | None = None, requires_aux: Dict[str, Set[str]] | None = None, has_job_output: bool = False)

Bases: WrapperNode

Node in the graph which contains preconfigured components

This allows letting the scheduler decide where to run the algorithms based on their dependencies while using external code to build the components.

create(container_info: Mapping[str, ContainerInfo]) Algorithm | List[Algorithm] | ConfigFragment

Create the algorithm(s) represented by this node

Parameters:

container_info (Mapping[str, ContainerInfo]) – The ContainerInfo for each input/output container

Returns:

The configured algorithm(s)

Return type:

Union[Algorithm, List[Algorithm], ConfigFragment]

property name: str

The name of this node (should be unique within the graph)

property priority: int

Nodes with a higher priority will try to be ordered earlier

class cpalgnodes.wrappers.UserAlgNode(type: str, name: str, priority: int = 0, inputs: Dict[str, str] | None = None, outputs: Dict[str, str] | None = None, produces_aux: Dict[str, Set[str]] | None = None, produces_containers: Dict[str, str] | None = None, requires_aux: Dict[str, Set[str]] | None = None, has_job_output: bool = False, **properties)

Bases: WrapperNode, AlgNode

Node that wraps a single user-configured algorithm

class cpalgnodes.wrappers.WrapperNode(*, requires_aux: Dict[str, Set[str]] | None = None, produces_aux: Dict[str, Set[str]] | None = None, produces_containers: Dict[str, str] | None = None, has_job_output: bool = False, **kwargs)

Bases: Node

Node class for wrapping preconfigured components

This is a base class for cases where a user provides a (mostly) configured fragment that the scheduler can still insert into the schedule based on its dependencies.

property has_job_output: bool

Whether or not this node is responsible for producing output from the job.

If a node produces output (e.g. a TTree or histogram) it is always required and so the scheduler will add a dependency from it to the output node.

property produces_aux: Dict[str, Set[str]]

The auxdata produced by this node, split by container

Return type:

A dictionary mapping container nicknames to the set of auxnames the node produces

property produces_containers: Dict[str, str]

Any containers created by this node

Containers are returned as a dictionary mapping from the created container nickname to its parent container (or None otherwise). A container has a parent if it is a deep copy, shallow copy or view. Where a node updates a container it should have itself as the parent.

property requires_aux: Dict[str, Set[str]]

The auxdata required by this node, split by container

Return type:

A dictionary mapping container nicknames to the set of auxnames the node requires