chronobench 0.1.1__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.
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2026 KU Leuven, DTAI Research Group
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,199 @@
1
+ Metadata-Version: 2.4
2
+ Name: chronobench
3
+ Version: 0.1.1
4
+ Author-email: Louis Carpentier <louis.carpentier@kuleuven.be>
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Provides-Extra: tqdm
9
+ Requires-Dist: tqdm; extra == "tqdm"
10
+ Provides-Extra: simple-example
11
+ Requires-Dist: scikit-learn>=1.3; extra == "simple-example"
12
+ Dynamic: license-file
13
+
14
+ Chronobench
15
+ ===========
16
+
17
+ A registry-driven ML experiment benchmarking framework. You register your own data loaders, models, and metrics (or refer to library ones by import path) and write one training loop — Chronobench handles configuration, parameter sweeps, parallelism, and CSV output. Your domain code stays in its own modules and never needs to import Chronobench or change to add an experiment.
18
+
19
+ ## Installation
20
+
21
+ Install Chronobench as follows:
22
+ ```bash
23
+ pip install git+https://github.com/LouisCarpentier42/Chronobench
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ Keep your components in plain modules (here `loaders.py`), then write a `script.py` that registers them, defines a `runner`, and calls `chronobench.main()`:
29
+
30
+ ```python
31
+ import chronobench as cb
32
+ from loaders import IrisLoader, BreastCancerLoader
33
+
34
+ cb.data_loaders.register(iris=IrisLoader, breast_cancer=BreastCancerLoader)
35
+
36
+ @cb.runner
37
+ def runner(data_loader, model, metrics) -> dict:
38
+ X_train, X_test, y_train, y_test = data_loader.load()
39
+ model.fit(X_train, y_train)
40
+ y_pred = model.predict(X_test)
41
+ return {m.func.__name__: m(y_test, y_pred) for m in metrics}
42
+
43
+ if __name__ == "__main__":
44
+ cb.main()
45
+ ```
46
+
47
+ Experiment TOML entries pick an implementation by registered `name` or by dotted `target` import path:
48
+
49
+ ```toml
50
+ [[data]]
51
+ name = "iris" # a registered name
52
+ test_size = 0.2
53
+
54
+ [[models]]
55
+ target = "sklearn.svm.SVC" # an import path - no registration
56
+ kernel = "linear"
57
+
58
+ [[metrics]]
59
+ target = "sklearn.metrics.accuracy_score" # an import path — no registration
60
+ ```
61
+
62
+ Then run it from the command line:
63
+
64
+ ```bash
65
+ python script.py my_experiment
66
+ ```
67
+
68
+ See [`examples/simple/`](examples/simple/) for a complete working example with scikit-learn.
69
+
70
+ ## Concepts
71
+
72
+ ### Registering components
73
+
74
+ Chronobench keeps three registries — `cb.data_loaders`, `cb.models`, and `cb.metrics` — plus one `runner`. A *factory* is any callable that produces a component: a class, or a function defined in your script. Register factories by short name:
75
+
76
+ ```python
77
+ cb.data_loaders.register(<short-name>=<object>)
78
+ ```
79
+
80
+ Registration is optional: anything importable can be referenced by its `target` path instead (see below), so in practice you register the components for which you want a short, stable name — typically your own project code — and refer to library components by import path.
81
+
82
+ Because `data_loader` and `model` are whatever the factory returns, you are not constrained to object-oriented wrappers — returning raw data (e.g., a tuple of arrays), a file path, or a config dict is equally valid as long as `runner` knows how to use it. The `runner` returns a dict whose keys become CSV columns.
83
+
84
+ ### `name` vs `target`
85
+
86
+ Each TOML entry selects its implementation with **exactly one** of:
87
+
88
+ - `name` — a name you registered in the script. Short, refactor-safe, and validated (an unknown name fails fast with the list of available names). Best for your own, frequently used components.
89
+ - `target` — a dotted import path (e.g. `"sklearn.svm.SVC"`). Resolved by import, so any library class or function works with no wrapper and no registration. Best for third-party components.
90
+
91
+ All other keys in the entry are forwarded to the factory as `**kwargs`.
92
+
93
+ ### Factories return lists or single instances
94
+
95
+ Each factory may return a single instance or a list of instances. A single instance produces one job variant, a list produces one variant per element, each crossed with every other-side variant. This allows you to easily run multiple datasets and/or models in the same experiment without writing any loops or separate config files.
96
+
97
+
98
+ A factory may return a **list** of instances. A single `[[data]]` (or `[[models]]`) entry then fans out into one variant per element, each crossed with every model (resp. data) variant — i.e. one CSV row per `(item × other-side-config)`. Each row is labeled by the instance's `name` attribute when present, otherwise by the entry label plus an index.
99
+
100
+ ```python
101
+ def all_datasets(test_size=0.2, random_state=None):
102
+ return [
103
+ IrisLoader(test_size=test_size, random_state=random_state),
104
+ BreastCancerLoader(test_size=test_size, random_state=random_state),
105
+ ]
106
+
107
+ cb.data_loaders.register(all=all_datasets) # one [[data]] entry -> two dataset rows
108
+ ```
109
+
110
+ To instead keep a single job that internally manages several splits (e.g. a tuning + evaluation set in one folder), just return one object whose `load()` exposes all splits and let `runner` use them.
111
+
112
+ ### Metrics: scoring functions without wrappers
113
+
114
+ A metric is a callable the `runner` invokes with data (e.g. `metric(y_true, y_pred)`). You can use a class whose instance is that callable, but a **bare scoring function works directly** — by `target` (no registration) or by a registered `name`:
115
+
116
+ ```toml
117
+ [[metrics]]
118
+ target = "sklearn.metrics.fbeta_score"
119
+ beta = 1.0
120
+ average = "macro" # bound into the function; remaining y_true/y_pred come from the runner
121
+ ```
122
+
123
+ When the config kwargs don't satisfy every required parameter (here `fbeta_score` still needs `y_true`/`y_pred`), Chronobench binds the given arguments with `functools.partial` and lets the `runner` supply the rest, instead of calling the function immediately. The result is a bound function, so name the CSV column from it in your runner (e.g., `metric.func.__name__`). Note that a bare function uses *its own* defaults (e.g., `fbeta_score` defaults to `average="binary"`, which fails on multiclass data), so set what you need in the TOML.
124
+
125
+ To register such a function under a short name instead, the optional convenience is:
126
+
127
+ ```python
128
+ from sklearn.metrics import accuracy_score, fbeta_score
129
+ cb.metrics.register(accuracy=accuracy_score, fbeta=fbeta_score)
130
+ ```
131
+
132
+ ### Context and environment injection
133
+
134
+ Factories are called with their TOML `**kwargs`. Chronobench also passes `environment` and/or `context` **only when the factory declares them as explicit parameters**, so plain and library classes work untouched while advanced factories can opt in:
135
+
136
+ ```python
137
+ def make_model(context, n_layers=2): # receives the cross-initializer context
138
+ return MyModel(n_classes=context.data_loader.n_classes, n_layers=n_layers)
139
+ ```
140
+
141
+ `environment` is the parsed `environment.toml`. `context` is a `Context` dataclass built progressively across stages:
142
+
143
+ | Stage | Populated `context` fields |
144
+ |---|---|
145
+ | data loaders | none |
146
+ | models | `data_loader`, `data_loader_name`, `data_loader_kwargs` |
147
+ | metrics | above + `model`, `model_name`, `model_kwargs` |
148
+
149
+ > `name`, `target`, `context`, and `environment` are reserved keys and must not be used as TOML parameter names.
150
+
151
+ ### Configuration files
152
+
153
+ **`environment.toml`** — global settings, required keys:
154
+
155
+ ```toml
156
+ path-to-results = "./results"
157
+ path-to-experiments = "./experiments"
158
+ n-jobs = 4
159
+ ```
160
+
161
+ **`experiments/<name>.toml`** — one file per experiment, with `[[data]]`, `[[models]]`, and `[[metrics]]` arrays-of-tables. `[[data]]` and `[[models]]` entries produce job variants (their Cartesian product is the final job list); `[[metrics]]` entries are collected into a single flat list used for every job.
162
+
163
+ ### Sweep parameters
164
+
165
+ Add `sweep.<key> = [v1, v2, ...]` to any entry to generate a parameter grid. The framework expands all sweep keys within a block via Cartesian product, then takes the product of data configs × model configs to produce the final job list. Sweep expansion on `[[metrics]]` entries only adds more metric instances per job — it does not create additional jobs.
166
+
167
+ ```toml
168
+ [[data]]
169
+ name = "iris"
170
+ sweep.random_state = [0, 1, 2] # 3 variants
171
+
172
+ [[models]] # 2 × 2 = 4 model variants
173
+ target = "sklearn.ensemble.RandomForestClassifier"
174
+ sweep.criterion = ["gini", "entropy"] # 2 variants
175
+ sweep.max_depth = [5, 10] # 2 variants
176
+
177
+ [[metrics]]
178
+ target = "sklearn.metrics.fbeta_score"
179
+ average = "macro"
180
+ sweep.beta = [0.5, 1.0, 2.0] # 3 variants
181
+ ```
182
+
183
+ This produces 3 × 4 = 12 jobs total. For each job, 3 metrics are computed ($F_\beta$ for all $\beta \in \{0.5, 1.0, 2.0\}$).
184
+
185
+ ### Results
186
+
187
+ Results are written to:
188
+
189
+ ```
190
+ {path-to-results}/raw/{experiment_name}/YYYYMMDD-HHMMSS.csv
191
+ ```
192
+
193
+ Columns are the union of all keys returned by `runner()`, plus `Dataset` and `Model` metadata columns. If a key appears in both data loader and model kwargs, it is prefixed with `Dataset.` / `Model.` to avoid collision.
194
+
195
+ Run `python script.py --help` for the full list of options.
196
+
197
+ ### Roadmap
198
+
199
+ This project is in early development, and many changes are still expected. However, the main interface should remain stable. Go to the [issue page](https://github.com/LouisCarpentier42/Chronobench/issues) for an overview of the tasks we plan to add in the near future.
@@ -0,0 +1,186 @@
1
+ Chronobench
2
+ ===========
3
+
4
+ A registry-driven ML experiment benchmarking framework. You register your own data loaders, models, and metrics (or refer to library ones by import path) and write one training loop — Chronobench handles configuration, parameter sweeps, parallelism, and CSV output. Your domain code stays in its own modules and never needs to import Chronobench or change to add an experiment.
5
+
6
+ ## Installation
7
+
8
+ Install Chronobench as follows:
9
+ ```bash
10
+ pip install git+https://github.com/LouisCarpentier42/Chronobench
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ Keep your components in plain modules (here `loaders.py`), then write a `script.py` that registers them, defines a `runner`, and calls `chronobench.main()`:
16
+
17
+ ```python
18
+ import chronobench as cb
19
+ from loaders import IrisLoader, BreastCancerLoader
20
+
21
+ cb.data_loaders.register(iris=IrisLoader, breast_cancer=BreastCancerLoader)
22
+
23
+ @cb.runner
24
+ def runner(data_loader, model, metrics) -> dict:
25
+ X_train, X_test, y_train, y_test = data_loader.load()
26
+ model.fit(X_train, y_train)
27
+ y_pred = model.predict(X_test)
28
+ return {m.func.__name__: m(y_test, y_pred) for m in metrics}
29
+
30
+ if __name__ == "__main__":
31
+ cb.main()
32
+ ```
33
+
34
+ Experiment TOML entries pick an implementation by registered `name` or by dotted `target` import path:
35
+
36
+ ```toml
37
+ [[data]]
38
+ name = "iris" # a registered name
39
+ test_size = 0.2
40
+
41
+ [[models]]
42
+ target = "sklearn.svm.SVC" # an import path - no registration
43
+ kernel = "linear"
44
+
45
+ [[metrics]]
46
+ target = "sklearn.metrics.accuracy_score" # an import path — no registration
47
+ ```
48
+
49
+ Then run it from the command line:
50
+
51
+ ```bash
52
+ python script.py my_experiment
53
+ ```
54
+
55
+ See [`examples/simple/`](examples/simple/) for a complete working example with scikit-learn.
56
+
57
+ ## Concepts
58
+
59
+ ### Registering components
60
+
61
+ Chronobench keeps three registries — `cb.data_loaders`, `cb.models`, and `cb.metrics` — plus one `runner`. A *factory* is any callable that produces a component: a class, or a function defined in your script. Register factories by short name:
62
+
63
+ ```python
64
+ cb.data_loaders.register(<short-name>=<object>)
65
+ ```
66
+
67
+ Registration is optional: anything importable can be referenced by its `target` path instead (see below), so in practice you register the components for which you want a short, stable name — typically your own project code — and refer to library components by import path.
68
+
69
+ Because `data_loader` and `model` are whatever the factory returns, you are not constrained to object-oriented wrappers — returning raw data (e.g., a tuple of arrays), a file path, or a config dict is equally valid as long as `runner` knows how to use it. The `runner` returns a dict whose keys become CSV columns.
70
+
71
+ ### `name` vs `target`
72
+
73
+ Each TOML entry selects its implementation with **exactly one** of:
74
+
75
+ - `name` — a name you registered in the script. Short, refactor-safe, and validated (an unknown name fails fast with the list of available names). Best for your own, frequently used components.
76
+ - `target` — a dotted import path (e.g. `"sklearn.svm.SVC"`). Resolved by import, so any library class or function works with no wrapper and no registration. Best for third-party components.
77
+
78
+ All other keys in the entry are forwarded to the factory as `**kwargs`.
79
+
80
+ ### Factories return lists or single instances
81
+
82
+ Each factory may return a single instance or a list of instances. A single instance produces one job variant, a list produces one variant per element, each crossed with every other-side variant. This allows you to easily run multiple datasets and/or models in the same experiment without writing any loops or separate config files.
83
+
84
+
85
+ A factory may return a **list** of instances. A single `[[data]]` (or `[[models]]`) entry then fans out into one variant per element, each crossed with every model (resp. data) variant — i.e. one CSV row per `(item × other-side-config)`. Each row is labeled by the instance's `name` attribute when present, otherwise by the entry label plus an index.
86
+
87
+ ```python
88
+ def all_datasets(test_size=0.2, random_state=None):
89
+ return [
90
+ IrisLoader(test_size=test_size, random_state=random_state),
91
+ BreastCancerLoader(test_size=test_size, random_state=random_state),
92
+ ]
93
+
94
+ cb.data_loaders.register(all=all_datasets) # one [[data]] entry -> two dataset rows
95
+ ```
96
+
97
+ To instead keep a single job that internally manages several splits (e.g. a tuning + evaluation set in one folder), just return one object whose `load()` exposes all splits and let `runner` use them.
98
+
99
+ ### Metrics: scoring functions without wrappers
100
+
101
+ A metric is a callable the `runner` invokes with data (e.g. `metric(y_true, y_pred)`). You can use a class whose instance is that callable, but a **bare scoring function works directly** — by `target` (no registration) or by a registered `name`:
102
+
103
+ ```toml
104
+ [[metrics]]
105
+ target = "sklearn.metrics.fbeta_score"
106
+ beta = 1.0
107
+ average = "macro" # bound into the function; remaining y_true/y_pred come from the runner
108
+ ```
109
+
110
+ When the config kwargs don't satisfy every required parameter (here `fbeta_score` still needs `y_true`/`y_pred`), Chronobench binds the given arguments with `functools.partial` and lets the `runner` supply the rest, instead of calling the function immediately. The result is a bound function, so name the CSV column from it in your runner (e.g., `metric.func.__name__`). Note that a bare function uses *its own* defaults (e.g., `fbeta_score` defaults to `average="binary"`, which fails on multiclass data), so set what you need in the TOML.
111
+
112
+ To register such a function under a short name instead, the optional convenience is:
113
+
114
+ ```python
115
+ from sklearn.metrics import accuracy_score, fbeta_score
116
+ cb.metrics.register(accuracy=accuracy_score, fbeta=fbeta_score)
117
+ ```
118
+
119
+ ### Context and environment injection
120
+
121
+ Factories are called with their TOML `**kwargs`. Chronobench also passes `environment` and/or `context` **only when the factory declares them as explicit parameters**, so plain and library classes work untouched while advanced factories can opt in:
122
+
123
+ ```python
124
+ def make_model(context, n_layers=2): # receives the cross-initializer context
125
+ return MyModel(n_classes=context.data_loader.n_classes, n_layers=n_layers)
126
+ ```
127
+
128
+ `environment` is the parsed `environment.toml`. `context` is a `Context` dataclass built progressively across stages:
129
+
130
+ | Stage | Populated `context` fields |
131
+ |---|---|
132
+ | data loaders | none |
133
+ | models | `data_loader`, `data_loader_name`, `data_loader_kwargs` |
134
+ | metrics | above + `model`, `model_name`, `model_kwargs` |
135
+
136
+ > `name`, `target`, `context`, and `environment` are reserved keys and must not be used as TOML parameter names.
137
+
138
+ ### Configuration files
139
+
140
+ **`environment.toml`** — global settings, required keys:
141
+
142
+ ```toml
143
+ path-to-results = "./results"
144
+ path-to-experiments = "./experiments"
145
+ n-jobs = 4
146
+ ```
147
+
148
+ **`experiments/<name>.toml`** — one file per experiment, with `[[data]]`, `[[models]]`, and `[[metrics]]` arrays-of-tables. `[[data]]` and `[[models]]` entries produce job variants (their Cartesian product is the final job list); `[[metrics]]` entries are collected into a single flat list used for every job.
149
+
150
+ ### Sweep parameters
151
+
152
+ Add `sweep.<key> = [v1, v2, ...]` to any entry to generate a parameter grid. The framework expands all sweep keys within a block via Cartesian product, then takes the product of data configs × model configs to produce the final job list. Sweep expansion on `[[metrics]]` entries only adds more metric instances per job — it does not create additional jobs.
153
+
154
+ ```toml
155
+ [[data]]
156
+ name = "iris"
157
+ sweep.random_state = [0, 1, 2] # 3 variants
158
+
159
+ [[models]] # 2 × 2 = 4 model variants
160
+ target = "sklearn.ensemble.RandomForestClassifier"
161
+ sweep.criterion = ["gini", "entropy"] # 2 variants
162
+ sweep.max_depth = [5, 10] # 2 variants
163
+
164
+ [[metrics]]
165
+ target = "sklearn.metrics.fbeta_score"
166
+ average = "macro"
167
+ sweep.beta = [0.5, 1.0, 2.0] # 3 variants
168
+ ```
169
+
170
+ This produces 3 × 4 = 12 jobs total. For each job, 3 metrics are computed ($F_\beta$ for all $\beta \in \{0.5, 1.0, 2.0\}$).
171
+
172
+ ### Results
173
+
174
+ Results are written to:
175
+
176
+ ```
177
+ {path-to-results}/raw/{experiment_name}/YYYYMMDD-HHMMSS.csv
178
+ ```
179
+
180
+ Columns are the union of all keys returned by `runner()`, plus `Dataset` and `Model` metadata columns. If a key appears in both data loader and model kwargs, it is prefixed with `Dataset.` / `Model.` to avoid collision.
181
+
182
+ Run `python script.py --help` for the full list of options.
183
+
184
+ ### Roadmap
185
+
186
+ This project is in early development, and many changes are still expected. However, the main interface should remain stable. Go to the [issue page](https://github.com/LouisCarpentier42/Chronobench/issues) for an overview of the tasks we plan to add in the near future.
@@ -0,0 +1,66 @@
1
+ [project]
2
+ name = "chronobench"
3
+ version = "0.1.1"
4
+ authors = [
5
+ {name = "Louis Carpentier", email = "louis.carpentier@kuleuven.be"}
6
+ ]
7
+ readme = "README.md"
8
+ requires-python = ">=3.11"
9
+ dependencies = []
10
+
11
+ [project.optional-dependencies]
12
+ tqdm = [
13
+ "tqdm",
14
+ ]
15
+ simple-example = [
16
+ "scikit-learn>=1.3",
17
+ ]
18
+
19
+ [dependency-groups]
20
+ dev = [
21
+ "mypy>=1.19.1",
22
+ "pre-commit>=4.5.1",
23
+ "python-dotenv>=1.2.2",
24
+ "ruff>=0.14.11",
25
+ "numpydoc>=1.5.0",
26
+ ]
27
+ test = [
28
+ "pytest>=9.0.3",
29
+ "pytest-cov>=6.0.0",
30
+ ]
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
34
+
35
+ [tool.uv]
36
+ package = true
37
+
38
+ [tool.numpydoc_validation]
39
+ checks = [
40
+ "all",
41
+ "SA01", # See Also section not required
42
+ "EX01", # Examples section not required
43
+ ]
44
+ exclude = [
45
+ '\._', # Ignore private objects
46
+ ]
47
+
48
+ [[tool.mypy.overrides]]
49
+ module = [
50
+ "sklearn.*",
51
+ "tqdm.*",
52
+ "aeon.*",
53
+ "pytest.*",
54
+ ]
55
+ ignore_missing_imports = true
56
+
57
+ [tool.pytest.ini_options]
58
+ addopts = "--cov=chronobench --cov-report=term-missing --cov-report=html"
59
+
60
+ [tool.coverage.run]
61
+ source = ["src/chronobench"]
62
+ omit = ["src/chronobench/__init__.py"]
63
+
64
+ [tool.coverage.report]
65
+ show_missing = true
66
+ skip_covered = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ """
2
+ Chronobench: a registry-driven framework for benchmarking machine learning experiments.
3
+ """
4
+
5
+ from ._main import main
6
+ from .context import Context
7
+ from .registry import data_loaders, metrics, models, runner
8
+
9
+ __all__ = [
10
+ "main",
11
+ "Context",
12
+ "data_loaders",
13
+ "models",
14
+ "metrics",
15
+ "runner",
16
+ ]
@@ -0,0 +1,61 @@
1
+ """
2
+ Entry point that dispatches CLI arguments to the appropriate execution mode.
3
+ """
4
+
5
+ from . import registry
6
+ from .modes.dry_run import main as main_dry_run
7
+ from .modes.run_many import main as main_run_many
8
+ from .utility.loading import load_environment, load_experiment_dict
9
+ from .utility.parsing_arguments import parse_args
10
+
11
+ __all__ = ["main"]
12
+
13
+
14
+ def main():
15
+ """
16
+ Run chronobench from the command line using the registered components.
17
+
18
+ This is the primary public API. Before calling it, register your data
19
+ loaders, models, and metrics on the module-level registries and mark your
20
+ training loop with :func:`chronobench.runner`::
21
+
22
+ import chronobench as cb
23
+ from src.loaders import IrisLoader
24
+
25
+ cb.data_loaders.register(iris=IrisLoader)
26
+
27
+ @cb.runner
28
+ def runner(data_loader, model, metrics):
29
+ ...
30
+
31
+ cb.main()
32
+
33
+ Experiment TOML entries select an implementation with either a registered
34
+ ``name`` or a dotted ``target`` import path, so stock library classes (e.g.
35
+ ``sklearn.svm.SVC``) can be used without a wrapper. ``main()`` reads the
36
+ registries and the registered runner directly; nothing is passed to it.
37
+ """
38
+ args = parse_args()
39
+ environment = load_environment(args.environment)
40
+ experiments = load_experiment_dict(environment, args.experiments)
41
+
42
+ if args.dry_run:
43
+ if args.debug:
44
+ print("Warning: --debug has no effect in dry-run mode.")
45
+ main_dry_run(
46
+ experiments=experiments,
47
+ data_loaders=registry.data_loaders,
48
+ models=registry.models,
49
+ metrics=registry.metrics,
50
+ environment=environment,
51
+ )
52
+ else:
53
+ main_run_many(
54
+ experiments=experiments,
55
+ debug=args.debug,
56
+ data_loaders=registry.data_loaders,
57
+ models=registry.models,
58
+ metrics=registry.metrics,
59
+ runner=registry.get_runner(),
60
+ environment=environment,
61
+ )
@@ -0,0 +1,42 @@
1
+ """
2
+ Context dataclass passed to user-supplied initializer callbacks.
3
+ """
4
+
5
+ from dataclasses import dataclass
6
+
7
+
8
+ @dataclass
9
+ class Context:
10
+ """
11
+ Cross-initializer context passed progressively to each callback.
12
+
13
+ The context is populated in stages as initialization proceeds:
14
+
15
+ - ``initialize_data_loaders`` receives ``Context()`` (all fields ``None``).
16
+ - ``initialize_models`` receives a ``Context`` with the data-loader fields set.
17
+ - ``initialize_metrics`` receives a fully populated ``Context``.
18
+
19
+ Attributes
20
+ ----------
21
+ data_loader : object, optional
22
+ The instantiated data loader for the current job.
23
+ data_loader_name : str, optional
24
+ The name of the current data loader as defined in the experiment
25
+ configuration.
26
+ data_loader_kwargs : dict, optional
27
+ The keyword arguments used to instantiate the current data loader.
28
+ model : object, optional
29
+ The instantiated model for the current job.
30
+ model_name : str, optional
31
+ The name of the current model as defined in the experiment
32
+ configuration.
33
+ model_kwargs : dict, optional
34
+ The keyword arguments used to instantiate the current model.
35
+ """
36
+
37
+ data_loader: object | None = None
38
+ data_loader_name: str | None = None
39
+ data_loader_kwargs: dict | None = None
40
+ model: object | None = None
41
+ model_name: str | None = None
42
+ model_kwargs: dict | None = None