Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

DynamicOutputs

Dynamic output specification that allows tasks to have a variable number of output ports.

This class enables tasks to produce a variable number of output resources that can be defined at runtime. The task should return an iterable of resources under the name specified by SPEC_NAME ('target'), which will be automatically distributed to the individual output ports based on their order.

Dynamic outputs are useful for tasks that produce an unpredictable number of results, such as splitting a file into multiple parts or generating multiple datasets from a single analysis.

Attributes: SPEC_NAME: The name of the output parameter the task should return ('target'). The task must return an iterable of resources under this key. additionnal_port_spec: Optional specification that defines the type and constraints for dynamically created output ports. If None, defaults to accepting any Resource subclass.

Example: ```python # Define dynamic outputs that produce Table resources outputs = DynamicOutputs( additionnal_port_spec=OutputSpec(Table, human_name="Output table") )

# In the task's run method:
def run(self, params: ConfigParams, inputs: InputsDTO) -> OutputsDTO:
    # Create multiple output tables
    tables = [table1, table2, table3]
    # Return as an iterable under 'target'
    return {'target': tables}
```

Notes: - The number of resources in the returned iterable must not exceed the number of configured output ports. - Resources are assigned to ports based on their order in the iterable and the order of the port keys. - If fewer resources are returned than there are ports, remaining ports will be empty.

Attributes
additionnal_port_spec: gws_core.io.io_spec.OutputSpec | None
Functions
__init__
default_specs : dict[str, gws_core.io.io_spec.OutputSpec] | None
default specs used when creating the outputs
additionnal_port_spec : gws_core.io.io_spec.OutputSpec | None
force the type of newly created port
check_and_build_outputs

Method that check if the task outputs

task_outputs : dict
outputs to check
Return type : OutputsCheckResult
get_additional_info
Return type : dict
get_default_spec
Return type : OutputSpec
get_first_spec
Return type : gws_core.io.io_spec.IOSpec | None
get_spec
name : str
Return type : IOSpec
get_specs
Return type : dict
get_type
Return type : Literal
has_spec
name : str
Return type : bool
set_additional_info
additional_info : dict | None
to_dto
Return type : IOSpecsDTO
from_dto @classmethod
io_specs : dict
additional_info : dict | None
Return type : DynamicOutputs
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.