Skip to content

to_taskflow

Convert to Taskflow flow.

make_variable_collector_task(name, input_rebinds, provides)

Create an intermedidate "collector" task to rebind multiple connections to a single output.

Source code in client/ayon_workflow/workflow_execution/to_taskflow.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
def make_variable_collector_task(
        name: str,
        input_rebinds: List[str],
        provides: str,
    ):
    """ Create an intermedidate "collector" task to rebind multiple
    connections to a single output.
    """
    class MultiConnectionCollector(task.Task):
        """
        This task gets automatically inserted before any input defined
        as 'allow_multi_connection'.
        In taskflow, an input can only be rebind to a single value,
        so this task collects multiple inputs into a single list output.
        """
        def execute(self, **kwargs):
            # node input is connected to only 1 output, leave it as-is.
            if len(kwargs) == 1:
                return kwargs[list(kwargs.keys())[0]]

            # force a rebind of the depending node outputs and
            # provide the result as a list to the following node input.
            return [kwargs[key] for key in kwargs.keys()]

    return MultiConnectionCollector(
        name=name,
        rebind=input_rebinds,
        provides=provides
    )