Config¶
danling.runner.config
¶
Config
¶
Bases: Config
Configuration class for managing and persisting all states of a DanLing Runner.
The Config class provides a hierarchical configuration system that handles:
- Parameter management: Hyperparameters, model settings, training options
- Experiment tracking: IDs, names, and other metadata for runs and experiments
- Serialization: Save/load configurations from files or command line
- Reproducibility: Tracking seeds and settings for reproducible runs
Config inherits from Config
and provides attribute-style access to nested values:
Python | |
---|---|
Config objects support three types of hierarchical attribute access patterns:
-
Direct assignment for simple values:
Python -
Auto-created nested objects for hierarchical settings:
-
Class-level annotations for typed properties with defaults:
Command-line integration is built-in. You can define a configuration and then override values via command line arguments:
General:
Name | Type | Description |
---|---|---|
run_name |
str
|
Human-readable name for this run. Defaults to |
run_id |
str
|
Unique identifier (hex string) for this run, derived from |
run_uuid |
(UUID, property)
|
Unique UUID generated from experiment_uuid and config hash. |
experiment_name |
str
|
Human-readable name for the experiment. Defaults to |
experiment_id |
str
|
Unique identifier for experiment, typically the git commit hash.
Defaults to |
experiment_uuid |
(UUID, property)
|
UUID derived from |
Reproducibility:
Name | Type | Description |
---|---|---|
seed |
int
|
Random seed for reproducibility. If not set, a random value is generated. |
deterministic |
bool
|
Whether to enforce deterministic operations in PyTorch.
Defaults to |
Progress:
Name | Type | Description |
---|---|---|
steps |
int
|
Current training step count. |
epochs |
int
|
Current epoch count. |
step_begin |
int
|
First step to run (for resuming). Defaults to 0. |
epoch_begin |
int
|
First epoch to run (for resuming). Defaults to 0. |
step_end |
int
|
Last step to run (optional). Use either this or |
epoch_end |
int
|
Last epoch to run (optional). Use either this or |
Model Evaluation:
Name | Type | Description |
---|---|---|
score_split |
str
|
Dataset split to use for model selection. Defaults to None. |
score_name |
str
|
Metric name to use for model selection. Defaults to “loss”. |
I/O:
Name | Type | Description |
---|---|---|
project_root |
str
|
Root directory for experiments. Defaults to |
checkpoint_dir_name |
str
|
Subdirectory name for checkpoints. Defaults to |
log |
bool
|
Whether to enable file logging. Defaults to |
tensorboard |
bool
|
Whether to use TensorBoard for visualization. Defaults to |
log_interval |
int
|
Iterations between log outputs. If None, auto-calculated. |
save_interval |
int
|
Epochs between checkpoint saves. If None, only save best/latest. |
Examples:
Basic usage:
Python | |
---|---|
Custom config class with typed attributes:
Command-line integration:
Bash | |
---|---|
Note
Always store all parameters needed to reproduce a run in the Config. The Config is automatically saved with checkpoints, enabling exact resumption.
See Also
Runner
: Main runner class that uses this config.chanfig.Config
: Base config implementation.
Source code in danling/runner/config.py
Python | |
---|---|
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|