Skip to content

Commit 6594dea

Browse files
authored
Merge pull request #127 from anagainaru/cleanup
Remove deprecated code and clean up the configuration options
2 parents e85a013 + a93fad8 commit 6594dea

12 files changed

Lines changed: 14 additions & 43 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,16 @@ poetry run mypy .
2929
The installable package lives under `src/apeiron/` (imported as `apeiron`; see `pyproject.toml` `packages = [{ include = "apeiron", from = "src" }]`).
3030

3131
### Core Pipeline
32-
1. **Config** (`src/apeiron/config/configuration.py`): TOML-based config parsed into frozen dataclasses (`Config`, `ModelCfg`, `DataCfg`, `TrainCfg`, `ContinualLearningCfg`, `DriftDetectionCfg`, `LoggingCfg`, `VisualizationCfg`). Supports `--set key=val` CLI overrides and `APP_` env var overrides.
32+
1. **Config** (`src/apeiron/config/configuration.py`): TOML-based config parsed into frozen dataclasses (`Config`, `ModelCfg`, `DataCfg`, `TrainCfg`, `ContinualLearningCfg`, `DriftDetectionCfg`, `LoggingCfg`). Supports `--set key=val` CLI overrides and `APP_` env var overrides.
3333
2. **Model Harness** (`src/apeiron/model/torch_model_harness.py`): Abstract `BaseModelHarness` providing `get_stream_dataloader()`, `get_train_dataloaders()`, `get_hist_dataloaders()`, `update_data_stream()`, `get_criterion()`, `get_optmizer()`, and `eval_metrics` dict. Also keeps a per-task registry for transfer metrics -- `register_task()`, `eval_past_tasks()`, `task_diagonals` -- which subclasses inherit unchanged (see `docs/tracking.md` "Transfer Metrics").
3434
3. **Driver** (`src/apeiron/driver/continuous_monitor.py`): `ContinuousMonitor` orchestrates the monitoring loop -- evaluates batches, checks drift at intervals, dispatches CL training on drift.
3535
4. **Drift Detection** (`src/apeiron/drift_detection/`): `BaseDriftDetector` ABC with `update(value) -> DriftSignal`. Implementations: ADWINDetector, KSWINDetector, PageHinkleyDetector, ModelPerformanceDetector, ModelEvalDetector, EnsembleDetector.
3636
5. **Training** (`src/apeiron/training/continuous_trainer.py`): `ContinuousTrainer` runs outer/inner CL loops with gradient accumulation.
3737
6. **Updaters** (`src/apeiron/training/updater/`): `BaseUpdater` with hooks `cl_preprocessing()`, `fwd_bwd()`, `update_pre_fwd_bwd()`, `update_post_fwd_bwd()`, `update_post_optimizer_call()`, `cl_postprocessing()`. Implementations: base (vanilla), jvp_reg (JVP updater -- now a first-order SAM robust update), ewc_online (EWC), kfac_online (KFAC), none (no-op).
3838
7. **Evaluation** (`src/apeiron/evaluation/metrics.py`): `accuracy()` and `accuracy_topk()`.
39-
8. **Logger** (`src/apeiron/logger/`): `Logger` with pluggable metrics backends -- `WandBLogger` and `MLFlowLogger` (configured via `[logging] backend = "wandb"|"mlflow"|"none"`), plus console output. Stages: eval, drift, cl.
39+
8. **Logger** (`src/apeiron/logger/`): `Logger` with pluggable metrics backends -- `WandBLogger` and `MLFlowLogger` (configured via `[logging] backend = "wandb"|"mlflow"|"none"`), plus console output. Stages: eval, drift, cl. Metrics are written to a CSV file at `[logging] metrics_output_path` for external analysis.
4040
9. **Profilers** (`src/apeiron/profilers/`): `FLOPSProfiler` (`count_flops.py`) using PyTorch FlopCounterMode.
4141

