diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 868f618d8..6d17599e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,5 +17,5 @@ repos: - id: pyupgrade name: python-old-syntax-check args: [--py36-plus] - files: lib/ramble/ramble/.*\.py$ + files: (lib/ramble/ramble/|var/ramble/repos/).*\.py$ diff --git a/var/ramble/repos/builtin/applications/minixyce/application.py b/var/ramble/repos/builtin/applications/minixyce/application.py index 2394957f4..d725f4f64 100644 --- a/var/ramble/repos/builtin/applications/minixyce/application.py +++ b/var/ramble/repos/builtin/applications/minixyce/application.py @@ -262,7 +262,7 @@ def _analyze_experiments(self, workspace, app_inst=None): if os.path.isfile(output_file): names = [] - with open(output_file, "r") as f: + with open(output_file) as f: names = f.readline().split() for line in f.readlines()[-1:]: values = line.split() @@ -271,6 +271,6 @@ def _analyze_experiments(self, workspace, app_inst=None): for i, (name, value) in enumerate( zip(names[1:-2], values[1:-2]) ): - f.write("{}: {} = {}\n".format((i + 1), name, value)) + f.write(f"{(i + 1)}: {name} = {value}\n") super()._analyze_experiments(workspace) diff --git a/var/ramble/repos/builtin/applications/namd/application.py b/var/ramble/repos/builtin/applications/namd/application.py index 748dc7ee3..6738c2375 100644 --- a/var/ramble/repos/builtin/applications/namd/application.py +++ b/var/ramble/repos/builtin/applications/namd/application.py @@ -388,7 +388,7 @@ def _analyze_experiments(self, workspace, app_inst=None): dpns = None if os.path.isfile(log_path): - with open(log_path, "r") as f: + with open(log_path) as f: for line in f.readlines(): match = ns_regex.match(line) if match: diff --git a/var/ramble/repos/builtin/applications/osu-micro-benchmarks/application.py b/var/ramble/repos/builtin/applications/osu-micro-benchmarks/application.py index 318022036..cf4572032 100644 --- a/var/ramble/repos/builtin/applications/osu-micro-benchmarks/application.py +++ b/var/ramble/repos/builtin/applications/osu-micro-benchmarks/application.py @@ -252,7 +252,7 @@ def _prepare_analysis(self, workspace, app_inst=None): fom_type = None log_file = self.expander.expand_var_name("log_file") if os.path.isfile(log_file): - with open(log_file, "r") as f: + with open(log_file) as f: for line in f.readlines(): for test_fom_type in self.fom_types: if self.fom_regex_headers[test_fom_type].match(line): diff --git a/var/ramble/repos/builtin/applications/py-nemo/application.py b/var/ramble/repos/builtin/applications/py-nemo/application.py index 77c9260c6..e0c42f143 100644 --- a/var/ramble/repos/builtin/applications/py-nemo/application.py +++ b/var/ramble/repos/builtin/applications/py-nemo/application.py @@ -615,7 +615,7 @@ def _preprocess_log(self, workspace, app_inst): final_regex = re.compile(self.final_epoch_regex) if os.path.exists(log_file): - with open(log_file, "r", encoding="ISO-8859-1") as f: + with open(log_file, encoding="ISO-8859-1") as f: data = f.read() processed_log = self.expander.expand_var( diff --git a/var/ramble/repos/builtin/applications/spack-stack/application.py b/var/ramble/repos/builtin/applications/spack-stack/application.py index ce4a2a2cb..661fe81d4 100644 --- a/var/ramble/repos/builtin/applications/spack-stack/application.py +++ b/var/ramble/repos/builtin/applications/spack-stack/application.py @@ -220,7 +220,7 @@ def evaluate_success(self): if not os.path.isfile(spack_file): return False - with open(spack_file, "r") as f: + with open(spack_file) as f: spack_data = syaml.load_config(f) tty.debug(f"Spack data: {spack_data}") diff --git a/var/ramble/repos/builtin/applications/wrfv3/application.py b/var/ramble/repos/builtin/applications/wrfv3/application.py index 1cc238264..d83ba6f97 100644 --- a/var/ramble/repos/builtin/applications/wrfv3/application.py +++ b/var/ramble/repos/builtin/applications/wrfv3/application.py @@ -183,7 +183,7 @@ def _analyze_experiments(self, workspace, app_inst=None): sum_time = 0.0 count = 0 for out_file in file_list: - with open(out_file, "r") as f: + with open(out_file) as f: for line in f.readlines(): m = timing_regex.match(line) if m: diff --git a/var/ramble/repos/builtin/applications/wrfv4/application.py b/var/ramble/repos/builtin/applications/wrfv4/application.py index bc4e5ef59..1050848dc 100644 --- a/var/ramble/repos/builtin/applications/wrfv4/application.py +++ b/var/ramble/repos/builtin/applications/wrfv4/application.py @@ -195,7 +195,7 @@ def _analyze_experiments(self, workspace, app_inst=None): sum_time = 0.0 count = 0 for out_file in file_list: - with open(out_file, "r") as f: + with open(out_file) as f: for line in f.readlines(): m = timing_regex.match(line) if m: diff --git a/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py b/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py index 8b4fe2b08..a3bcad2a1 100644 --- a/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py +++ b/var/ramble/repos/builtin/modifiers/pyxis-enroot/modifier.py @@ -308,7 +308,7 @@ def artifact_inventory(self, workspace, app_inst=None): ) if os.path.exists(hash_file_path): - with open(hash_file_path, "r") as f: + with open(hash_file_path) as f: container_hash = f.read() else: diff --git a/var/ramble/repos/builtin/package_managers/pip/package_manager.py b/var/ramble/repos/builtin/package_managers/pip/package_manager.py index b6846813b..ff3a460f1 100644 --- a/var/ramble/repos/builtin/package_managers/pip/package_manager.py +++ b/var/ramble/repos/builtin/package_managers/pip/package_manager.py @@ -362,7 +362,7 @@ def generate_requirement_file(self): existing_req_mtime = os.path.getmtime(req_file) existing_lock_mtime = os.path.getmtime(lock_file) if existing_lock_mtime >= existing_req_mtime: - with open(req_file, "r") as f: + with open(req_file) as f: if f.read() == contents: self.installed = True logger.debug("requirement file already up-to-date") @@ -428,7 +428,7 @@ def define_path_vars(self, app_inst, cache): if not lock_file: raise RunnerError(f"Lock file {lock_file} is missing") pkgs = [] - with open(lock_file, "r") as f: + with open(lock_file) as f: for line in f.readlines(): # pip freeze generates such a comment, which serves as a divider # for packages that are added as deps of the ones defined directly. diff --git a/var/ramble/repos/builtin/package_managers/spack-lightweight/package_manager.py b/var/ramble/repos/builtin/package_managers/spack-lightweight/package_manager.py index 2bba22b20..1890bd133 100644 --- a/var/ramble/repos/builtin/package_managers/spack-lightweight/package_manager.py +++ b/var/ramble/repos/builtin/package_managers/spack-lightweight/package_manager.py @@ -61,7 +61,7 @@ def _software_install_requested_compilers(self, workspace, app_inst=None): cache_tupl = ("spack-compilers", env_path) if workspace.check_cache(cache_tupl): - logger.debug("{} already in cache.".format(cache_tupl)) + logger.debug(f"{cache_tupl} already in cache.") return else: workspace.add_to_cache(cache_tupl) @@ -114,7 +114,7 @@ def _software_create_env(self, workspace, app_inst=None): cache_tupl = ("spack-env", env_path) if workspace.check_cache(cache_tupl): - logger.debug("{} already in cache.".format(cache_tupl)) + logger.debug(f"{cache_tupl} already in cache.") return else: workspace.add_to_cache(cache_tupl) @@ -222,7 +222,7 @@ def _software_configure(self, workspace, app_inst=None): cache_tupl = ("concretize-env", env_path) if workspace.check_cache(cache_tupl): - logger.debug("{} already in cache.".format(cache_tupl)) + logger.debug(f"{cache_tupl} already in cache.") return else: workspace.add_to_cache(cache_tupl) @@ -273,7 +273,7 @@ def _mirror_software(self, workspace, app_inst=None): cache_tupl = ("spack-mirror", env_path) if workspace.check_cache(cache_tupl): - logger.debug("{} already in cache.".format(cache_tupl)) + logger.debug(f"{cache_tupl} already in cache.") return else: workspace.add_to_cache(cache_tupl) @@ -334,7 +334,7 @@ def _push_to_spack_cache(self, workspace, app_inst=None): env_path = self.app_inst.expander.env_path cache_tupl = ("push-to-cache", env_path) if workspace.check_cache(cache_tupl): - logger.debug("{} already pushed, skipping".format(cache_tupl)) + logger.debug(f"{cache_tupl} already pushed, skipping") return else: workspace.add_to_cache(cache_tupl) @@ -1039,7 +1039,7 @@ def generate_env_file(self): env_data = syaml.load_config( syaml.dump_config(env_file, default_flow_style=False) ) - with open(spack_env_file, "r") as f: + with open(spack_env_file) as f: existing_data = syaml.load_config(f) gen_env_hash = ramble.util.hashing.hash_json(env_data) existing_env_hash = ramble.util.hashing.hash_json( diff --git a/var/ramble/repos/builtin/package_managers/spack/package_manager.py b/var/ramble/repos/builtin/package_managers/spack/package_manager.py index 63f83c3fb..f3960a913 100644 --- a/var/ramble/repos/builtin/package_managers/spack/package_manager.py +++ b/var/ramble/repos/builtin/package_managers/spack/package_manager.py @@ -42,7 +42,7 @@ def _software_install(self, workspace, app_inst=None): cache_tupl = ("spack-install", env_path) if workspace.check_cache(cache_tupl): - logger.debug("{} already in cache.".format(cache_tupl)) + logger.debug(f"{cache_tupl} already in cache.") return else: workspace.add_to_cache(cache_tupl)