hpcflow.app.Command#

class hpcflow.app.Command(command=None, executable=None, arguments=None, variables=None, stdout=None, stderr=None, stdin=None, rules=<factory>)#

Bases: Command

A command that may be run within a workflow action.

Parameters:
  • command (str) – The actual command.

  • executable (str) – The executable to run, from the set of executable managed by the environment.

  • arguments (list[str]) – The arguments to pass in.

  • variables (dict[str, str]) – Values that may be substituted when preparing the arguments.

  • stdout (str) – The name of a file to write standard output to.

  • stderr (str) – The name of a file to write standard error to.

  • stdin (str) – The name of a file to read standard input from.

  • rules (list[ActionRule]) – Rules that state whether this command is eligible to run.

Methods

from_json_like

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

get_command_line

Return the resolved command line.

get_output_types

Get whether stdout and stderr are workflow parameters.

get_required_executables

Return executable labels required by this command.

process_std_stream

Process a description of a standard stread from a command to get how it becomes a workflow parameter for later actions.

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.

Attributes

arguments

The arguments to pass in.

command

The actual command.

executable

The executable to run, from the set of executable managed by the environment.

stderr

The name of a file to write standard error to.

stdin

The name of a file to read standard input from.

stdout

The name of a file to write standard output to.

variables

Values that may be substituted when preparing the arguments.

rules

Rules that state whether this command is eligible to run.

arguments: list[str] | None = None#

The arguments to pass in.

command: str | None = None#

The actual command. Overrides executable.

executable: str | None = None#

The executable to run, from the set of executable managed by the environment.

classmethod from_json_like(json_like, shared_data=None)#

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

Parameters:
  • json_like (str | Mapping[str, JSONed] | Sequence[Mapping[str, JSONed]] | None) – The data to deserialise.

  • shared_data (Mapping[str, ObjectList[JSONable]] | None) – Shared context data.

Return type:

The deserialised object.

get_command_line(EAR, shell, env)#

Return the resolved command line.

This is ordinarily called at run-time by Workflow.write_commands.

Parameters:
Return type:

tuple[str, list[tuple[str, …]]]

get_output_types()#

Get whether stdout and stderr are workflow parameters.

Return type:

Mapping[str, str | None]

get_required_executables()#

Return executable labels required by this command.

Return type:

Sequence[str]

process_std_stream(name, value, stderr)#

Process a description of a standard stread from a command to get how it becomes a workflow parameter for later actions.

Parameters:
  • name (str) – The name of the output, describing how to process things.

  • value (str) – The actual value read from the stream.

  • stderr (bool) – If true, this is handling the stderr stream. If false, the stdout stream.

Return type:

Any

rules: list[ActionRule]#

Rules that state whether this command is eligible to run.

stderr: str | None = None#

The name of a file to write standard error to.

stdin: str | None = None#

The name of a file to read standard input from.

stdout: str | None = None#

The name of a file to write standard output to.

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]

variables: dict[str, str] | None = None#

Values that may be substituted when preparing the arguments.