matflow.Action#

class matflow.Action(environments=None, commands=None, script=None, script_data_in=None, script_data_out=None, script_data_files_use_opt=False, script_exe=None, script_pass_env_spec=False, abortable=False, input_file_generators=None, output_file_parsers=None, input_files=None, output_files=None, rules=None, save_files=None, clean_up=None)#

Bases: Action

Methods

compose_source

Generate the file contents of this source.

expand

from_json_like

generate_data_index

Generate the data index for this action of an element iteration whose overall data index is passed.

get_command_input_file_labels

Get input files types from commands.

get_command_input_types

Get parameter types from commands.

get_command_output_types

Get parameter types from command stdout and stderr arguments.

get_commands_action_env

get_environment

get_environment_name

get_environment_spec

get_input_file_generator_action_env

get_input_file_labels

get_input_types

Get the input types that are consumed by commands and input file generators of this action.

get_output_file_labels

get_output_file_parser_action_env

get_output_types

Get the output types that are produced by command standard outputs and errors, and by output file parsers of this action.

get_param_dump_file_path_HDF5

get_param_dump_file_path_JSON

get_param_dump_file_stem

get_param_load_file_path_HDF5

get_param_load_file_path_JSON

get_param_load_file_stem

get_parameter_dependence

Find if/where a given parameter is used by the action.

get_parameter_names

Get parameter types associated with a given prefix.

get_possible_scopes

Get the action scopes that are inclusive of this action, ordered by decreasing specificity.

get_precise_scope

get_required_executables

Return executable labels required by this action.

get_resolved_action_env

get_script_name

Return the script name.

get_snippet_script_path

get_snippet_script_str

is_input_type_required

is_snippet_script

