hpcflow.sdk.submission.shells.bash.WSLBash#

class hpcflow.sdk.submission.shells.bash.WSLBash(WSL_executable=None, WSL_distribution=None, WSL_user=None, *args, **kwargs)#

Bases: Bash

Methods

format_save_parameter

format_stream_assignment

get_direct_submit_command

Get the command for submitting a non-scheduled jobscript.

get_version_info

Get WSL and bash version information.

get_wait_command

prepare_JS_path

prepare_element_run_dirs

process_JS_header_args

wrap_in_subshell

Format commands to run within a subshell.

Attributes

DEFAULT_EXE

DEFAULT_WSL_EXE

JS_DIRECT_HEADER

JS_ELEMENT_ARRAY

JS_ELEMENT_LOOP

JS_ENV_SETUP_INDENT

JS_EXT

JS_HEADER

JS_INDENT

JS_MAIN

JS_SCHEDULER_HEADER

JS_SHEBANG

executable

linux_release_file

shebang_executable

Parameters:
  • WSL_executable (str | None) –

  • WSL_distribution (str | None) –

  • WSL_user (str | None) –

DEFAULT_EXE = '/bin/bash'#
DEFAULT_WSL_EXE = 'wsl'#
JS_DIRECT_HEADER = '{shebang}\n\n{header}\n{wait_command}\n'#
JS_ELEMENT_ARRAY = 'JS_elem_idx=$(({scheduler_array_item_var} - 1))\n{main}\ncd $WK_PATH\n'#
JS_ELEMENT_LOOP = 'for ((JS_elem_idx=0;JS_elem_idx<{num_elements};JS_elem_idx++))\ndo\n{main}\ndone\ncd $WK_PATH\n'#
JS_ENV_SETUP_INDENT = '    '#
JS_EXT = '.sh'#
JS_HEADER = '{workflow_app_alias} () {{\n(\n{env_setup}{app_invoc}\\\n        --with-config log_file_path "$(wslpath -m `pwd`)/{app_package_name}.log"\\\n        --config-dir "{config_dir}"\\\n        --config-invocation-key "{config_invoc_key}"\\\n        "$@"\n)\n}}\n\nWK_PATH=`pwd`\nWK_PATH_ARG=`wslpath -m $WK_PATH`\nSUB_IDX={sub_idx}\nJS_IDX={js_idx}\nEAR_ID_FILE="$WK_PATH/artifacts/submissions/${{SUB_IDX}}/{EAR_file_name}"\nELEM_RUN_DIR_FILE="$WK_PATH/artifacts/submissions/${{SUB_IDX}}/{element_run_dirs_file_path}"\n'#
JS_INDENT = '  '#
JS_MAIN = 'elem_EAR_IDs=`sed "$((${{JS_elem_idx}} + 1))q;d" $EAR_ID_FILE`\nelem_run_dirs=`sed "$((${{JS_elem_idx}} + 1))q;d" $ELEM_RUN_DIR_FILE`\n\nfor ((JS_act_idx=0;JS_act_idx<{num_actions};JS_act_idx++))\ndo\n\n  EAR_ID="$(cut -d\'{EAR_files_delimiter}\' -f $(($JS_act_idx + 1)) <<< $elem_EAR_IDs)"\n  if [ "$EAR_ID" = "-1" ]; then\n      continue\n  fi\n\n  run_dir="$(cut -d\'{EAR_files_delimiter}\' -f $(($JS_act_idx + 1)) <<< $elem_run_dirs)"\n  cd $WK_PATH/$run_dir\n  app_stream_file="`pwd`/{app_package_name}_std.txt"\n\n  skip=`{workflow_app_alias} internal workflow $WK_PATH_ARG get-ear-skipped $EAR_ID 2>> $app_stream_file`\n  exc_sk=$?\n\n  if [ $exc_sk -eq 0 ]; then\n\n      if [ "$skip" = "1" ]; then\n          continue\n      fi\n\n      {workflow_app_alias} internal workflow $WK_PATH_ARG write-commands $SUB_IDX $JS_IDX $JS_act_idx $EAR_ID >> $app_stream_file 2>&1\n      exc_wc=$?\n\n      {workflow_app_alias} internal workflow $WK_PATH_ARG set-ear-start $EAR_ID >> $app_stream_file 2>&1\n      exc_se=$?\n\n      if [ $exc_wc -eq 0 ] && [ $exc_se -eq 0 ]; then\n          . {commands_file_name}\n          exit_code=$?\n      else\n          exit_code=$([ $exc_wc -ne 0 ] && echo "$exc_wc" || echo "$exc_se")\n      fi\n\n  else\n      exit_code=$exc_sk\n  fi\n\n  {workflow_app_alias} internal workflow $WK_PATH_ARG set-ear-end $JS_IDX $JS_act_idx $EAR_ID $exit_code >> $app_stream_file 2>&1\n\ndone\n'#
JS_SCHEDULER_HEADER = '{shebang}\n\n{scheduler_options}\n{header}\n'#
JS_SHEBANG = '#!{shebang_executable} {shebang_args}'#
property executable: List[str]#
format_save_parameter(workflow_app_alias, param_name, shell_var_name, EAR_ID)#
format_stream_assignment(shell_var_name, command)#
get_direct_submit_command(js_path)#

Get the command for submitting a non-scheduled jobscript.

Return type:

List[str]

get_version_info(exclude_os=False)#

Get WSL and bash version information.

Parameters:

exclude_os (bool | None) – If True, exclude operating system information.

Return type:

Dict

get_wait_command(workflow_app_alias, sub_idx, deps)#
Parameters:
  • workflow_app_alias (str) –

  • sub_idx (int) –

  • deps (Dict) –

property linux_release_file#
prepare_JS_path(js_path)#
Parameters:

js_path (Path) –

Return type:

str

prepare_element_run_dirs(run_dirs)#
Parameters:

run_dirs (List[List[Path]]) –

Return type:

List[List[str]]

process_JS_header_args(header_args)#
property shebang_executable: List[str]#
wrap_in_subshell(commands, abortable)#

Format commands to run within a subshell.

This assumes commands ends in a newline.

Parameters:
  • commands (str) –

  • abortable (bool) –

Return type:

str