hpcflow.app.InputFileGenerator#

class hpcflow.app.InputFileGenerator(input_file, inputs, script=None, environment=None, script_pass_env_spec=False, abortable=False, rules=None)#

Bases: InputFileGenerator

Represents a script that is run to generate input files for an action.

Parameters:
  • input_file (hpcflow.app.FileSpec) – The file to generate.

  • inputs (list[Parameter]) – The input parameters to the generator.

  • script (str) – The script that generates the input.

  • environment (hpcflow.app.Environment) – The environment in which to run the generator.

  • script_pass_env_spec (bool | None) – Whether to pass in the environment.

  • abortable (bool | None) – Whether the generator can be stopped early. Quick-running scripts tend to not need this.

  • rules (list[ActionRule]) – User-specified rules for whether to run the generator.

Methods

compose_source

Generate the file contents of this input file generator 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 input file generator 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 script if it is specified as a snippet script, otherwise we assume the script already exists in the working directory.

Attributes

abortable

Whether the generator can be stopped early.

app

environment

The environment in which to run the generator.

rules

User-specified rules for whether to run the generator.

script

The script that generates the inputs.

script_pass_env_spec

Whether to pass in the environment.

input_file

The file to generate.

inputs

The input parameters to the generator.

abortable: bool | None = False#

Whether the generator can be stopped early. Quick-running scripts tend to not need this.

app = BaseApp(name='hpcFlow', version='0.2.0a180')#
compose_source(snip_path)#

Generate the file contents of this input file generator source.

Return type:

str

environment: app.Environment = None#

The environment in which to run the generator.

classmethod from_json_like(json_like, shared_data=None)#

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

Parameters:
  • json_like (Union[Dict, List]) – The data to deserialise.

  • shared_data (Optional[Dict[str, ObjectList]]) – Shared context data.

Return type:

The deserialised object.

get_action_rules()#

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

input_file: app.FileSpec#

The file to generate.

inputs: List[app.Parameter]#

The input parameters to the generator.

rules: List[app.ActionRule] | None = None#

User-specified rules for whether to run the generator.

script: str = None#

The script that generates the inputs.

script_pass_env_spec: bool | None = False#

Whether to pass in the environment.

to_dict()#

Serialize this object as a dictionary.

to_json_like(dct=None, shared_data=None, exclude=None, 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.

write_source(action, env_spec)#

Write the script if it is specified as a snippet script, otherwise we assume the script already exists in the working directory.

Parameters:

env_spec (Dict[str, Any]) –