Returns True if the provided script string represents a script snippets that is to be modified before execution (e.g.

process_script_data_formats

test_rules

Test all rules against the specified element iteration.

to_dict

to_json_like

Attributes

app

script_data_in_grouped

Get input parameter types by script data-in format.

script_data_in_has_direct

Return True if the script requires some inputs to be passed directly from the app.

script_data_in_has_files

Return True if the script requires some inputs to be passed via an intermediate file format.

script_data_out_grouped

Get output parameter types by script data-out format.

script_data_out_has_direct

Return True if the script produces some outputs to be passed directly to the app.

script_data_out_has_files

Return True if the script produces some outputs via an intermediate file format.

script_is_python

Return True if the script is a Python script (determined by the file extension)

task_schema

Parameters:
  • environments (Optional[List[app.ActionEnvironment]]) –

  • commands (Optional[List[app.Command]]) –

  • script (Optional[str]) –

  • script_data_in (Optional[str]) –

  • script_data_out (Optional[str]) –

  • script_data_files_use_opt (Optional[bool]) –

  • script_exe (Optional[str]) –

  • script_pass_env_spec (Optional[bool]) –

  • abortable (Optional[bool]) –

  • input_file_generators (Optional[List[app.InputFileGenerator]]) –

  • output_file_parsers (Optional[List[app.OutputFileParser]]) –

  • input_files (Optional[List[app.FileSpec]]) –

  • output_files (Optional[List[app.FileSpec]]) –

  • rules (Optional[List[app.ActionRule]]) –

  • save_files (Optional[List[str]]) –

  • clean_up (Optional[List[str]]) –

app = App(name='MatFlow', version='0.3.0a129')#
compose_source(snip_path)#

Generate the file contents of this source.

Parameters:

snip_path (Path) –

Return type:

str

expand()#
classmethod from_json_like(json_like, shared_data=None)#
Parameters:
  • json_like (Union[Dict, List]) –

  • shared_data (Optional[Dict[str, ObjectList]]) –

generate_data_index(act_idx, EAR_ID, schema_data_idx, all_data_idx, workflow, param_source)#

Generate the data index for this action of an element iteration whose overall data index is passed.

This mutates all_data_idx.

Return type:

List[int]

get_command_input_file_labels()#

Get input files types from commands.

Return type:

Tuple[str]

get_command_input_types(sub_parameters=False)#

Get parameter types from commands.

Parameters:

sub_parameters (bool) – If True, sub-parameters (i.e. dot-delimited parameter types) will be returned untouched. If False (default), only return the root parameter type and disregard the sub-parameter part.

Return type:

Tuple[str]

get_command_output_types()#

Get parameter types from command stdout and stderr arguments.

Return type:

Tuple[str]

get_commands_action_env()#
get_environment()#
Return type:

Environment

get_environment_name()#
Return type:

str

get_environment_spec()#
Return type:

Dict[str, Any]

get_input_file_generator_action_env(input_file_generator)#
Parameters:

input_file_generator (InputFileGenerator) –

get_input_file_labels()#
get_input_types(sub_parameters=False)#

Get the input types that are consumed by commands and input file generators of this action.

Parameters:

sub_parameters (bool) – If True, sub-parameters (i.e. dot-delimited parameter types) in command line inputs will be returned untouched. If False (default), only return the root parameter type and disregard the sub-parameter part.

Return type:

Tuple[str]

get_output_file_labels()#
get_output_file_parser_action_env(output_file_parser)#
Parameters:

output_file_parser (OutputFileParser) –

get_output_types()#

Get the output types that are produced by command standard outputs and errors, and by output file parsers of this action.

Return type:

Tuple[str]

get_param_dump_file_path_HDF5(js_idx, js_act_idx)#
Parameters:
  • js_idx (int) –

  • js_act_idx (int) –

get_param_dump_file_path_JSON(js_idx, js_act_idx)#
Parameters:
  • js_idx (int) –

  • js_act_idx (int) –

static get_param_dump_file_stem(js_idx, js_act_idx)#
Parameters:
  • js_idx (int) –

  • js_act_idx (int) –

get_param_load_file_path_HDF5(js_idx, js_act_idx)#
Parameters:
  • js_idx (int) –

  • js_act_idx (int) –

get_param_load_file_path_JSON(js_idx, js_act_idx)#
Parameters:
  • js_idx (int) –

  • js_act_idx (int) –

static get_param_load_file_stem(js_idx, js_act_idx)#
Parameters:
  • js_idx (int) –

  • js_act_idx (int) –

get_parameter_dependence(parameter)#

Find if/where a given parameter is used by the action.

Parameters:

parameter (SchemaParameter) –

get_parameter_names(prefix)#

Get parameter types associated with a given prefix.

For example, with the prefix “inputs”, this would return [‘p1’, ‘p2’] for an action that has input types p1 and p2. For inputs, labels are ignored. For example, for an action that accepts two inputs of the same type p1, with labels one and two, this method would return (for the “inputs” prefix): [‘p1[one]’, ‘p1[two]’].

This method is distinct from TaskSchema.get_parameter_names in that it returns action-level input/output/file types/labels, whereas TaskSchema.get_parameter_names returns schema-level inputs/outputs.

Parameters:

prefix (str) – One of “inputs”, “outputs”, “input_files”, “output_files”.

Return type:

List[str]

get_possible_scopes()#

Get the action scopes that are inclusive of this action, ordered by decreasing specificity.

Return type:

Tuple[ActionScope]

get_precise_scope()#
Return type:

ActionScope

get_required_executables()#

Return executable labels required by this action.

Return type:

Tuple[str]

get_resolved_action_env(relevant_scopes, input_file_generator=None, output_file_parser=None, commands=None)#
Parameters:
classmethod get_script_name(script)#

Return the script name.

Parameters:

script (str) –

Return type:

str

classmethod get_snippet_script_path(script_path, env_spec=None)#
Parameters:

env_spec (Dict[str, Any] | None) –

Return type:

Path

classmethod get_snippet_script_str(script, env_spec=None)#
Parameters:

env_spec (Dict[str, Any] | None) –

Return type:

str

is_input_type_required(typ, provided_files)#
Parameters:
Return type:

bool

static is_snippet_script(script)#

Returns True if the provided script string represents a script snippets that is to be modified before execution (e.g. to receive and provide parameter data).

Parameters:

script (str) –

Return type:

bool

process_script_data_formats()#
property script_data_in_grouped: Dict[str, List[str]]#

Get input parameter types by script data-in format.

property script_data_in_has_direct: bool#

Return True if the script requires some inputs to be passed directly from the app.

property script_data_in_has_files: bool#

Return True if the script requires some inputs to be passed via an intermediate file format.

property script_data_out_grouped: Dict[str, List[str]]#

Get output parameter types by script data-out format.

property script_data_out_has_direct: bool#

Return True if the script produces some outputs to be passed directly to the app.

property script_data_out_has_files: bool#

Return True if the script produces some outputs via an intermediate file format.

property script_is_python: bool#

Return True if the script is a Python script (determined by the file extension)

property task_schema#
test_rules(element_iter)#

Test all rules against the specified element iteration.

Return type:

Tuple[bool, List[int]]

to_dict()#
to_json_like(dct=None, shared_data=None, exclude=None, path=None)#