srbf 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. srbf-0.1.0/LICENSE +21 -0
  2. srbf-0.1.0/PKG-INFO +106 -0
  3. srbf-0.1.0/README.md +71 -0
  4. srbf-0.1.0/THIRD_PARTY_LICENSES +84 -0
  5. srbf-0.1.0/pyproject.toml +67 -0
  6. srbf-0.1.0/setup.cfg +4 -0
  7. srbf-0.1.0/src/srbf/__init__.py +10 -0
  8. srbf-0.1.0/src/srbf/__main__.py +96 -0
  9. srbf-0.1.0/src/srbf/baselines/__init__.py +7 -0
  10. srbf-0.1.0/src/srbf/baselines/brute_force_model.py +329 -0
  11. srbf-0.1.0/src/srbf/baselines/skeleton_pool_model.py +389 -0
  12. srbf-0.1.0/src/srbf/benchmarks/__init__.py +5 -0
  13. srbf-0.1.0/src/srbf/benchmarks/fastsrb.py +524 -0
  14. srbf-0.1.0/src/srbf/compat/__init__.py +5 -0
  15. srbf-0.1.0/src/srbf/compat/nesymres.py +74 -0
  16. srbf-0.1.0/src/srbf/eval/__init__.py +15 -0
  17. srbf-0.1.0/src/srbf/eval/candidate_store.py +308 -0
  18. srbf-0.1.0/src/srbf/eval/core.py +109 -0
  19. srbf-0.1.0/src/srbf/eval/data_sources.py +1015 -0
  20. srbf-0.1.0/src/srbf/eval/engine.py +599 -0
  21. srbf-0.1.0/src/srbf/eval/evaluation.py +159 -0
  22. srbf-0.1.0/src/srbf/eval/formatting.py +59 -0
  23. srbf-0.1.0/src/srbf/eval/metrics/__init__.py +24 -0
  24. srbf-0.1.0/src/srbf/eval/metrics/bootstrap.py +31 -0
  25. srbf-0.1.0/src/srbf/eval/metrics/numeric.py +97 -0
  26. srbf-0.1.0/src/srbf/eval/metrics/symbolic.py +34 -0
  27. srbf-0.1.0/src/srbf/eval/metrics/token_prediction.py +464 -0
  28. srbf-0.1.0/src/srbf/eval/metrics/zss.py +42 -0
  29. srbf-0.1.0/src/srbf/eval/model_adapters.py +1021 -0
  30. srbf-0.1.0/src/srbf/eval/provenance.py +186 -0
  31. srbf-0.1.0/src/srbf/eval/result_processing.py +351 -0
  32. srbf-0.1.0/src/srbf/eval/result_store.py +134 -0
  33. srbf-0.1.0/src/srbf/eval/run_config.py +779 -0
  34. srbf-0.1.0/src/srbf/eval/sample_metadata.py +85 -0
  35. srbf-0.1.0/src/srbf/eval/variable_renaming.py +128 -0
  36. srbf-0.1.0/src/srbf/py.typed +0 -0
  37. srbf-0.1.0/src/srbf.egg-info/PKG-INFO +106 -0
  38. srbf-0.1.0/src/srbf.egg-info/SOURCES.txt +41 -0
  39. srbf-0.1.0/src/srbf.egg-info/dependency_links.txt +1 -0
  40. srbf-0.1.0/src/srbf.egg-info/entry_points.txt +2 -0
  41. srbf-0.1.0/src/srbf.egg-info/requires.txt +23 -0
  42. srbf-0.1.0/src/srbf.egg-info/top_level.txt +1 -0
  43. srbf-0.1.0/tests/test_overlap_engine.py +287 -0
