hpcflow.sdk.submission.shells.bash.Bash#
- class hpcflow.sdk.submission.shells.bash.Bash(executable=None, os_args=None)#
Bases:
Shell
Class to represent using bash on a POSIX OS to generate and submit a jobscript.
Methods
Format construction of a shell array.
Format retrieval of a shell array item at a specified index.
Format the commands file.
Format retrieval of a shell environment variable.
Produce code to save a parameter's value into the workflow persistent store.
Format sourcing (i.e.
Produce code to assign the output of the command to a shell variable.
Get the command for launching the commands file for a given run.
Get the command for submitting a non-scheduled jobscript.
Get bash version information.
Get the command to wait for a workflow.
Prepare the jobscript path for use.
Prepare the element run directory names for use.
Process the application invocation key in the jobscript header arguments.
Perform any post-processing of an application invocation command name.
Attributes
Arguments to pass to the shell.
Default for executable name.
Template for the action-run processing loop in a jobscript.
Template for the single-action-run execution in a jobscript.
Template for a jobscript-block header.
Template for the jobscript block loop in a jobscript.
Template for the jobscript header when directly executed.
Template for the array handling code in a jobscript.
Template for the element processing loop in a jobscript.
Template for single-element execution.
Indent for environment setup.
File extension for jobscripts.
Template for the jobscript footer.
Template for the jobscript functions file.
Template for the common part of the jobscript header.
Basic indent.
Template for setting up environment variables and running one or more action-runs.
Template for setting up run environment variables and executing the run.
Template for the run execution command.
Template for the execution command for multiple combined runs.
Template for disabling writing of the app log.
Template for enabling writing of the app log.
Template for the jobscript header when scheduled.
Template for the jobscript shebang line.
The executable to use plus any mandatory arguments.
The name of the file describing the Linux version.
The executable to use in a shebang line.
- JS_ACT_MULTI: ClassVar[str] = 'for ((block_act_idx=0;block_act_idx<{num_actions};block_act_idx++))\ndo \n{run_block}\ndone \n'#
Template for the action-run processing loop in a jobscript.
- JS_ACT_SINGLE: ClassVar[str] = 'block_act_idx=0 \n{run_block}\n'#
Template for the single-action-run execution in a jobscript.
- JS_BLOCK_HEADER: ClassVar[str] = 'block_idx=0\nexport {app_caps}_BLOCK_IDX=0\n'#
Template for a jobscript-block header.
- JS_BLOCK_LOOP: ClassVar[str] = 'num_elements={num_elements}\nnum_actions={num_actions}\nblock_start_elem_idx=0\nfor ((block_idx=0;block_idx<{num_blocks};block_idx++))\ndo\n export {app_caps}_BLOCK_IDX=$block_idx\n{element_loop}\n block_start_elem_idx=$(($block_start_elem_idx + ${{num_elements[$block_idx]}}))\ndone\n'#
Template for the jobscript block loop in a jobscript.
- JS_DIRECT_HEADER: ClassVar[str] = '{shebang}\n{header}\n{wait_command}\n'#
Template for the jobscript header when directly executed.
- JS_ELEMENT_MULTI_ARRAY: ClassVar[str] = 'JS_elem_idx=$(({scheduler_array_item_var} - 1))\n{main}\n'#
Template for the array handling code in a jobscript.
- JS_ELEMENT_MULTI_LOOP: ClassVar[str] = 'for ((JS_elem_idx={block_start_elem_idx};JS_elem_idx<$(({block_start_elem_idx} + {num_elements}));JS_elem_idx++))\ndo\n{main}\ndone\n'#
Template for the element processing loop in a jobscript.
- JS_ELEMENT_SINGLE: ClassVar[str] = 'JS_elem_idx={block_start_elem_idx}\n{main}\n'#
Template for single-element execution.
- JS_FUNCS: ClassVar[str] = '{workflow_app_alias} () {{\n(\n{env_setup}{app_invoc}\\\n --with-config log_file_path "${app_caps}_LOG_PATH"\\\n --config-dir "{config_dir}"\\\n --config-key "{config_invoc_key}"\\\n "$@"\n)\n}}\n'#
Template for the jobscript functions file.
- JS_HEADER: ClassVar[str] = 'WK_PATH=`pwd`\nWK_PATH_ARG="$WK_PATH"\nSUB_IDX={sub_idx}\nJS_IDX={js_idx}\nAPP_CAPS={app_caps}\n\nSUB_DIR="$WK_PATH/artifacts/submissions/${{SUB_IDX}}"\nJS_FUNCS_PATH="$SUB_DIR/{jobscript_functions_dir}/{jobscript_functions_name}"\n. "$JS_FUNCS_PATH" \n\nEAR_ID_FILE="$WK_PATH/artifacts/submissions/${{SUB_IDX}}/{run_IDs_file_dir}/{run_IDs_file_name}"\nSUB_TMP_DIR="$SUB_DIR/{tmp_dir_name}"\nSUB_LOG_DIR="$SUB_DIR/{log_dir_name}"\nSUB_STD_DIR="$SUB_DIR/{app_std_dir_name}"\nSUB_SCRIPTS_DIR="$SUB_DIR/{scripts_dir_name}"\n\nexport {app_caps}_WK_PATH=$WK_PATH\nexport {app_caps}_WK_PATH_ARG=$WK_PATH_ARG\nexport {app_caps}_SUB_IDX={sub_idx}\nexport {app_caps}_SUB_SCRIPTS_DIR=$SUB_SCRIPTS_DIR\nexport {app_caps}_SUB_TMP_DIR=$SUB_TMP_DIR\nexport {app_caps}_SUB_LOG_DIR=$SUB_LOG_DIR\nexport {app_caps}_SUB_STD_DIR=$SUB_STD_DIR\nexport {app_caps}_LOG_PATH="$SUB_LOG_DIR/js_${{JS_IDX}}.log"\nexport {app_caps}_JS_FUNCS_PATH=$JS_FUNCS_PATH\nexport {app_caps}_JS_IDX={js_idx}\nexport {app_caps}_RUN_ID_FILE=$EAR_ID_FILE\n'#
Template for the common part of the jobscript header.
- JS_MAIN: ClassVar[str] = 'block_elem_idx=$(( $JS_elem_idx - {block_start_elem_idx} ))\nelem_EAR_IDs=`sed "$((${{JS_elem_idx}} + 1))q;d" "$EAR_ID_FILE"`\nexport {app_caps}_JS_ELEM_IDX=$JS_elem_idx\nexport {app_caps}_BLOCK_ELEM_IDX=$block_elem_idx\n\n{action}\n'#
Template for setting up environment variables and running one or more action-runs.
- JS_RUN: ClassVar[str] = 'EAR_ID="$(cut -d\'{EAR_files_delimiter}\' -f $(($block_act_idx + 1)) <<< $elem_EAR_IDs)"\nif [ "$EAR_ID" = "-1" ]; then\n continue\nfi\n\nexport {app_caps}_RUN_ID=$EAR_ID\nexport {app_caps}_RUN_LOG_PATH={run_log_enable_disable}\nexport {app_caps}_LOG_PATH="${app_caps}_RUN_LOG_PATH"\nexport {app_caps}_RUN_STD_PATH="$SUB_STD_DIR/${app_caps}_RUN_ID.txt"\nexport {app_caps}_BLOCK_ACT_IDX=$block_act_idx\n\ncd "$SUB_TMP_DIR"\n\n{run_cmd}\n'#
Template for setting up run environment variables and executing the run.
- JS_RUN_CMD: ClassVar[str] = '{workflow_app_alias} internal workflow "$WK_PATH_ARG" execute-run $SUB_IDX $JS_IDX $block_idx $block_act_idx $EAR_ID\n'#
Template for the run execution command.
- JS_RUN_CMD_COMBINED: ClassVar[str] = '{workflow_app_alias} internal workflow "$WK_PATH_ARG" execute-combined-runs $SUB_IDX $JS_IDX\n'#
Template for the execution command for multiple combined runs.
- JS_RUN_LOG_PATH_ENABLE: ClassVar[str] = '"$SUB_LOG_DIR/{run_log_file_name}"'#
Template for enabling writing of the app log.
- JS_SCHEDULER_HEADER: ClassVar[str] = '{shebang}\n\n{scheduler_options}\n{header}\n'#
Template for the jobscript header when scheduled.
- JS_SHEBANG: ClassVar[str] = '#!{shebang_executable} {shebang_args}'#
Template for the jobscript shebang line.
- format_array_get_item(arr_name, index)#
Format retrieval of a shell array item at a specified index.
- format_commands_file(app_name, commands)#
Format the commands file.
- format_env_var_get(var)#
Format retrieval of a shell environment variable.
- format_save_parameter(workflow_app_alias, param_name, shell_var_name, cmd_idx, stderr, app_name)#
Produce code to save a parameter’s value into the workflow persistent store.
- format_source_functions_file(app_name, commands)#
Format sourcing (i.e. invocation) of the jobscript functions file.
- format_stream_assignment(shell_var_name, command)#
Produce code to assign the output of the command to a shell variable.
- get_command_file_launch_command(cmd_file_path)#
Get the command for launching the commands file for a given run.
- get_direct_submit_command(js_path)#
Get the command for submitting a non-scheduled jobscript.
- get_version_info(exclude_os=False)#
Get bash version information.
- Parameters:
exclude_os (bool) – If True, exclude operating system information.
- Return type:
VersionInfo
- get_wait_command(workflow_app_alias, sub_idx, deps)#
Get the command to wait for a workflow.
- 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:
- prepare_element_run_dirs(run_dirs)#
Prepare the element run directory names for use.
- process_JS_header_args(header_args)#
Process the application invocation key in the jobscript header arguments.
- Parameters:
header_args (JobscriptHeaderArgs) –
- Return type:
- static process_app_invoc_executable(app_invoc_exe)#
Perform any post-processing of an application invocation command name.