hpcflow.app.Jobscript#
- class hpcflow.app.Jobscript(index, is_array, resources, blocks, at_submit_metadata=None, submit_hostname=None, submit_machine=None, shell_idx=None, version_info=None, resource_hash=None, elements=None)#
Bases:
Jobscript
A group of actions that are submitted together to be executed by the underlying job management system as a single unit.
- Parameters:
task_actions (list[tuple]) – The actions of the tasks.
task insert ID, action_idx, index into task_loop_idx
for eachJS_ACTION_IDX
task_elements (dict[int, list[int]]) – The elements of the tasks. Maps
JS_ELEMENT_IDX
to list ofTASK_ELEMENT_IDX
for eachTASK_INSERT_ID
EAR_ID – Element action run information.
resources (ElementResources) – Resources to use
task_loop_idx (list[dict]) – Description of what loops are in play.
dependencies (dict[int, dict]) – Description of dependencies.
submit_time (datetime) – When the jobscript was submitted, if known.
submit_hostname (str) – Where the jobscript was submitted, if known.
submit_machine (str) – Description of what the jobscript was submitted to, if known.
submit_cmdline (str) – The command line used to do the commit, if known.
scheduler_job_ID (str) – The job ID from the scheduler, if known.
process_ID (int) – The process ID of the subprocess, if known.
version_info (dict[str, ...]) – Version info about the target system.
os_name (str) – The name of the OS.
shell_name (str) – The name of the shell.
scheduler_name (str) – The scheduler used.
running (bool) – Whether the jobscript is currently running.
index (int) –
is_array (bool) –
blocks (list[JobscriptBlock]) –
shell_idx (int | None) –
resource_hash (str | None) –
Methods
Prepare the combined-script file string, if applicable.
Prepare the jobscript file string.
Make an instance of this class from JSON (or YAML) data.
If this jobscript is active on this machine, return the state information from the scheduler.
Get the name of a file containing commands for a particular jobscript action.
File path of combined standard output and error streams.
Retrieve the contents of the standard error stream file.
File path to which the jobscript's standard error is saved.
Retrieve the contents of the standard output stream file.
File path to which the jobscript's standard output is saved.
Print the contents of the standard error stream file.
Print the contents of the standard output stream file.
Submit the jobscript to the scheduler.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Write the jobscript to its file.
Write a text file containing the action script index for each block and action in a combined_scripts script.
Attributes
The name of a file containing EAR IDs.
The path to the file containing EAR IDs for this jobscript.
Return all run IDs of this jobscripts (across all blocks), removing missing run IDs (i.e.
Description of EAR information for this jobscript.
The path to the file containing script indices, in the case this is a
combine_scripts=True
jobscript.The dependency descriptor, accounting for all blocks within this jobscript.
File path of combined standard output and error streams.
File path to which the jobscript's standard error is saved, for direct execution only.
File path to which the jobscript's standard output is saved, for direct execution only.
File for holding the direct execution PID.
The path to the file containing PIDs for directly executed commands for this jobscript.
The last known end time of any EAR in this jobscript.
The index of this jobscript within its parent
Submission
.Whether to generate an array job.
Whether this jobscript has been submitted.
The path to the file containing the supporting shell functions.
The name of the jobscript file.
The path to the file containing the jobscript file.
The name of the OS to use.
The process ID from direct execution, if known.
The common resources that this jobscript requires.
The scheduler that submissions go to from this jobscript.
The job ID from the scheduler, if known.
The reference to the submitted job for the jobscript.
The name of the scheduler to use.
The shell for composing submission scripts.
The first known start time of any EAR in this jobscript.
Directory in which to store jobscript standard out and error stream files.
The parent submission.
The command line used to submit the jobscript, if known.
Where the jobscript was submitted, if known.
Description of what the jobscript was submitted to, if known.
When the jobscript was submitted, if known.
Version information about the execution environment (OS, etc).
The workflow this is all on behalf of.
Alias for the workflow app in job scripts.
- property EAR_ID_file_path: Path#
The path to the file containing EAR IDs for this jobscript.
- property all_EAR_IDs: NDArray#
Return all run IDs of this jobscripts (across all blocks), removing missing run IDs (i.e. -1 values)
- property all_EARs: Sequence[ElementActionRun]#
Description of EAR information for this jobscript.
- property blocks: Sequence[JobscriptBlock]#
- property combined_script_indices_file_path: Path#
The path to the file containing script indices, in the case this is a
combine_scripts=True
jobscript.
- compose_combined_script(action_scripts)#
Prepare the combined-script file string, if applicable.
- compose_jobscript(shell, deps=None, os_name=None, scheduler_name=None, scheduler_args=None)#
Prepare the jobscript file string.
- property dependencies: Mapping[tuple[int, int], dict[str, bool]]#
The dependency descriptor, accounting for all blocks within this jobscript.
- property direct_std_out_err_path: Path#
File path of combined standard output and error streams.
Notes
This path will only exist if resources.combine_jobscript_std is True. Otherwise, see direct_stdout_path and direct_stderr_path for the separate stream paths.
- property direct_stderr_path: Path#
File path to which the jobscript’s standard error is saved, for direct execution only.
Notes
This returned path be the same as that from get_stdout_path if resources.combine_jobscript_std is True.
- property direct_stdout_path: Path#
File path to which the jobscript’s standard output is saved, for direct execution only.
Notes
This returned path be the same as that from get_stderr_path if resources.combine_jobscript_std is True.
- property direct_win_pid_file_path: Path#
The path to the file containing PIDs for directly executed commands for this jobscript. Windows only.
- classmethod from_json_like(json_like, shared_data=None)#
Make an instance of this class from JSON (or YAML) data.
- Parameters:
json_like – The data to deserialise.
shared_data – Shared context data.
- Return type:
The deserialised object.
- get_active_states(as_json=False)#
If this jobscript is active on this machine, return the state information from the scheduler.
- Parameters:
as_json (bool) –
- Return type:
Mapping[int, Mapping[int, JobscriptElementState | str]]
- get_app_std_path()#
- Return type:
Path
- get_commands_file_name(block_act_key, shell=None)#
Get the name of a file containing commands for a particular jobscript action.
- get_std_out_err_path(array_idx=None)#
File path of combined standard output and error streams.
Notes
This path will only exist if resources.combine_jobscript_std is True. Otherwise, see get_stdout_path and get_stderr_path for the separate stream paths.
- Parameters:
array_idx (int | None) –
- Return type:
Path
- get_stderr(array_idx=None)#
Retrieve the contents of the standard error stream file.
Notes
In the case of non-array jobscripts, this will return the whole standard error, even if that includes multiple elements/actions.
- get_stderr_path(array_idx=None)#
File path to which the jobscript’s standard error is saved.
Notes
This returned path be the same as that from get_stdout_path if resources.combine_jobscript_std is True.
- Parameters:
array_idx (int | None) –
- Return type:
Path
- get_stdout(array_idx=None)#
Retrieve the contents of the standard output stream file.
Notes
In the case of non-array jobscripts, this will return the whole standard output, even if that includes multiple elements/actions.
- get_stdout_path(array_idx=None)#
File path to which the jobscript’s standard output is saved.
Notes
This returned path be the same as that from get_stderr_path if resources.combine_jobscript_std is True.
- Parameters:
array_idx (int | None) –
- Return type:
Path
- property index: int#
The index of this jobscript within its parent
Submission
.
- property jobscript_functions_name#
- property jobscript_functions_path: Path#
The path to the file containing the supporting shell functions.
- property jobscript_path: Path#
The path to the file containing the jobscript file.
- print_stderr(array_idx=None)#
Print the contents of the standard error stream file.
Notes
In the case of non-array jobscripts, this will print the whole standard error, even if that includes multiple elements/actions.
- Parameters:
array_idx (int | None) –
- Return type:
None
- print_stdout(array_idx=None)#
Print the contents of the standard output stream file.
Notes
In the case of non-array jobscripts, this will print the whole standard output, even if that includes multiple elements/actions.
- Parameters:
array_idx (int | None) –
- Return type:
None
- property resources: ElementResources#
The common resources that this jobscript requires.
- property scheduler_js_ref: str | None | tuple[int | None, list[str] | None]#
The reference to the submitted job for the jobscript.
- property shell_idx#
- property std_path: Path#
Directory in which to store jobscript standard out and error stream files.
- property submission: Submission#
The parent submission.
- submit(scheduler_refs, print_stdout=False)#
Submit the jobscript to the scheduler.
- property submit_time#
When the jobscript was submitted, if known.
- 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.
- property version_info: VersionInfo | None#
Version information about the execution environment (OS, etc).
- write_jobscript(os_name=None, shell_name=None, deps=None, os_args=None, shell_args=None, scheduler_name=None, scheduler_args=None)#
Write the jobscript to its file.