hpcflow.sdk.submission.shells.powershell.WindowsPowerShell#
- class hpcflow.sdk.submission.shells.powershell.WindowsPowerShell(*args, **kwargs)#
Bases:
Shell
Class to represent using PowerShell on Windows to generate and submit a jobscript.
Methods
Get the command for submitting a non-scheduled jobscript.
Get powershell version information.
Format commands to run within a child scope.
Attributes
- DEFAULT_EXE = 'powershell.exe'#
- JS_DIRECT_HEADER = '{shebang}\n\n{header}\n{wait_command}\n'#
- JS_ELEMENT_LOOP = 'for ($JS_elem_idx = 0; $JS_elem_idx -lt {num_elements}; $JS_elem_idx += 1) {{\n{main}\n}}\nSet-Location $WK_PATH\n'#
- JS_ENV_SETUP_INDENT = ' '#
- JS_EXT = '.ps1'#
- JS_HEADER = 'function {workflow_app_alias} {{\n & {{\n{env_setup}{app_invoc} `\n --with-config log_file_path "$pwd/{app_package_name}.log" `\n --config-dir "{config_dir}" `\n --config-invocation-key "{config_invoc_key}" `\n $args\n }} @args\n}}\n\nfunction get_nth_line($file, $line) {{\n Get-Content $file | Select-Object -Skip $line -First 1\n}}\n\nfunction JoinMultiPath {{\n $numArgs = $args.Length\n $path = $args[0]\n for ($i = 1; $i -lt $numArgs; $i++) {{\n $path = Join-Path $path $args[$i]\n }}\n return $path\n}}\n\nfunction StartJobHere($block) {{\n $jobInitBlock = [scriptblock]::Create(@"\n Function wkflow_app {{ $function:wkflow_app }}\n Function get_nth_line {{ $function:get_nth_line }}\n Function JoinMultiPath {{ $function:JoinMultiPath }}\n Set-Location \'$pwd\'\n"@)\n Start-Job -InitializationScript $jobInitBlock -Script $block\n}}\n\n$WK_PATH = $(Get-Location)\n$WK_PATH_ARG = $WK_PATH\n$SUB_IDX = {sub_idx}\n$JS_IDX = {js_idx}\n$EAR_ID_FILE = JoinMultiPath $WK_PATH artifacts submissions $SUB_IDX {EAR_file_name}\n$ELEM_RUN_DIR_FILE = JoinMultiPath $WK_PATH artifacts submissions $SUB_IDX {element_run_dirs_file_path}\n'#
- JS_INDENT = ' '#
- JS_MAIN = '$elem_EAR_IDs = get_nth_line $EAR_ID_FILE $JS_elem_idx\n$elem_run_dirs = get_nth_line $ELEM_RUN_DIR_FILE $JS_elem_idx\n\nfor ($JS_act_idx = 0; $JS_act_idx -lt {num_actions}; $JS_act_idx += 1) {{\n\n $EAR_ID = ($elem_EAR_IDs -split "{EAR_files_delimiter}")[$JS_act_idx]\n if ($EAR_ID -eq -1) {{\n continue\n }}\n\n $run_dir = ($elem_run_dirs -split "{EAR_files_delimiter}")[$JS_act_idx]\n $run_dir_abs = "$WK_PATH\\$run_dir"\n Set-Location $run_dir_abs\n $app_stream_file = "$pwd/{app_package_name}_std.txt"\n\n $skip = {workflow_app_alias} internal workflow $WK_PATH get-ear-skipped $EAR_ID 2>> $app_stream_file\n $exc_sk = $LASTEXITCODE\n\n if ($exc_sk -eq 0) {{\n\n if ($skip -eq "1") {{\n continue\n }}\n\n {workflow_app_alias} internal workflow $WK_PATH write-commands $SUB_IDX $JS_IDX $JS_act_idx $EAR_ID 2>&1 >> $app_stream_file\n $exc_wc = $LASTEXITCODE\n\n {workflow_app_alias} internal workflow $WK_PATH set-ear-start $EAR_ID 2>&1 >> $app_stream_file\n $exc_se = $LASTEXITCODE\n\n if (($exc_wc -eq 0) -and ($exc_se -eq 0)) {{\n . (Join-Path $run_dir_abs "{commands_file_name}")\n $exit_code = $LASTEXITCODE\n }}\n else {{\n $exit_code = If ($exc_wc -ne 0) {{$exc_wc}} Else {{$exc_se}}\n }}\n }}\n else {{ \n $exit_code = $exc_sk\n }}\n $global:LASTEXITCODE = $null\n {workflow_app_alias} internal workflow $WK_PATH set-ear-end $EAR_ID $exit_code 2>&1 >> $app_stream_file\n\n}}\n'#
- JS_SHEBANG = ''#
- 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.
- get_version_info(exclude_os=False)#
Get powershell version information.
- get_wait_command(workflow_app_alias, sub_idx, deps)#
- prepare_element_run_dirs(run_dirs)#