hpcflow.sdk.submission.shells.base.Shell#

class hpcflow.sdk.submission.shells.base.Shell(executable=None, os_args=None)#

Bases: ABC

Class to represent a shell and templates for jobscript composition.

This class represents a combination of a shell and an OS. For example, running bash on a POSIX OS, and provides snippets that are used to compose a jobscript for that combination.

Parameters:
  • executable (str) – Which executable implements the shell.

  • os_args (dict[str, str] | None) – Arguments to pass to the shell.

Methods

format_loop_check

Format a loop check.

format_save_parameter

Format instructions to save a parameter.

format_stream_assignment

Format a stream assignment.

get_direct_submit_command

Get the command for submitting a non-scheduled jobscript.

get_version_info

Get shell and operating system information.

get_wait_command

Get the command to wait for a workflow.

prepare_JS_path

Prepare the jobscript path for use.

prepare_element_run_dirs

Prepare the element run directory names for use.

process_JS_header_args

Process the application invocation key in the jobscript header arguments.

process_app_invoc_executable

Perform any post-processing of an application invocation command name.

wrap_in_subshell

Format commands to run within a child scope.

Attributes

os_args

Arguments to pass to the shell.

executable

The executable to use plus any mandatory arguments.

shebang_executable

The executable to use in a shebang line.

JS_EXT

File extension for jobscripts.

DEFAULT_EXE

Default for executable name.

JS_ENV_SETUP_INDENT

Indent for environment setup.

JS_SHEBANG

Template for the jobscript shebang line.

JS_HEADER

Template for the common part of the jobscript header.

JS_SCHEDULER_HEADER

Template for the jobscript header when scheduled.

JS_DIRECT_HEADER

Template for the jobscript header when directly executed.

JS_MAIN

Template for the jobscript body.

JS_ELEMENT_ARRAY

Template for the array handling code in a jobscript.

JS_ELEMENT_LOOP

Template for the element processing loop in a jobscript.

JS_INDENT

Basic indent.

DEFAULT_EXE: ClassVar[str]#

Default for executable name.

JS_DIRECT_HEADER: ClassVar[str]#

Template for the jobscript header when directly executed.

JS_ELEMENT_ARRAY: ClassVar[str]#

Template for the array handling code in a jobscript.

JS_ELEMENT_LOOP: ClassVar[str]#

Template for the element processing loop in a jobscript.

JS_ENV_SETUP_INDENT: ClassVar[str]#

Indent for environment setup.

JS_EXT: ClassVar[str]#

File extension for jobscripts.

JS_HEADER: ClassVar[str]#

Template for the common part of the jobscript header.

JS_INDENT: ClassVar[str]#

Basic indent.

JS_MAIN: ClassVar[str]#

Template for the jobscript body.

JS_SCHEDULER_HEADER: ClassVar[str]#

Template for the jobscript header when scheduled.

JS_SHEBANG: ClassVar[str]#

Template for the jobscript shebang line.

property executable: list[str]#

The executable to use plus any mandatory arguments.

abstract format_loop_check(workflow_app_alias, loop_name, run_ID)#

Format a loop check.

Parameters:
  • workflow_app_alias (str) –

  • loop_name (str) –

  • run_ID (int) –

Return type:

str

abstract format_save_parameter(workflow_app_alias, param_name, shell_var_name, EAR_ID, cmd_idx, stderr)#

Format instructions to save a parameter.

Parameters:
  • workflow_app_alias (str) –

  • param_name (str) –

  • shell_var_name (str) –

  • EAR_ID (int) –

  • cmd_idx (int) –

  • stderr (bool) –

abstract format_stream_assignment(shell_var_name, command)#

Format a stream assignment.

Parameters:
  • shell_var_name (str) –

  • command (str) –

Return type:

str

get_direct_submit_command(js_path)#

Get the command for submitting a non-scheduled jobscript.

Parameters:

js_path (str) –

Return type:

list[str]

abstract get_version_info(exclude_os=False)#

Get shell and operating system information.

Parameters:

exclude_os (bool) –

Return type:

VersionInfo

get_wait_command(workflow_app_alias, sub_idx, deps)#

Get the command to wait for a workflow.

Parameters:
  • workflow_app_alias (str) –

  • sub_idx (int) –

  • deps (Mapping[int, Any]) –

os_args#

Arguments to pass to the shell.

prepare_JS_path(js_path)#

Prepare the jobscript path for use.

Parameters:

js_path (Path) –

Return type:

str

prepare_element_run_dirs(run_dirs)#

Prepare the element run directory names for use.

Parameters:

run_dirs (list[list[Path]]) –

Return type:

list[list[str]]

process_JS_header_args(header_args)#

Process the application invocation key in the jobscript header arguments.

Parameters:

header_args (JobscriptHeaderArgs) –

Return type:

JobscriptHeaderArgs

static process_app_invoc_executable(app_invoc_exe)#

Perform any post-processing of an application invocation command name.

Parameters:

app_invoc_exe (str) –

Return type:

str

property shebang_executable: list[str]#

The executable to use in a shebang line.

abstract wrap_in_subshell(commands, abortable)#

Format commands to run within a child scope.

This assumes commands ends in a newline.

Parameters:
  • commands (str) –

  • abortable (bool) –

Return type:

str