From fc8b75fe698389193edcc3a62320ca967b9fb560 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Wed, 22 Jul 2026 14:23:55 -0700 Subject: [PATCH 1/3] remove unused pytest.warns() check from test_gather --- src/openfecli/tests/commands/test_gather.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/openfecli/tests/commands/test_gather.py b/src/openfecli/tests/commands/test_gather.py index 9e81960ab..6722c440c 100644 --- a/src/openfecli/tests/commands/test_gather.py +++ b/src/openfecli/tests/commands/test_gather.py @@ -447,11 +447,10 @@ def test_missing_leg_error(self, results_paths_serial_missing_legs: str): def test_missing_leg_allow_partial_disconnected(self, results_paths_serial_missing_legs: str): runner = CliRunner() - with pytest.warns(): - args = ["--report", "dg", "--allow-partial"] - result = runner.invoke(gather, results_paths_serial_missing_legs + args + ["--tsv"]) - assert result.exit_code == 1 - assert "The results network is disconnected" in str(result.stderr) + args = ["--report", "dg", "--allow-partial"] + result = runner.invoke(gather, results_paths_serial_missing_legs + args + ["--tsv"]) + assert result.exit_code == 1 + assert "The results network is disconnected" in str(result.stderr) def test_allow_partial_msg_not_printed(self, results_paths_serial_missing_legs: str): # we *dont* want the suggestion to use --allow-partial if the user already used it! From 8ba3734283b00ba7ca507e94646bb17a353dafea Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Wed, 22 Jul 2026 11:34:04 -0700 Subject: [PATCH 2/3] add magic_open --- src/openfecli/commands/gather.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/openfecli/commands/gather.py b/src/openfecli/commands/gather.py index 9692b2fbc..7a2315e1e 100644 --- a/src/openfecli/commands/gather.py +++ b/src/openfecli/commands/gather.py @@ -8,6 +8,7 @@ import click import pandas as pd +from gufe.utils import magic_open from openfecli import OFECommandPlugin from openfecli.clicktypes import HyphenAwareChoice @@ -178,7 +179,10 @@ def format_df_with_precision( def is_results_json(fpath: os.PathLike | str) -> bool: """Sanity check that file is a result json before we try to deserialize""" - return "estimate" in open(fpath, "r").read(20) + + with open(fpath, "rb") as raw: + with magic_open(raw) as f: + return "estimate" in f.read(20) def load_json(fpath: os.PathLike | str) -> dict: @@ -201,7 +205,9 @@ def load_json(fpath: os.PathLike | str) -> dict: from gufe.tokenization import JSON_HANDLER - return json.load(open(fpath, "r"), cls=JSON_HANDLER.decoder) + with open(fpath, "rb") as raw: + with magic_open(raw) as f: + return json.load(f, cls=JSON_HANDLER.decoder) def _get_names(result: dict) -> tuple[str, str]: @@ -609,17 +615,13 @@ def _collect_result_jsons(results: List[os.PathLike | str]) -> List[pathlib.Path def collect_jsons(results: List[os.PathLike]): all_jsons = [] for p in results: - if str(p).endswith("json"): + if ".json" in str(p): all_jsons.append(p) elif p.is_dir(): - all_jsons.extend(glob.glob(f"{p}/**/*json", recursive=True)) + all_jsons.extend(glob.glob(f"{p}/**/*.json*", recursive=True)) return all_jsons - def is_results_json(fpath: os.PathLike | str) -> bool: - """Sanity check that file is a result json before we try to deserialize""" - return "estimate" in open(fpath, "r").read(20) - results = sorted(results) # ensures reproducible output order regardless of input order # 1) find all possible jsons @@ -774,7 +776,7 @@ def gather( RESULTS is the path(s) to JSON files or directories of JSON files containing RBFE protocol results as generated by ``openfe quickrun``. All directories will be walked recursively and any valid JSON results files will be gathered. - Files must end in .json to be collected, and invalid files will be ignored. + Files must contain `".json"` to be collected, and invalid files will be ignored. The results reported depends on ``--report`` flag: From 90f07751c0b1b14e1e75d758d5db856b59205be8 Mon Sep 17 00:00:00 2001 From: Alyssa Travitz Date: Wed, 22 Jul 2026 14:49:17 -0700 Subject: [PATCH 3/3] add json.gz files to testing --- src/openfecli/tests/commands/test_gather.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/openfecli/tests/commands/test_gather.py b/src/openfecli/tests/commands/test_gather.py index 6722c440c..1a45bd9c7 100644 --- a/src/openfecli/tests/commands/test_gather.py +++ b/src/openfecli/tests/commands/test_gather.py @@ -515,13 +515,6 @@ def septop_result_dir(tmp_path_factory) -> pathlib.Path: ZENODO_SEPTOP_DATA.fetch("septop_results.zip", processor=pooch.Unzip()) result_dir = pathlib.Path(POOCH_CACHE) / "septop_results.zip.unzip/septop_results/" - for gz_file in result_dir.rglob("*.json.gz"): - json_file = gz_file.with_suffix("") # removes .gz, leaving .json - with gzip.open(gz_file, "rb") as f_in: - with open(json_file, "wb") as f_out: - f_out.write(f_in.read()) - gz_file.unlink() # remove the .gz file - return result_dir