Skip to content

unique

unique

Contains the function for the constraint that makes a required task be unique throughout all prior tasks in a pipeline.

is_unique_in_prior_tasks(vs: Mapping[str, CoSyLuigiTask], required_to_be_unique: type[CoSyLuigiTask] | Sequence[type[CoSyLuigiTask]]) -> bool

Wrapper around _is_unique_in_prior_tasks that allows passing either a single type of a CoSyLuigiTask or a Sequence of CoSyLuigiTasks' types.

Parameters:

Name Type Description Default
vs Mapping[str, CoSyLuigiTask]

The variables passed to the function by CoSy during synthesis. Populated by the partial pipelines beginning at current tasks required tasks.

required
required_to_be_unique type[CoSyLuigiTask] | Sequence[type[CoSyLuigiTask]]

The CoSyLuigiTask's type or types that are intended to be unique.

required

Returns:

Name Type Description
bool bool

True if all types contained in required_to_be_unique are unique, False otherwise.

Source code in src/cosy_luigi/constraints/unique.py
def is_unique_in_prior_tasks(
    vs: Mapping[str, CoSyLuigiTask], required_to_be_unique: type[CoSyLuigiTask] | Sequence[type[CoSyLuigiTask]]
) -> bool:
    """Wrapper around _is_unique_in_prior_tasks that allows passing either a single type of a CoSyLuigiTask or a
    Sequence of CoSyLuigiTasks' types.

    Args:
        vs (Mapping[str, CoSyLuigiTask]): The variables passed to the function by CoSy during synthesis. Populated by the partial pipelines beginning at current tasks required tasks.
        required_to_be_unique (type[CoSyLuigiTask] | Sequence[type[CoSyLuigiTask]]): The CoSyLuigiTask's type or types that are intended to be unique.

    Returns:
        bool: True if all types contained in required_to_be_unique are unique, False otherwise.
    """
    return _is_unique_in_prior_tasks(
        vs,
        required_to_be_unique if isinstance(required_to_be_unique, Sequence) else [required_to_be_unique],
    )