From e7b797a0c452fd430b380e6235f51e08a5e0d20f Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 2 Oct 2023 17:22:43 -0600 Subject: [PATCH 1/6] Make specs for containers configurable, clean up arguments for spack stack create [env|ctr] --- .../stack/cmd/stack_cmds/create.py | 83 +++++++++++++------ .../spack-stack/stack/container_env.py | 59 +++++++------ .../spack-stack/stack/stack_paths.py | 1 + 3 files changed, 90 insertions(+), 53 deletions(-) diff --git a/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py b/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py index ef93d78b45218e..d038839958245f 100644 --- a/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py +++ b/lib/jcsda-emc/spack-stack/stack/cmd/stack_cmds/create.py @@ -51,44 +51,86 @@ def container_config_help(): help_string = "Pre-configured container." + os.linesep help_string += "Available options are: " + os.linesep for config in container_configs: + if config == "README.md": + continue help_string += "\t" + config.rstrip(".yaml") + os.linesep return help_string +def container_specs_help(): + _, _, specs_lists = next(os.walk(stack_path("configs", "containers", "specs"))) + help_string = "List of specs to build in container." + os.linesep + help_string += "Available options are: " + os.linesep + for specs_list in specs_lists: + help_string += "\t" + specs_list.rstrip(".yaml") + os.linesep + return help_string + + def setup_common_parser_args(subparser): """Shared CLI args for container and environment subcommands""" + subparser.add_argument( - "--template", - type=str, + "--overwrite", + action="store_true", required=False, - dest="template", - default="empty", - help=template_help(), + default=False, + help="Overwrite existing environment if it exists." " Warning this is dangerous.", + ) + + +def setup_ctr_parser(subparser): + """create container-specific parsing options""" + + subparser.add_argument("--container", + required=True, + help=container_config_help() + ) + + subparser.add_argument("--specs", + required=True, + help=container_specs_help() ) subparser.add_argument( - "--name", + "--dir", type=str, required=False, - default=None, - help='Environment name, defaults to "{}".'.format(default_env_name), + default=default_env_path, + help="Environment will be placed in /container/." + " Default is {}/container/.".format(default_env_path) ) + setup_common_parser_args(subparser) + + +def setup_env_parser(subparser): + """create environment-specific parsing options""" + setup_common_parser_args(subparser) + subparser.add_argument( "--dir", type=str, required=False, default=default_env_path, - help="Environment will be placed in //." - " Default is {}//.".format(default_env_path), + help="Environment will be placed in //." + " Default is {}//.".format(default_env_path), ) subparser.add_argument( - "--overwrite", - action="store_true", + "--name", + type=str, required=False, - default=False, - help="Overwrite existing environment if it exists." " Warning this is dangerous.", + default=None, + help='Environment name, defaults to