42-
Note: `[visualization]` config (`VisualizationCfg`) is parsed but there is no bundled dashboard/renderer in the current package; runs emit a CSV at `visualization.input` for external plotting.
43-
4442
### Example Harnesses
4543
- `examples/mnist/model.py`: `MNIST_CNN` -- CNN on MNIST with affine drift simulation.
4644
- `examples/cifar/model.py`: `CIFAR_VISION` -- ViT/VGG on CIFAR-10 with affine drift.
@@ -49,7 +47,7 @@ Note: `[visualization]` config (`VisualizationCfg`) is parsed but there is no bu
4947

5048
### Configuration Format (TOML)
5149
Required sections: `[model]` (name, pretrained_path), `[data]` (name, path), `[train]` (batch_size, num_workers, init_lr), `[drift_detection]` (detector_name, detection_interval, etc).
52-
Optional sections: `[continual_learning]` (update_mode, lambda params), `[logging]` (backend = "wandb"|"mlflow"|"none", experiment_name, mlflow_tracking_uri), `[visualization]` (baseline, input, output -- parsed but not rendered by the package).
50+
Optional sections: `[continual_learning]` (update_mode, lambda params), `[logging]` (backend = "wandb"|"mlflow"|"none", experiment_name, mlflow_tracking_uri, metrics_output_path).
5351
Top-level keys: `seed`, `device` ("auto"|"cpu"|"cuda"|"mps"), `multi_gpu`.
5452

5553
### Available Drift Detectors

examples/cifar/cifar10_vgg11.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ adwin_delta = 0.002
4646
adwin_minor_threshold = 0.3
4747
adwin_moderate_threshold = 0.6
4848

49-
[visualization]
50-
input = "output/cifar.csv"
49+
[logging]
50+
metrics_output_path = "output/cifar.csv"

examples/cifar/cifar10_vit.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ adwin_delta = 0.002
4747
adwin_minor_threshold = 0.3
4848
adwin_moderate_threshold = 0.6
4949

50-
[visualization]
51-
input = "output/cifar.csv"
50+
[logging]
51+
metrics_output_path = "output/cifar.csv"

examples/mnist/mnist.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,4 @@ adwin_moderate_threshold = 0.6
5858
backend = "wandb" # "wandb", "mlflow", or "none"
5959
experiment_name = "mnist-continual-learning" # Optional: project/experiment name
6060
# mlflow_tracking_uri = "http://localhost:5000" # Optional: MLflow tracking server
61-
62-
[visualization]
63-
input = "output/mnist.csv"
61+
metrics_output_path = "output/mnist.csv"

src/apeiron/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
TrainCfg,
88
ContinualLearningCfg,
99
DriftDetectionCfg,
10-
VisualizationCfg,
1110
LoggingCfg,
1211
build_config,
1312
)
@@ -35,7 +34,6 @@
3534
"TrainCfg",
3635
"ContinualLearningCfg",
3736
"DriftDetectionCfg",
38-
"VisualizationCfg",
3937
"LoggingCfg",
4038
"build_config",
4139
"BaseModelHarness",

src/apeiron/config/configuration.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,14 @@ def __post_init__(self) -> None:
182182
object.__setattr__(self, "ensemble_detectors", tuple(names))
183183

184184

185-
@dataclass(frozen=True)
186-
class VisualizationCfg:
187-
input: str = "output/output.csv" # CSV path where run metrics are written
188-
189-
190185
@dataclass(frozen=True)
191186
class LoggingCfg:
192-
backend: MetricsBackend = "wandb" # "wandb", "mlflow", or "none"
187+
backend: MetricsBackend = "none" # "wandb", "mlflow", or "none"
193188
experiment_name: str | None = (
194189
None # Project name for WandB/Experiment name for MLflow
195190
)
196191
mlflow_tracking_uri: str | None = None # MLflow tracking server URI
192+
metrics_output_path: str | None = None # CSV path where run metrics are written
197193

198194

199195
@dataclass(frozen=True)
@@ -208,7 +204,6 @@ class Config:
208204
device: str
209205
multi_gpu: bool = False
210206
verbosity: str = "INFO"
211-
visualization: VisualizationCfg | None = None
212207
logging: LoggingCfg | None = None
213208

214209

