From 147c8bdbdd29d773a63cb31862b252f31a22b9c6 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Wed, 1 Jul 2026 13:25:24 +0800 Subject: [PATCH] fix(examples): use config-relative data paths in zinc_protein zinc_se_a_mask.json referenced its training/validation data with repo-root-relative paths (examples/zinc_protein/...), so the example only trained when launched from the repository root; from examples/zinc_protein the paths resolved to examples/zinc_protein/examples/zinc_protein/... and did not exist. Every other example uses paths relative to its own directory. Use local train_data_dp_mask/ and val_data_dp_mask/ paths, and extend test_examples.py to assert that each example's data systems resolve relative to the example directory (previously only argument-checking was verified, so unresolvable data paths passed). Fix #5694 --- examples/zinc_protein/zinc_se_a_mask.json | 4 ++-- source/tests/common/test_examples.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/zinc_protein/zinc_se_a_mask.json b/examples/zinc_protein/zinc_se_a_mask.json index 8d3c747e08..ae50a8cdc0 100644 --- a/examples/zinc_protein/zinc_se_a_mask.json +++ b/examples/zinc_protein/zinc_se_a_mask.json @@ -69,14 +69,14 @@ "training": { "training_data": { "systems": [ - "examples/zinc_protein/train_data_dp_mask/" + "train_data_dp_mask/" ], "batch_size": 2, "_comment7": "that's all" }, "validation_data": { "systems": [ - "examples/zinc_protein/val_data_dp_mask/" + "val_data_dp_mask/" ], "batch_size": 2, "_comment8": "that's all" diff --git a/source/tests/common/test_examples.py b/source/tests/common/test_examples.py index 7c96a7b1ca..e47e6e2837 100644 --- a/source/tests/common/test_examples.py +++ b/source/tests/common/test_examples.py @@ -94,3 +94,26 @@ def test_arguments(self) -> None: if multi_task: jdata["model"], _ = preprocess_shared_params(jdata["model"]) normalize(jdata, multi_task=multi_task) + + def test_data_paths_exist(self) -> None: + """Each example's data ``systems`` must resolve relative to the example's + own directory, so the example is runnable from that directory. + """ + for fn in input_files: + training = j_loader(str(fn)).get("training", {}) + for key in ("training_data", "validation_data"): + data = training.get(key) + if not isinstance(data, dict): + continue + systems = data.get("systems") + if systems is None: + continue + if isinstance(systems, str): + systems = [systems] + for system in systems: + with self.subTest(fn=str(fn), key=key, system=system): + self.assertTrue( + (fn.parent / system).exists(), + f"{system!r} in {fn} does not resolve relative to " + f"the example directory {fn.parent}", + )