Skip to content

Commit 877b114

Browse files
Merge pull request #953 from douglasjacobsen/env-vars-in-exec
Add env-var passthrough option
2 parents d8610ed + 505ca78 commit 877b114

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

etc/ramble/defaults/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ config:
2424
workspace_dirs: $ramble/var/ramble/workspaces
2525
report_dirs: ~/.ramble/reports
2626
include_phase_dependencies: false
27+
resolve_variables_in_subprocesses: false
2728
spack:
2829
install:
2930
flags: --reuse

lib/ramble/ramble/main.py

+10
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,12 @@ def make_argument_parser(**kwargs):
441441
help="when running in a workspace, use its application repository",
442442
)
443443

444+
parser.add_argument(
445+
"--resolve-variables-in-subprocesses",
446+
action="store_true",
447+
help="Allow resolution of environment variables when launching subprocesses",
448+
)
449+
444450
parser.add_argument(
445451
"-k",
446452
"--insecure",
@@ -612,6 +618,10 @@ def setup_main_options(args):
612618
logger.warn("You asked for --insecure. Will NOT check SSL certificates.")
613619
ramble.config.set("config:verify_ssl", False, scope="command_line")
614620

621+
# If the user asked for it allow env-vars to resolve in subprocess calls
622+
if args.resolve_variables_in_subprocesses:
623+
ramble.config.set("config:resolve_variables_in_subprocesses", True, scope="command_line")
624+
615625
# Use the ramble config command to handle parsing the config strings
616626
for config_var in args.config_vars or []:
617627
ramble.config.add(fullpath=config_var, scope="command_line")

lib/ramble/ramble/pipeline.py

+4
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ def __init__(
555555
def _execute(self):
556556
super()._execute()
557557

558+
resolve_env_vars = ramble.config.get("config:resolve_variables_in_subprocesses", False)
559+
558560
if not self.suppress_run_header:
559561
logger.all_msg("Running executors...")
560562

@@ -568,6 +570,8 @@ def _execute(self):
568570

569571
app_inst.add_expand_vars(self.workspace)
570572
exec_str = app_inst.expander.expand_var(self.executor)
573+
if resolve_env_vars:
574+
exec_str = os.path.expandvars(exec_str)
571575
exec_parts = shlex.split(exec_str)
572576
exec_name = exec_parts[0]
573577
exec_args = exec_parts[1:]

lib/ramble/ramble/schema/config.py

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@
116116
},
117117
"additionalProperties": False,
118118
},
119+
"resolve_variables_in_subprocesses": {
120+
"type": "boolean",
121+
"default": False,
122+
"additionalProperties": False,
123+
},
119124
},
120125
"additionalProperties": False,
121126
}

share/ramble/ramble-completion.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ complete -o bashdefault -o default -F _bash_completion_ramble ramble
264264
_ramble() {
265265
if $list_options
266266
then
267-
RAMBLE_COMPREPLY="-h --help -H --all-help --color -c --config -C --config-scope -d --debug --disable-passthrough -N --disable-logger -P --disable-progress-bar --timestamp --pdb -w --workspace -D --workspace-dir -W --no-workspace --use-workspace-repo -k --insecure -l --enable-locks -L --disable-locks -m --mock --mock-applications --mock-modifiers --mock-package-managers --mock-workflow-managers --mock-base-applications --mock-base-modifiers --mock-base-package-managers --mock-base-workflow-managers -p --profile --sorted-profile --lines --profile-restrictions -v --verbose --stacktrace -V --version --print-shell-vars"
267+
RAMBLE_COMPREPLY="-h --help -H --all-help --color -c --config -C --config-scope -d --debug --disable-passthrough -N --disable-logger -P --disable-progress-bar --timestamp --pdb -w --workspace -D --workspace-dir -W --no-workspace --use-workspace-repo --resolve-variables-in-subprocesses -k --insecure -l --enable-locks -L --disable-locks -m --mock --mock-applications --mock-modifiers --mock-package-managers --mock-workflow-managers --mock-base-applications --mock-base-modifiers --mock-base-package-managers --mock-base-workflow-managers -p --profile --sorted-profile --lines --profile-restrictions -v --verbose --stacktrace -V --version --print-shell-vars"
268268
else
269269
RAMBLE_COMPREPLY="attributes clean commands config debug deployment docs edit help info license list mirror on python repo results software-definitions style unit-test workspace"
270270
fi

0 commit comments

Comments
 (0)