@@ -362,7 +357,6 @@ def build_config(argv=None) -> Config:
362357
train = TrainCfg(**cfg["train"])
363358
dd = DriftDetectionCfg(**cfg["drift_detection"])
364359
cl = ContinualLearningCfg(**cfg.get("continual_learning", {}))
365-
viz = VisualizationCfg(**cfg["visualization"]) if "visualization" in cfg else None
366360
log_cfg = LoggingCfg(**cfg["logging"]) if "logging" in cfg else None
367361

368362
raw_device = str(
@@ -385,7 +379,6 @@ def build_config(argv=None) -> Config:
385379
"train",
386380
"continual_learning",
387381
"drift_detection",
388-
"visualization",
389382
"logging",
390383
"device",
391384
"multi_gpu",
@@ -400,7 +393,6 @@ def build_config(argv=None) -> Config:
400393
train=train,
401394
continual_learning=cl,
402395
drift_detection=dd,
403-
visualization=viz,
404396
logging=log_cfg,
405397
device=resolved_device,
406398
multi_gpu=multi_gpu_flag,

src/apeiron/logger/logger.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,14 @@ def __init__(
2424
verbosity: str = "INFO",
2525
backend: MetricsBackend = "wandb",
2626
csv_path: str | Path | None = None,
27-
# Legacy parameter for backwards compatibility
28-
wandb_enabled: bool | None = None,
2927
):
3028
"""Initialize unified logger.
3129
3230
Args:
3331
verbosity: Console level (DEBUG, INFO, INFO:n, WARNING, ERROR, CRITICAL)
3432
backend: Metrics backend to use ("wandb", "mlflow", or "none")
3533
csv_path: Save metrics to CSV at this path (disabled if None)
36-
wandb_enabled: Deprecated. Use backend="wandb" or backend="none" instead.
3734
"""
38-
# Handle legacy wandb_enabled parameter
39-
if wandb_enabled is not None:
40-
backend = "wandb" if wandb_enabled else "none"
4135

4236
# Initialize metrics backend
4337
if backend == "mlflow":
@@ -163,16 +157,13 @@ def get_logger(
163157
verbosity: str = "INFO",
164158
backend: MetricsBackend = "wandb",
165159
csv_path: str | Path | None = None,
166-
# Legacy parameter for backwards compatibility
167-
wandb_enabled: bool | None = None,
168160
) -> Logger:
169161
"""Get or create the default Logger instance.
170162
171163
Args:
172164
verbosity: Console level (DEBUG, INFO, INFO:n, WARNING, ERROR, CRITICAL)
173165
backend: Metrics backend to use ("wandb", "mlflow", or "none")
174166
csv_path: Save metrics to CSV at this path (disabled if None)
175-
wandb_enabled: Deprecated. Use backend="wandb" or backend="none" instead.
176167
177168
Returns:
178169
Logger instance
@@ -183,7 +174,6 @@ def get_logger(
183174
verbosity=verbosity,
184175
backend=backend,
185176
csv_path=csv_path,
186-
wandb_enabled=wandb_enabled,
187177
)
188178
return _default_logger
189179

src/cl_only.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ def main(argv: list[str] | None = None) -> int:
578578
logger = get_logger(
579579
verbosity=cfg.verbosity,
580580
backend=backend,
581-
csv_path=cfg.visualization.input if cfg.visualization else None,
581+
csv_path=cfg.logging.metrics_output_path if cfg.logging else None,
582582
)
583583

584584
project_name = "basesim-framework"

src/drift_only.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def main(argv: list[str] | None = None) -> int:
355355
logger = get_logger(
356356
verbosity=cfg.verbosity,
357357
backend=backend,
358-
csv_path=cfg.visualization.input if cfg.visualization else None,
358+
csv_path=cfg.logging.metrics_output_path if cfg.logging else None,
359359
)
360360

361361
project_name = "basesim-framework"

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def main(argv: list[str] | None = None) -> int:
1717
logger = get_logger(
1818
verbosity=cfg.verbosity,
1919
backend=backend,
20-
csv_path=cfg.visualization.input if cfg.visualization else None,
20+
csv_path=cfg.logging.metrics_output_path if cfg.logging else None,
2121
)
2222

2323
modelHarness = get_example(cfg=cfg)

0 commit comments

Comments
 (0)