From ca3dfcd26d6b030e8fbec76574cf056bb91ac62a Mon Sep 17 00:00:00 2001 From: Andreas Simbuerger Date: Wed, 14 Dec 2022 01:11:13 +0100 Subject: [PATCH 1/2] refactor(environments): remove unused type ignore comments --- benchbuild/environments/entrypoints/cli.py | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/benchbuild/environments/entrypoints/cli.py b/benchbuild/environments/entrypoints/cli.py index 9e47d2f33..bf5acd7f5 100644 --- a/benchbuild/environments/entrypoints/cli.py +++ b/benchbuild/environments/entrypoints/cli.py @@ -15,7 +15,7 @@ rich.traceback.install() -class BenchBuildContainer(cli.Application): # type: ignore +class BenchBuildContainer(cli.Application): """ Top-level command for benchbuild containers. """ @@ -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'], @@ -143,17 +142,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'], @@ -222,17 +220,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'], From b1a095c1e5b6ceb32b7eb3a7eda61918eeb3f757 Mon Sep 17 00:00:00 2001 From: Andreas Simbuerger Date: Wed, 14 Dec 2022 01:19:43 +0100 Subject: [PATCH 2/2] feat(environments): do not overwrite config, if cli option is default CLI takes precedence over Config File, iff changed from default value. --- benchbuild/environments/entrypoints/cli.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/benchbuild/environments/entrypoints/cli.py b/benchbuild/environments/entrypoints/cli.py index bf5acd7f5..764f98dcf 100644 --- a/benchbuild/environments/entrypoints/cli.py +++ b/benchbuild/environments/entrypoints/cli.py @@ -75,9 +75,14 @@ def set_group(self, groups: tp.List[str]) -> None: 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 @@ -168,7 +173,8 @@ def set_group(self, groups: tp.List[str]) -> None: 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