From d7f04014da93a3f956f67a8d71cd65362e99ffae Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 23 Jul 2026 17:34:09 +0100 Subject: [PATCH 1/3] test: stop test_config littering bad/ in the repo root `test_path_empty` ran `os.makedirs("bad/path")` relative to the CWD and never cleaned up, so every test run left a `bad/` directory behind in whatever directory pytest was invoked from. Move both path-validation tests onto pytest's `tmp_path` and drop the now-unused `BAD_PATH` constant and `remove_path()` helper. Fixes the producer rather than gitignoring the symptom. Co-Authored-By: Claude Opus 4.8 --- test_autonerves/test_config.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/test_autonerves/test_config.py b/test_autonerves/test_config.py index 28a749a..9414e12 100644 --- a/test_autonerves/test_config.py +++ b/test_autonerves/test_config.py @@ -1,5 +1,3 @@ -import os -import shutil from pathlib import Path import pytest @@ -41,28 +39,18 @@ def test_exception(self, label_config): label_config["superscript"].family(MockClass) -BAD_PATH = "bad/path" - - -def remove_path(): - shutil.rmtree( - BAD_PATH, - ignore_errors=True, - ) - - @pytest.fixture(name="config") def make_config(): return conf.Config() -def test_path_does_not_exist(config): - remove_path() +def test_path_does_not_exist(config, tmp_path): with pytest.raises(ConfigException): - config.push(BAD_PATH) + config.push(str(tmp_path / "does_not_exist")) -def test_path_empty(config): - os.makedirs(BAD_PATH, exist_ok=True) +def test_path_empty(config, tmp_path): + empty = tmp_path / "empty" + empty.mkdir() with pytest.raises(ConfigException): - config.push(BAD_PATH) + config.push(str(empty)) From 9bc8d4d2f924ccac54ddc80174ffad9c38a0df93 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 23 Jul 2026 17:34:50 +0100 Subject: [PATCH 2/3] refactor: remove the dead EDEN packaging tooling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Euclid EDEN packaging path has been dormant for years. Its driver, `scripts/edenise.py`, imports `autofit.tools.edenise`, which no longer exists in PyAutoFit — the script raises ImportError on run. It also reads an `eden.ini` that was removed org-wide on 2026-07-13, so the `eden.yaml` left here was never even the file it consumed. Nothing else in the repo, the libraries, or any workspace references either file. Wired into no CI and no build. The PyAutoNerves leg of the eden-tooling removal; `PyAutoFit/eden.yaml` is a follow-up (PyAutoFit is currently claimed by another task). Co-Authored-By: Claude Opus 4.8 --- eden.yaml | 2 -- scripts/edenise.py | 23 ----------------------- 2 files changed, 25 deletions(-) delete mode 100644 eden.yaml delete mode 100755 scripts/edenise.py diff --git a/eden.yaml b/eden.yaml deleted file mode 100644 index 38e1d00..0000000 --- a/eden.yaml +++ /dev/null @@ -1,2 +0,0 @@ -name: autonerves -eden_prefix: VIS_CTI diff --git a/scripts/edenise.py b/scripts/edenise.py deleted file mode 100755 index 19fff62..0000000 --- a/scripts/edenise.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -from configparser import ConfigParser -from sys import argv - -from autofit.tools import edenise - - -def main(root_directory): - try: - config = ConfigParser() - config.read(f"{root_directory}/eden.ini") - - edenise.edenise( - root_directory, config.get("eden", "name"), config.get("eden", "prefix") - ) - except ValueError: - print("Usage: ./edenise.py root_directory") - exit(1) - - -if __name__ == "__main__": - main(argv[1]) From 461650ce82bd502c29bc1e81d7640d1700ef5219 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 23 Jul 2026 17:35:51 +0100 Subject: [PATCH 3/3] refactor: remove the one-shot config-bootstrap tooling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `scripts/` held four drivers used to set up the original configs years ago. They are wired into no CI, referenced from no workspace, and two no longer even import: - `convert_config.py` — the .ini -> YAML migration, long since run - `convert_prior_configs.py` — imports `oyaml`, not a declared dependency - `generate_priors.py` — CLI over `json_prior/generate.py` `json_prior/generate.py` had no consumer beyond that CLI and its own test, and is not exported from `autonerves/__init__.py`, so it goes with them. The live half of the package, `json_prior/config.py`, is untouched — it is imported by `conf.py` and re-exports `default_prior`, `make_config_for_class`, `path_for_class` and `JSONPriorConfig`, all verified still resolving. `priors/subconfig.json` was a stray output artifact of `generate_priors.py`. Both `scripts/` and `priors/` disappear; neither is referenced from `pyproject.toml`, `setup.py` or `MANIFEST.in`. 149 passed (the 2 removed are `test_generate.py`'s own). Co-Authored-By: Claude Opus 4.8 --- autonerves/json_prior/generate.py | 70 --------------------- priors/subconfig.json | 1 - scripts/convert_config.py | 37 ----------- scripts/convert_prior_configs.py | 55 ---------------- scripts/generate_priors.py | 14 ----- test_autonerves/json_prior/test_generate.py | 61 ------------------ 6 files changed, 238 deletions(-) delete mode 100644 autonerves/json_prior/generate.py delete mode 100644 priors/subconfig.json delete mode 100755 scripts/convert_config.py delete mode 100755 scripts/convert_prior_configs.py delete mode 100755 scripts/generate_priors.py delete mode 100644 test_autonerves/json_prior/test_generate.py diff --git a/autonerves/json_prior/generate.py b/autonerves/json_prior/generate.py deleted file mode 100644 index 8ce05c5..0000000 --- a/autonerves/json_prior/generate.py +++ /dev/null @@ -1,70 +0,0 @@ -import inspect -import json -import logging -import os -from importlib import util -from pathlib import Path - -from .config import make_config_for_class - -logger = logging.getLogger(__name__) - - -def for_file(module_path: str) -> dict: - """ - Generate JSON priors for all classes in a file, using default - prior configuration for each constructor argument. - - Parameters - ---------- - module_path - The path to the file. - - Returns - ------- - JSON configuration, where class names are mapped to their prior configs. - """ - spec = util.spec_from_file_location("module.name", module_path) - module = util.module_from_spec(spec) - spec.loader.exec_module(module) - classes = inspect.getmembers(module) - - return { - name: make_config_for_class(obj)[1] - for name, obj in classes - if inspect.isclass(obj) - } - - -def generate(directory: str): - """ - Generate prior configuration for a given directory, recursively. - - A directory "priors" is created if it does not exists. A new JSON file is created - in priors for each python module found that contains at least one class. - - If an output file already exists then prior generation is skipped. - - Parameters - ---------- - directory - The directory for which prior are generated - """ - cwd = Path.cwd() - try: - (cwd / "priors").mkdir() - except FileExistsError: - pass - for directory, _, files in os.walk(directory): - directory = Path(directory) - for file in files: - if file.endswith(".py"): - full_path = directory / file - spec = for_file(full_path) - config_path = cwd / "priors" / file.replace(".py", ".json") - if len(spec) > 0: - if config_path.exists(): - logger.info(f"{config_path} already exists") - continue - with open(config_path, "w+") as f: - json.dump(spec, f) diff --git a/priors/subconfig.json b/priors/subconfig.json deleted file mode 100644 index bffe257..0000000 --- a/priors/subconfig.json +++ /dev/null @@ -1 +0,0 @@ -{"SubClass": {"variable": {"type": "Uniform", "lower_limit": 0.0, "upper_limit": 1.0, "width_modifier": {"type": "Absolute", "value": 0.2}, "limits": {"lower": 0.0, "upper": 1.0}}}} \ No newline at end of file diff --git a/scripts/convert_config.py b/scripts/convert_config.py deleted file mode 100755 index 47ddaaa..0000000 --- a/scripts/convert_config.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -""" -Converts the configuration files and directories in a given directory into YAML configs. - -Usage: -./convert_config.py path/to/directory -""" - -import os -import shutil -import sys -from pathlib import Path - -import yaml - -from autonerves.directory_config import RecursiveConfig, YAMLConfig - -target_path = Path(sys.argv[1]) - -config = RecursiveConfig(str(target_path)) - -for key in config.keys(): - value = config[key] - if isinstance(value, YAMLConfig): - continue - - d = value.dict() - path = target_path / key - with open(path.with_suffix(".yaml"), "w") as f: - yaml.dump(d, f) - - try: - os.remove(path.with_suffix(".ini")) - except FileNotFoundError: - pass - - shutil.rmtree(path, ignore_errors=True) diff --git a/scripts/convert_prior_configs.py b/scripts/convert_prior_configs.py deleted file mode 100755 index 28fe401..0000000 --- a/scripts/convert_prior_configs.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -""" -Converts JSON prior configs to YAML equivalent. - -Usage: -./convert_prior_configs.py /path/to/prior/directory -""" -import json -import os -import sys -from pathlib import Path - -import oyaml as yaml - -ORDER = [ - "type", - "mean", - "sigma", - "lower_limit", - "upper_limit", - "width_modifier", - "limits", -] - -for path in Path(sys.argv[1]).rglob("*.json"): - with open(path) as f: - d = json.load(f) - - with open(path.with_suffix(".yaml"), "w") as f: - yaml.dump(d, f) - - os.remove(path) - - -def sort_dict(obj): - if isinstance(obj, dict): - return { - key: sort_dict(value) - for key, value in sorted( - obj.items(), - key=lambda item: ORDER.index(item[0]) if item[0] in ORDER else 999, - ) - } - if isinstance(obj, list): - return list(map(sort_dict, obj)) - return obj - - -for path in Path(sys.argv[1]).rglob("*.yaml"): - with open(path) as f: - d = yaml.safe_load(f) - - print(sort_dict(d)) - with open(path, "w") as f: - yaml.dump(sort_dict(d), f) diff --git a/scripts/generate_priors.py b/scripts/generate_priors.py deleted file mode 100755 index c0f6e59..0000000 --- a/scripts/generate_priors.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python -""" -Generate prior configuration for all classes in a package, recursively -""" - -from sys import argv - -from autonerves.json_prior import generate - -if __name__ == "__main__": - try: - generate.generate(argv[1]) - except KeyError: - print("Usage: ./generate_priors.py /path/to/project") diff --git a/test_autonerves/json_prior/test_generate.py b/test_autonerves/json_prior/test_generate.py deleted file mode 100644 index 63321fa..0000000 --- a/test_autonerves/json_prior/test_generate.py +++ /dev/null @@ -1,61 +0,0 @@ -import json -import os -from pathlib import Path - -import pytest - -from autonerves.json_prior import generate as g - -directory = Path(__file__).parent -package_directory = directory / "source_code" -module_path = package_directory / "module.py" - - -@pytest.fixture(name="prior_json") -def make_prior_json(): - return { - "MyClass": { - "simple": { - "limits": {"lower": 0.0, "upper": 1.0}, - "lower_limit": 0.0, - "type": "Uniform", - "upper_limit": 1.0, - "width_modifier": {"type": "Absolute", "value": 0.2}, - }, - "tup_0": { - "limits": {"lower": 0.0, "upper": 1.0}, - "lower_limit": 0.0, - "type": "Uniform", - "upper_limit": 1.0, - "width_modifier": {"type": "Absolute", "value": 0.2}, - }, - "tup_1": { - "limits": {"lower": 0.0, "upper": 1.0}, - "lower_limit": 0.0, - "type": "Uniform", - "upper_limit": 1.0, - "width_modifier": {"type": "Absolute", "value": 0.2}, - }, - } - } - - -@pytest.fixture(autouse=True) -def cleanup(): - yield - try: - os.remove("priors/module.json") - except FileNotFoundError: - pass - - -def test_generate_for_file(prior_json): - result = g.for_file(module_path) - assert result == prior_json - - -def test_generate(prior_json): - g.generate(package_directory) - - with open(f"priors/module.json") as f: - assert json.load(f) == prior_json