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

Allow description for required_variable directive #768

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion lib/ramble/ramble/language/modifier_language.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _env_var_modification(mod):


@modifier_directive("required_vars")
def required_variable(var: str, results_level="variable", modes=None):
def required_variable(var: str, results_level="variable", modes=None, description=None):
"""Mark a variable as being required by this modifier

Args:
Expand All @@ -265,6 +265,7 @@ def required_variable(var: str, results_level="variable", modes=None):
a key within JSON or YAML formatted results.
modes (list[str] | None): modes that the required check should be applied. The
default None means apply to all modes.
description (str | None): Description of the required variable.
"""

def _mark_required_var(mod):
Expand All @@ -273,6 +274,7 @@ def _mark_required_var(mod):
"level": ramble.keywords.output_level.variable,
# Extra prop that's only used for filtering
"modes": set(modes) if modes is not None else None,
"description": description,
}

return _mark_required_var
Expand Down
16 changes: 10 additions & 6 deletions var/ramble/repos/builtin/modifiers/apptainer/modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ class Apptainer(BasicModifier):
mode("standard", description="Standard execution mode for apptainer")
default_mode("standard")

# The container_name variable controls the name of the resulting container file.
# It will be of the format {container_name}.{container_extension}
required_variable("container_name")
required_variable(
"container_name",
description="The variable controls the name of the resulting container file. "
"It will be of the format {container_name}.{container_extension}.",
)

# The container_uri variable controls the URI the container is pulled from.
# This should be of the format that would be input into `apptainer pull <uri>`.
required_variable("container_uri")
required_variable(
"container_uri",
description="The variable controls the URI the container is pulled from. "
"This should be of the format that would be input into `apptainer pull <uri>`.",
)

modifier_variable(
"container_mounts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ class ConditionalPsm3(BasicModifier):

executable_modifier("apply_psm3")

required_variable("psm3_mpi")
required_variable(
"psm3_mpi",
description="The name of the package used for MPI "
"within an experiment's software environment",
)

modifier_variable(
"apply_psm3_exec_regex",
Expand Down