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

environments: do not override config settings, if not changed from default #527

Merged
merged 2 commits into from
Dec 20, 2022
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
45 changes: 24 additions & 21 deletions benchbuild/environments/entrypoints/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
rich.traceback.install()


class BenchBuildContainer(cli.Application): # type: ignore
class BenchBuildContainer(cli.Application):
"""
Top-level command for benchbuild containers.
"""
Expand All @@ -30,24 +30,23 @@ def main(self, *args: str) -> int:


@BenchBuildContainer.subcommand("run")
class BenchBuildContainerRun(cli.Application): # type: ignore
class BenchBuildContainerRun(cli.Application):
experiment_args: tp.List[str] = []
group_args: tp.List[str] = []

@cli.switch(["-E", "--experiment"],
str,
list=True,
help="Specify experiments to run") # type: ignore
def set_experiments(self, names: tp.List[str]) -> None: # type: ignore
help="Specify experiments to run")
def set_experiments(self, names: tp.List[str]) -> None:
self.experiment_args = names

@cli.switch(["-G", "--group"],
str,
list=True,
requires=["--experiment"],
help="Run a group of projects under the given experiments"
) # type: ignore
def set_group(self, groups: tp.List[str]) -> None: # type: ignore
help="Run a group of projects under the given experiments")
def set_group(self, groups: tp.List[str]) -> None:
self.group_args = groups

image_export = cli.Flag(['export'],
Expand Down Expand Up @@ -76,9 +75,14 @@ def set_group(self, groups: tp.List[str]) -> None: # type: ignore
def main(self, *projects: str) -> int:
plugins.discover()

CFG['container']['replace'] = self.replace
CFG['container']['keep'] = self.debug
CFG['container']['interactive'] = self.interactive
if self.replace:
CFG['container']['replace'] = self.replace

if self.debug:
CFG['container']['keep'] = self.debug

if self.interactive:
CFG['container']['interactive'] = self.interactive

cli_experiments = self.experiment_args
cli_groups = self.group_args
Expand Down Expand Up @@ -143,17 +147,16 @@ class BenchBuildContainerBase(cli.Application):
@cli.switch(["-E", "--experiment"],
str,
list=True,
help="Specify experiments to run") # type: ignore
def set_experiments(self, names: tp.List[str]) -> None: # type: ignore
help="Specify experiments to run")
def set_experiments(self, names: tp.List[str]) -> None:
self.experiment_args = names

@cli.switch(["-G", "--group"],
str,
list=True,
requires=["--experiment"],
help="Run a group of projects under the given experiments"
) # type: ignore
def set_group(self, groups: tp.List[str]) -> None: # type: ignore
help="Run a group of projects under the given experiments")
def set_group(self, groups: tp.List[str]) -> None:
self.group_args = groups

image_export = cli.Flag(['export'],
Expand All @@ -170,7 +173,8 @@ def set_group(self, groups: tp.List[str]) -> None: # type: ignore
def main(self, *projects: str) -> int:
plugins.discover()

CFG['container']['keep'] = self.debug
if self.debug:
CFG['container']['keep'] = self.debug

cli_experiments = self.experiment_args
cli_groups = self.group_args
Expand Down Expand Up @@ -222,17 +226,16 @@ class BenchBuildContainerRemoveImages(cli.Application):
@cli.switch(["-E", "--experiment"],
str,
list=True,
help="Specify experiments to run") # type: ignore
def set_experiments(self, names: tp.List[str]) -> None: # type: ignore
help="Specify experiments to run")
def set_experiments(self, names: tp.List[str]) -> None:
self.experiment_args = names

@cli.switch(["-G", "--group"],
str,
list=True,
requires=["--experiment"],
help="Run a group of projects under the given experiments"
) # type: ignore
def set_group(self, groups: tp.List[str]) -> None: # type: ignore
help="Run a group of projects under the given experiments")
def set_group(self, groups: tp.List[str]) -> None:
self.group_args = groups

delete_project_images = cli.Flag(['with-projects'],
Expand Down