Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local mode to gcp-metadata modifier #688

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 47 additions & 15 deletions var/ramble/repos/builtin/modifiers/gcp-metadata/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,42 @@ class GcpMetadata(BasicModifier):
maintainers("rfbgo")

mode("standard", description="Standard execution mode")
mode(
"local", description="Local execution (disables parallel prefix/pdssh)"
)
default_mode("standard")

software_spec("pdsh", pkg_spec="pdsh", package_manager="spack*")

required_variable("hostlist")

modifier_variable(
"metadata_parallel_prefix",
default="pdsh -R ssh -N -w {hostlist} '",
modes=["standard"],
description="Express how parlalelism should be done between nodes",
)
modifier_variable(
"metadata_parallel_prefix",
douglasjacobsen marked this conversation as resolved.
Show resolved Hide resolved
default="",
modes=["local"],
description="Express how parlalelism should be done between nodes",
)

# Need to close any open `'` we leave in the prefix
modifier_variable(
"metadata_parallel_suffix",
default="'",
modes=["standard"],
description="Optional suffix for {metadata_parallel_prefix}",
)
modifier_variable(
"metadata_parallel_suffix",
default="",
modes=["local"],
description="Optional suffix for {metadata_parallel_prefix}",
)

executable_modifier("gcp_metadata_exec")

def gcp_metadata_exec(self, executable_name, executable, app_inst=None):
Expand All @@ -46,15 +76,16 @@ def gcp_metadata_exec(self, executable_name, executable, app_inst=None):
post_cmds = []
pre_cmds = []

pre_cmds.append(
CommandExecutable(
"save-old-loglevel",
template=[
'old_pdsh_args="$PDSH_SSH_ARGS_APPEND"',
'export PDSH_SSH_ARGS_APPEND="-q"',
],
if self._usage_mode != "local":
pre_cmds.append(
CommandExecutable(
"save-old-loglevel",
template=[
'old_pdsh_args="$PDSH_SSH_ARGS_APPEND"',
'export PDSH_SSH_ARGS_APPEND="-q"',
],
)
)
)

payloads = [
# type, end point, per_node
Expand All @@ -74,8 +105,8 @@ def gcp_metadata_exec(self, executable_name, executable, app_inst=None):
prefix = ""
suffix = ""
if per_node:
prefix = "pdsh -R ssh -N -w {hostlist} '"
suffix = "'"
prefix = self.expander.expand_var("{metadata_parallel_prefix}")
suffix = self.expander.expand_var("{metadata_parallel_suffix}")
log_name = end_point.split("/")[-1]
pre_cmds.append(
CommandExecutable(
Expand All @@ -92,12 +123,13 @@ def gcp_metadata_exec(self, executable_name, executable, app_inst=None):
)
)

pre_cmds.append(
CommandExecutable(
"restore-old-loglevel",
template=['export PDSH_SSH_ARGS_APPEND="$old_pdsh_args"'],
if self._usage_mode != "local":
pre_cmds.append(
CommandExecutable(
"restore-old-loglevel",
template=['export PDSH_SSH_ARGS_APPEND="$old_pdsh_args"'],
)
)
)

return pre_cmds, post_cmds

Expand Down