hpcflow.app.OutputFileParser#

class hpcflow.app.OutputFileParser(output_files, output=None, script=None, environment=None, inputs=None, outputs=None, options=None, script_pass_env_spec=False, abortable=False, save_files=True, clean_up=<factory>, rules=<factory>)#

Bases: OutputFileParser

Represents a script that is run to parse output files from an action and create outputs.

Parameters:
  • output_files (list[FileSpec]) – The output files that this parser will parse.

  • output (Parameter) – The singular output parsed by this parser. Not to be confused with outputs (plural).

  • script (str) – The name of the file containing the output file parser source.

  • environment (Environment) – The environment to use to run the parser.

  • inputs (list[str]) – The other inputs to the parser.

  • outputs (list[str]) – Optional multiple outputs from the upstream actions of the schema that are required to parametrise this parser.

  • options (dict) – Miscellaneous options.

  • script_pass_env_spec (bool) – Whether to pass the environment specifier to the script.

  • abortable (bool) – Whether this script can be aborted.

  • save_files (list[str]) – The files that should be saved to the persistent store for the workflow.

  • clean_files (list[str]) – The files that should be immediately removed.

  • rules (list[ActionRule]) – Rules for whether to enable this parser.

  • clean_up (list[str]) –

Methods

compose_source

Generate the file contents of this output file parser source.

from_json_like

Make an instance of this class from JSON (or YAML) data.

get_action_rules

Get the rules that allow testing if this output file parser must be run or not for a given element.

to_dict

Serialize this object as a dictionary.

to_json_like

Serialize this object as an object structure that can be trivially converted to JSON.

write_source

Write the actual output parser to a file so it can be enacted.

Attributes

abortable

Whether this script can be aborted.

environment

The environment to use to run the parser.

inputs

The other inputs to the parser.

options

Miscellaneous options.

output

The singular output parsed by this parser.

outputs

Optional multiple outputs from the upstream actions of the schema that are required to parametrise this parser.

save_files

The files that should be saved to the persistent store for the workflow.

script

The name of the file containing the output file parser source.

script_pass_env_spec

Whether to pass the environment specifier to the script.

output_files

The output files that this parser will parse.

clean_up

The files that should be immediately removed.

rules

Rules for whether to enable this parser.

abortable: bool = False#

Whether this script can be aborted.

clean_up: list[str]#

The files that should be immediately removed.

compose_source(snip_path)#

Generate the file contents of this output file parser source.

Parameters:

snip_path (Path) –

Return type:

str

environment: Environment | None = None#

The environment to use to run the parser.

classmethod from_json_like(json_like, shared_data=None)#

Make an instance of this class from JSON (or YAML) data.

Parameters:
  • json_like (dict[str, Any]) – The data to deserialise.

  • shared_data (Mapping | None) – Shared context data.

Return type:

The deserialised object.

get_action_rules()#

Get the rules that allow testing if this output file parser must be run or not for a given element.

Return type:

list[ActionRule]

inputs: list[str] | None = None#

The other inputs to the parser.

options: dict[str, Any] | None = None#

Miscellaneous options.

output: Parameter | None = None#

The singular output parsed by this parser. Not to be confused with outputs (plural).

output_files: list[FileSpec]#

The output files that this parser will parse.

outputs: list[str] | None = None#

Optional multiple outputs from the upstream actions of the schema that are required to parametrise this parser. Not to be confused with output (plural).

rules: list[ActionRule]#

Rules for whether to enable this parser.

save_files: InitVar[list[FileSpec] | bool] = True#

The files that should be saved to the persistent store for the workflow.

script: str | None = None#

The name of the file containing the output file parser source.

script_pass_env_spec: bool = False#

Whether to pass the environment specifier to the script.

to_dict()#

Serialize this object as a dictionary.

Return type:

dict[str, Any]

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

Serialize this object as an object structure that can be trivially converted to JSON. Note that YAML can also be produced from the result of this method; it just requires a different final serialization step.

Parameters:
  • dct (dict[str, JSONable] | None) –

  • shared_data (_JSONDeserState) –

  • exclude (Container[str | None]) –

  • path (list | None) –

Return type:

tuple[JSONDocument, _JSONDeserState]

write_source(action, env_spec)#

Write the actual output parser to a file so it can be enacted.

Parameters:
  • action (Action) –

  • env_spec (Mapping[str, Any]) –

Return type:

None