finam.tools.ConnectHelper#

class finam.tools.ConnectHelper(logger_name, inputs, outputs, pull_data=None, in_info_rules=None, out_info_rules=None, cache=True)[source]#

Bases: Loggable

Helper for iterative connect.

Warning

This class is not intended for direct use! Use Component.create_connector() and Component.try_connect() instead.

Parameters:
  • logger (Logger) – Logger to use

  • inputs (dict) – All inputs of the component.

  • outputs (dict) – All outputs of the component.

  • in_info_rules (dict) – Info transfer rules for inputs.

  • out_info_rules (dict) – Info transfer rules for outputs.

  • pull_data (arraylike) – Names of the inputs that are to be pulled.

  • cache (bool) – Whether data and Info objects passed via connect() are cached for later calls. Default True.

Attributes:
all_data_pulled

bool: True if all expected data is pulled.

data_pushed

dict: If data was pushed for outputs so far.

data_required

dict: If data to push is still required.

in_data

dict: The pulled input data so far. May contain None values.

in_infos

dict: The exchanged input infos so far. May contain None values.

in_infos_required

dict: If input infos to exchange are still required.

infos_pushed

dict: If an info was pushed for outputs so far.

inputs

dict: The component’s inputs.

logger

Logger for this component.

logger_name

Logger name derived from base logger name and class name.

out_infos

dict: The exchanged output infos so far. May contain None values.

out_infos_required

dict: If output infos to push are still required.

outputs

dict: The component’s outputs.

uses_base_logger_name

Whether this class has a base_logger_name attribute.

Methods

add_in_info_rule(in_name, rule)

Add an input info rule.

add_out_info_rule(out_name, rule)

Add an output info rule.

connect(start_time[, exchange_infos, ...])

Exchange the info and data with linked components.

add_in_info_rule(in_name, rule)[source]#

Add an input info rule.

Parameters:
  • in_name (str) – Name of the input to add an info rule to.

  • rule (FromOutput or FromInput or FromValue) – Rule to add.

add_out_info_rule(out_name, rule)[source]#

Add an output info rule.

Parameters:
  • out_name (str) – Name of the output to add an info rule to.

  • rule (FromInput or FromOutput or FromValue) – Rule to add.

property logger#

Logger for this component.

property logger_name#

Logger name derived from base logger name and class name.

property uses_base_logger_name#

Whether this class has a base_logger_name attribute. True.

property inputs#

The component’s inputs.

Type:

dict

property outputs#

The component’s outputs.

Type:

dict

property in_infos#

The exchanged input infos so far. May contain None values.

Type:

dict

property out_infos#

The exchanged output infos so far. May contain None values.

Type:

dict

property in_data#

The pulled input data so far. May contain None values.

Type:

dict

property all_data_pulled#

True if all expected data is pulled.

Type:

bool

property infos_pushed#

If an info was pushed for outputs so far.

Type:

dict

property data_pushed#

If data was pushed for outputs so far.

Type:

dict

property data_required#

If data to push is still required.

Type:

dict

property in_infos_required#

If input infos to exchange are still required.

Type:

dict

property out_infos_required#

If output infos to push are still required.

Type:

dict

connect(start_time, exchange_infos=None, push_infos=None, push_data=None)[source]#

Exchange the info and data with linked components.

Values passed by the arguments are cached internally for later calls to the method if constructed with cache=True (the default). Thus, it is sufficient to provide only data and infos that became newly available. Giving the same data or infos repeatedly overwrites the cache.

Parameters:
  • start_time (datetime) – the composition’s starting time as passed to Component.try_connect()

  • exchange_infos (dict) – currently or newly available input data infos by input name

  • push_infos (dict) – currently or newly available output data infos by output name

  • push_data (dict) – currently or newly available output data by output name

Returns:

the new component status

Return type:

ComponentStatus