-
Notifications
You must be signed in to change notification settings - Fork 14
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
Update spack stack extension for containers: make specs configurable, clean up arguments for env/ctr #333
Update spack stack extension for containers: make specs configurable, clean up arguments for env/ctr #333
Changes from 1 commit
e7b797a
6c02740
afd8a10
734e565
bea1111
1f4e7c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The diffs in this file are confusing. It may be better checking out the current code and this PR and verify side by side in meld (which sometimes does a better job with diffs). Most of the common arguments on the left moved down into the env section, and ctr got its own arguments. |
||
_, _, 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 <dir>/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 <dir>/<name>/." | ||
" Default is {}/<name>/.".format(default_env_path), | ||
help="Environment will be placed in <dir>/<env-name>/." | ||
" Default is {}/<env-name>/.".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 <template>.<site>', | ||
) | ||
|
||
subparser.add_argument( | ||
"--template", | ||
type=str, | ||
required=False, | ||
dest="template", | ||
default="empty", | ||
help=template_help(), | ||
) | ||
|
||
subparser.add_argument( | ||
|
@@ -106,17 +148,6 @@ def setup_common_parser_args(subparser): | |
help="Include upstream environment (/path/to/spack-stack-x.y.z/envs/unified-env/install)", | ||
) | ||
|
||
|
||
def setup_ctr_parser(subparser): | ||
"""create container-specific parsing options""" | ||
subparser.add_argument("container", help=container_config_help()) | ||
|
||
setup_common_parser_args(subparser) | ||
|
||
|
||
def setup_env_parser(subparser): | ||
"""create environment-specific parsing options""" | ||
setup_common_parser_args(subparser) | ||
subparser.add_argument( | ||
"--site", type=str, required=False, default=default_site(), help=site_help() | ||
) | ||
|
@@ -145,7 +176,7 @@ def setup_create_parser(subparser): | |
def container_create(args): | ||
"""Create pre-configured container""" | ||
|
||
container = StackContainer(args.container, args.template, args.name, args.dir, args.packages) | ||
container = StackContainer(args.container, args.dir, args.specs) | ||
|
||
env_dir = container.env_dir | ||
if os.path.exists(env_dir): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we could use the logic from
lib/jcsda-emc/spack-stack/tests/test_stack_create.py
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this alternate logic would be better as long as we know that config is always going to be in files with a
.yaml
extension. That way we don't pick up an undesirable file if something besidesREADME.md
shows up.Would there be cases of config files using a
.yml
extension, ie is it worthwhile to add the checkx.endswith(".yml")
to the test in the alternate logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the alternate logic is better. The spack convention is to always use
.yaml
, I don't think we need.yml
. (Also, the logic in the create container code assumes.yaml
, because that's what it appends to the arguments.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done