srbf-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Paul Saegert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
srbf-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,106 @@
1
+ Metadata-Version: 2.4
2
+ Name: srbf
3
+ Version: 0.1.0
4
+ Summary: srbf: the symbolic-regression evaluation framework (engine, adapters, benchmarks, metrics) carved from flash-ansr.
5
+ Author: Paul Saegert
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/psaegert/srbf
8
+ Project-URL: Issues, https://github.com/psaegert/srbf/issues
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ License-File: THIRD_PARTY_LICENSES
13
+ Requires-Dist: flash-ansr~=0.6
14
+ Requires-Dist: simplipy>=0.3.0
15
+ Requires-Dist: numpy>=1.24
16
+ Requires-Dist: pandas>=1.3
17
+ Requires-Dist: scikit-learn>=1.0
18
+ Requires-Dist: torch>=2.0
19
+ Requires-Dist: tqdm
20
+ Requires-Dist: pyyaml
21
+ Requires-Dist: zss
22
+ Requires-Dist: editdistance
23
+ Provides-Extra: baselines
24
+ Requires-Dist: sympy>=1.10; extra == "baselines"
25
+ Requires-Dist: pysr; extra == "baselines"
26
+ Requires-Dist: omegaconf; extra == "baselines"
27
+ Provides-Extra: dev
28
+ Requires-Dist: pre-commit; extra == "dev"
29
+ Requires-Dist: pytest; extra == "dev"
30
+ Requires-Dist: pytest-cov; extra == "dev"
31
+ Requires-Dist: mypy; extra == "dev"
32
+ Requires-Dist: flake8; extra == "dev"
33
+ Requires-Dist: srbf[baselines]; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # srbf: Symbolic Regression Benchmark Framework
37
+
38
+ `srbf` evaluates symbolic-regression models on shared benchmarks with shared metrics. It is the
39
+ evaluation framework carved out of [flash-ansr](https://github.com/psaegert/flash-ansr): the
40
+ evaluation engine, model adapters, benchmarks, and metrics. It depends one-way on `flash-ansr`
41
+ (`srbf` imports `flash-ansr`; `flash-ansr` never imports `srbf`).
42
+
43
+ **Built for contributions.** Developers of SR methods add their model by opening a PR with an
44
+ **adapter** (two methods) plus install instructions. The built-in adapters (`flash_ansr`, `pysr`,
45
+ `nesymres`, `e2e`, `skeleton_pool`, `brute_force`) are reference examples, not a closed set. See the
46
+ [adapter contribution guide](docs/adapters.md).
47
+
48
+ > **Status: 0.1, cleanly-carved eval.** The engine seam (`srbf.eval.core` Protocols +
49
+ > `srbf.eval.engine`) is model-agnostic, but every built-in adapter imports `flash-ansr` and the
50
+ > adapter set is a registry edited by PR. A plugin `register_adapter()` entry-point and raw-dataset
51
+ > (`(X, y)` CSV/parquet) ingestion are planned follow-ons.
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ pip install srbf # engine + metrics + the pip-installable adapters (flash-ansr, PySR)
57
+ pip install "srbf[baselines]" # + pip baseline deps (sympy, pysr, omegaconf)
58
+ ```
59
+
60
+ `srbf` pulls in `flash-ansr` and `simplipy` automatically. The unpackaged research baselines
61
+ (NeSymReS, E2E) are provisioned out-of-band; see [docs/models.md](docs/models.md).
62
+
63
+ ## Quickstart
64
+
65
+ ```bash
66
+ # 1. point srbf at a tree holding configs/, data/, and models/ (your srbf checkout works)
67
+ export FLASH_ANSR_ROOT=$(pwd)
68
+
69
+ # 2. get a model to evaluate (flash-ansr's CLI ships with srbf)
70
+ flash_ansr install psaegert/flash-ansr-v23.0-3M
71
+
72
+ # 3. fetch a benchmark + build its skeleton pool (see docs/benchmarks.md)
73
+ # ...then run an evaluation:
74
+ srbf run -c configs/evaluation/scaling/v23.0-3M_val.yaml --limit 50 -v
75
+ ```
76
+
77
+ Outputs land under `results/evaluation/.../*.pkl`, one row per evaluated dataset with flat metric
78
+ columns. Run programmatically instead:
79
+
80
+ ```python
81
+ from srbf import build_evaluation_run
82
+
83
+ plan = build_evaluation_run(config="configs/evaluation/scaling/v23.0-3M_val.yaml")
84
+ plan.engine.run(limit=plan.remaining, output_path=plan.output_path)
85
+ ```
86
+
87
+ ## Documentation
88
+
89
+ | Guide | What it covers |
90
+ |---|---|
91
+ | [Running evaluations](docs/running.md) | the `srbf run` CLI, config anatomy (data_source / model_adapter / runner / experiments), outputs, resume |
92
+ | [Benchmarks & datasets](docs/benchmarks.md) | fetching FastSRB, building skeleton pools with `flash_ansr import-data`, custom sets |
93
+ | [Models & provisioning](docs/models.md) | installing/patching the built-in models; the `model_adapter` block per type |
94
+ | [**Adding your model**](docs/adapters.md) | the adapter protocol + registry, and the PR flow to contribute a new SR method |
95
+
96
+ ## Development
97
+
98
+ ```bash
99
+ pip install -e ".[dev]"
100
+ pre-commit run --all-files
101
+ pytest tests
102
+ ```
103
+
104
+ ## License
105
+
106
+ MIT (see [LICENSE](LICENSE)). Third-party attributions in [THIRD_PARTY_LICENSES](THIRD_PARTY_LICENSES).
srbf-0.1.0/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # srbf: Symbolic Regression Benchmark Framework
2
+
3
+ `srbf` evaluates symbolic-regression models on shared benchmarks with shared metrics. It is the
4
+ evaluation framework carved out of [flash-ansr](https://github.com/psaegert/flash-ansr): the
5
+ evaluation engine, model adapters, benchmarks, and metrics. It depends one-way on `flash-ansr`
6
+ (`srbf` imports `flash-ansr`; `flash-ansr` never imports `srbf`).
7
+
8
+ **Built for contributions.** Developers of SR methods add their model by opening a PR with an
9
+ **adapter** (two methods) plus install instructions. The built-in adapters (`flash_ansr`, `pysr`,
10
+ `nesymres`, `e2e`, `skeleton_pool`, `brute_force`) are reference examples, not a closed set. See the
11
+ [adapter contribution guide](docs/adapters.md).
12
+
13
+ > **Status: 0.1, cleanly-carved eval.** The engine seam (`srbf.eval.core` Protocols +
14
+ > `srbf.eval.engine`) is model-agnostic, but every built-in adapter imports `flash-ansr` and the
15
+ > adapter set is a registry edited by PR. A plugin `register_adapter()` entry-point and raw-dataset
16
+ > (`(X, y)` CSV/parquet) ingestion are planned follow-ons.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ pip install srbf # engine + metrics + the pip-installable adapters (flash-ansr, PySR)
22
+ pip install "srbf[baselines]" # + pip baseline deps (sympy, pysr, omegaconf)
23
+ ```
24
+
25
+ `srbf` pulls in `flash-ansr` and `simplipy` automatically. The unpackaged research baselines
26
+ (NeSymReS, E2E) are provisioned out-of-band; see [docs/models.md](docs/models.md).
27
+
28
+ ## Quickstart
29
+
30
+ ```bash
31
+ # 1. point srbf at a tree holding configs/, data/, and models/ (your srbf checkout works)
32
+ export FLASH_ANSR_ROOT=$(pwd)
33
+
34
+ # 2. get a model to evaluate (flash-ansr's CLI ships with srbf)
35
+ flash_ansr install psaegert/flash-ansr-v23.0-3M
36
+
37
+ # 3. fetch a benchmark + build its skeleton pool (see docs/benchmarks.md)
38
+ # ...then run an evaluation:
39
+ srbf run -c configs/evaluation/scaling/v23.0-3M_val.yaml --limit 50 -v
40
+ ```
41
+
42
+ Outputs land under `results/evaluation/.../*.pkl`, one row per evaluated dataset with flat metric
43
+ columns. Run programmatically instead:
44
+
45
+ ```python
46
+ from srbf import build_evaluation_run
47
+
48
+ plan = build_evaluation_run(config="configs/evaluation/scaling/v23.0-3M_val.yaml")
49
+ plan.engine.run(limit=plan.remaining, output_path=plan.output_path)
50
+ ```
51
+
52
+ ## Documentation
53
+
54
+ | Guide | What it covers |
55
+ |---|---|
56
+ | [Running evaluations](docs/running.md) | the `srbf run` CLI, config anatomy (data_source / model_adapter / runner / experiments), outputs, resume |
57
+ | [Benchmarks & datasets](docs/benchmarks.md) | fetching FastSRB, building skeleton pools with `flash_ansr import-data`, custom sets |
58
+ | [Models & provisioning](docs/models.md) | installing/patching the built-in models; the `model_adapter` block per type |
59
+ | [**Adding your model**](docs/adapters.md) | the adapter protocol + registry, and the PR flow to contribute a new SR method |
60
+
61
+ ## Development
62
+
63
+ ```bash
64
+ pip install -e ".[dev]"
65
+ pre-commit run --all-files
66
+ pytest tests
67
+ ```
68
+
69
+ ## License
70
+
71
+ MIT (see [LICENSE](LICENSE)). Third-party attributions in [THIRD_PARTY_LICENSES](THIRD_PARTY_LICENSES).
@@ -0,0 +1,84 @@
1
+ Third-party licenses
2
+ ====================
3
+
4
+ Flash-ANSR itself is distributed under the MIT License (see LICENSE).
5
+ Portions of this project are derived from or interoperate with third-party
6
+ work, whose licenses and notices are reproduced below.
7
+
8
+
9
+ -------------------------------------------------------------------------------
10
+ Neural Symbolic Regression that Scales (NeSymReS)
11
+ -------------------------------------------------------------------------------
12
+
13
+ The function `load_nesymres` in `src/srbf/compat/nesymres.py` is largely
14
+ based on code from the "Neural Symbolic Regression that Scales" repository:
15
+ https://github.com/SymposiumOrganization/NeuralSymbolicRegressionThatScales
16
+
17
+ That project is distributed under the MIT License:
18
+
19
+ MIT License
20
+
21
+ Copyright (c) 2021 SymposiumOrganization
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in all
31
+ copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
+ SOFTWARE.
40
+
41
+
42
+ -------------------------------------------------------------------------------
43
+ Fast Symbolic Regression Benchmarking (FastSRB)
44
+ -------------------------------------------------------------------------------
45
+
46
+ The FastSRB benchmark sampling code in `src/srbf/benchmarks/fastsrb.py`
47
+ (and the `FastSRBSource` evaluation data source in
48
+ `src/srbf/eval/data_sources.py`) is translated and adapted from the Julia
49
+ FastSRB benchmarking code by Viktor Martinek:
50
+ https://github.com/viktmar/FastSRB
51
+
52
+ @misc{martinek2025fastsymbolicregressionbenchmarking,
53
+ title={Fast Symbolic Regression Benchmarking},
54
+ author={Viktor Martinek},
55
+ year={2025},
56
+ eprint={2508.14481},
57
+ archivePrefix={arXiv},
58
+ primaryClass={cs.LG},
59
+ url={https://arxiv.org/abs/2508.14481},
60
+ }
61
+
62
+ That project is distributed under the MIT License:
63
+
64
+ MIT License
65
+
66
+ Copyright (c) 2025 Viktor Martinek
67
+
68
+ Permission is hereby granted, free of charge, to any person obtaining a copy
69
+ of this software and associated documentation files (the "Software"), to deal
70
+ in the Software without restriction, including without limitation the rights
71
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
72
+ copies of the Software, and to permit persons to whom the Software is
73
+ furnished to do so, subject to the following conditions:
74
+
75
+ The above copyright notice and this permission notice shall be included in all
76
+ copies or substantial portions of the Software.
77
+
78
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
79
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
80
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
81
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
82
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
83
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
84
+ SOFTWARE.
@@ -0,0 +1,67 @@
1
+ # srbf: the symbolic-regression evaluation framework, carved from flash-ansr.
2
+ # Internal self-imports are srbf.* ; the §5 contract imports stay flash_ansr.* (one-way dependency;
3
+ # flash-ansr must NEVER import srbf).
4
+ [project]
5
+ name = "srbf"
6
+ description = "srbf: the symbolic-regression evaluation framework (engine, adapters, benchmarks, metrics) carved from flash-ansr."
7
+ authors = [{ name = "Paul Saegert" }]
8
+ readme = "README.md"
9
+ requires-python = ">=3.12"
10
+ version = "0.1.0"
11
+ license = "MIT"
12
+ license-files = ["LICEN[CS]E*", "THIRD_PARTY_LICENSES*"]
13
+
14
+ dependencies = [
15
+ "flash-ansr~=0.6", # one-way dep; CI-tested 0.6.x ceiling (flash-ansr never imports srbf).
16
+ "simplipy>=0.3.0", # DIRECT: eval/baselines/benchmarks all import it
17
+ "numpy>=1.24",
18
+ "pandas>=1.3", # runtime: baselines imported top-level by eval/model_adapters.py
19
+ "scikit-learn>=1.0", # runtime: baselines BaseEstimator, same reason
20
+ "torch>=2.0", # direct in provenance/model_adapters/token_prediction/baselines
21
+ "tqdm",
22
+ "pyyaml", # benchmarks/fastsrb.py
23
+ "zss", # moved out of flash-ansr core (eval-only)
24
+ "editdistance", # moved out of flash-ansr core (eval-only)
25
+ ]
26
+
27
+ [project.optional-dependencies]
28
+ # pip-installable third-party baselines whose imports are LAZY (not needed to `import srbf`).
29
+ baselines = [
30
+ "sympy>=1.10", # E2E + NeSymReS adapters (lazy)
31
+ "pysr", # PySRAdapter (lazy; also needs Julia at runtime)
32
+ "omegaconf", # NeSymReS adapter glue (compat/nesymres.py)
33
+ ]
34
+ dev = ["pre-commit", "pytest", "pytest-cov", "mypy", "flake8", "srbf[baselines]"]
35
+
36
+ [project.scripts]
37
+ srbf = "srbf.__main__:main" # carries ONLY the eval `run` command
38
+
39
+ [project.urls]
40
+ Repository = "https://github.com/psaegert/srbf"
41
+ Issues = "https://github.com/psaegert/srbf/issues"
42
+
43
+ # NB: the NeSymReS/E2E vendored model trees + weights are NOT pip deps and never enter the wheel;
44
+ # they are provisioned by a git-clone bench-setup flow using scripts/patch_nesymres.py.
45
+
46
+ [build-system]
47
+ requires = ["setuptools>=68", "wheel"]
48
+ build-backend = "setuptools.build_meta"
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = ["src"] # src/srbf/ ; the out-of-band nesymres clone tree is not under src/, so it stays out of the wheel
52
+
53
+ [tool.setuptools.package-data]
54
+ srbf = ["py.typed"]
55
+
56
+ [tool.mypy]
57
+ # Mirror flash-ansr's mypy settings (this code was carved from flash_ansr.eval and type-checked clean there).
58
+ no_implicit_optional = false
59
+ disallow_untyped_defs = true
60
+ disallow_incomplete_defs = true
61
+ explicit_package_bases = true
62
+ exclude = "(.venv|tests/|src/srbf/compat/nesymres.py)" # vendored nesymres types unavailable (carried over from flash-ansr)
63
+ ignore_missing_imports = true
64
+
65
+ [tool.flake8]
66
+ ignore = ["E501", "W503"]
67
+ per-file-ignores = "__init__.py:F401"
srbf-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ """srbf: the symbolic-regression evaluation framework, carved from flash-ansr.
2
+
3
+ Engine + model adapters + benchmarks + metrics for evaluating symbolic-regression models.
4
+ Depends one-way on flash-ansr (srbf imports flash-ansr; flash-ansr never imports srbf).
5
+ """
6
+ from srbf.eval.evaluation import Evaluation
7
+ from srbf.eval.run_config import EvaluationRunPlan, build_evaluation_run
8
+
9
+ __all__ = ["Evaluation", "EvaluationRunPlan", "build_evaluation_run"]
10
+ __version__ = "0.1.0"
@@ -0,0 +1,96 @@
1
+ """srbf command-line interface: the ``run`` subcommand carved from flash-ansr.
2
+
3
+ flash-ansr keeps the rest of its CLI (train / benchmark / import-data / install / ...); only
4
+ ``run`` is evaluation-bound and lives here. The eval imports are ``srbf.eval.*``; the
5
+ flash-ansr ``utils`` imports are the cross-repo contract (srbf depends one-way on flash-ansr).
6
+ """
7
+ import argparse
8
+
9
+
10
+ def main(argv: list[str] | None = None) -> None:
11
+ parser = argparse.ArgumentParser(description="srbf: symbolic-regression evaluation framework")
12
+ subparsers = parser.add_subparsers(dest="command_name", required=True)
13
+
14
+ run_parser = subparsers.add_parser("run", help="Run an evaluation from a unified config")
15
+ run_parser.add_argument('-c', '--config', type=str, required=True, help='Path to the evaluation run config file')
16
+ run_parser.add_argument('-n', '--limit', type=int, default=None, help='Override the sample limit specified in the config')
17
+ run_parser.add_argument('-o', '--output-file', type=str, default=None, help='Override the output file path from the config')
18
+ run_parser.add_argument('--save-every', type=int, default=None, help='Override periodic save frequency')
19
+ run_parser.add_argument('--no-resume', action='store_true', help='Ignore previous results even if the output file exists')
20
+ run_parser.add_argument('--experiment', type=str, default=None, help='Name of the experiment defined in the config to execute')
21
+ run_parser.add_argument('-v', '--verbose', action='store_true', help='Print a progress bar')
22
+
23
+ args = parser.parse_args(argv)
24
+
25
+ match args.command_name:
26
+ case 'run':
27
+ from srbf.eval.run_config import build_evaluation_run, EvaluationRunPlan
28
+ from flash_ansr.utils.config_io import load_config
29
+ from flash_ansr.utils.paths import substitute_root_path
30
+
31
+ config_path = substitute_root_path(args.config)
32
+ if args.verbose:
33
+ print(f"Running evaluation plan from {config_path}")
34
+
35
+ raw_config = load_config(config_path)
36
+ experiment_map = raw_config.get("experiments") if isinstance(raw_config, dict) else None
37
+
38
+ from srbf.eval.provenance import collect_provenance, format_provenance
39
+ base_prov = collect_provenance(config_path, None)
40
+ print(format_provenance(base_prov), flush=True)
41
+
42
+ def _execute_plan(plan: EvaluationRunPlan, experiment_name: str | None = None) -> None:
43
+ label = f"[{experiment_name}] " if experiment_name else ""
44
+ if plan.completed or plan.engine is None:
45
+ if args.verbose:
46
+ target = plan.total_limit or 'configured'
47
+ print(f"{label}Evaluation already completed ({plan.existing_results}/{target}). Nothing to do.")
48
+ return
49
+
50
+ plan.engine.run(
51
+ limit=plan.remaining,
52
+ save_every=plan.save_every,
53
+ output_path=plan.output_path,
54
+ verbose=args.verbose,
55
+ progress=args.verbose,
56
+ meta={**base_prov, "experiment": experiment_name},
57
+ )
58
+
59
+ if args.verbose:
60
+ total = plan.engine.result_store.size
61
+ destination = plan.output_path or 'memory'
62
+ print(f"{label}Evaluation finished with {total} samples (saved to {destination}).")
63
+
64
+ if experiment_map and args.experiment is None:
65
+ experiment_names = list(experiment_map.keys())
66
+ if args.verbose:
67
+ count = len(experiment_names)
68
+ print(f"No --experiment provided; running all {count} experiments defined in config.")
69
+ for experiment_name in experiment_names:
70
+ if args.verbose:
71
+ print(f"--> {experiment_name}")
72
+ plan = build_evaluation_run(
73
+ config=config_path,
74
+ limit_override=args.limit,
75
+ output_override=args.output_file,
76
+ save_every_override=args.save_every,
77
+ resume=None if not args.no_resume else False,
78
+ experiment=experiment_name,
79
+ )
80
+ _execute_plan(plan, experiment_name)
81
+ else:
82
+ plan = build_evaluation_run(
83
+ config=config_path,
84
+ limit_override=args.limit,
85
+ output_override=args.output_file,
86
+ save_every_override=args.save_every,
87
+ resume=None if not args.no_resume else False,
88
+ experiment=args.experiment,
89
+ )
90
+ _execute_plan(plan, args.experiment)
91
+ case _:
92
+ parser.print_help()
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
@@ -0,0 +1,7 @@
1
+ from .skeleton_pool_model import SkeletonPoolModel
2
+ from .brute_force_model import BruteForceModel
3
+
4
+ __all__ = [
5
+ "SkeletonPoolModel",
6
+ "BruteForceModel",
7
+ ]