wandb_setup
wandb_setup
¶
WandB integration for Safe Synthesizer.
This module provides WandB (Weights & Biases) integration for experiment tracking, including run initialization, configuration logging, and failure reporting.
Classes:
| Name | Description |
|---|---|
WandbMode |
WandB run mode. |
WandbPhase |
Phase of the Safe Synthesizer pipeline. |
WandbSettings |
WandB configuration for Safe Synthesizer. |
Functions:
| Name | Description |
|---|---|
resolve_wandb_run_id |
Resolve a wandb run ID from a string or file path. |
log_failure_to_wandb |
Log failure to wandb before exiting. |
update_wandb_config |
Update the wandb config with the given configuration. |
initialize_wandb_run |
Initialize or resume a wandb run with consistent configuration. |
WandbMode
¶
Bases: str, Enum
WandB run mode.
WandbPhase
¶
Bases: str, Enum
Phase of the Safe Synthesizer pipeline.
WandbSettings
¶
Bases: BaseSettings
WandB configuration for Safe Synthesizer.
All settings can be configured via environment variables.
Methods:
| Name | Description |
|---|---|
validate_wandb_mode |
Coerce string or None to |
validate_phase |
Coerce string or None to |
Attributes:
| Name | Type | Description |
|---|---|---|
wandb_mode |
WandbMode
|
Run mode, one of online, offline, or disabled (env variable: |
wandb_project |
str | None
|
WandB project name override (env variable: |
exp_name |
str
|
Fallback project name when |
phase |
WandbPhase
|
Current pipeline phase for WandB grouping. |
effective_wandb_project |
str
|
Effective wandb project name, falling back to |
wandb_mode = Field(default=(WandbMode.DISABLED), description='Run mode, one of online, offline, or disabled.', validation_alias=(AliasChoices('WANDB_MODE', 'NSS_WANDB_MODE')))
class-attribute
instance-attribute
¶
Run mode, one of online, offline, or disabled (env variable: WANDB_MODE or NSS_WANDB_MODE).
wandb_project = Field(default=None, description='WandB project name override.', validation_alias=(AliasChoices('WANDB_PROJECT', 'NSS_WANDB_PROJECT')))
class-attribute
instance-attribute
¶
WandB project name override (env variable: WANDB_PROJECT or NSS_WANDB_PROJECT).
exp_name = Field(default='nss_experiments', description='Fallback project name when ``wandb_project`` is not set.')
class-attribute
instance-attribute
¶
Fallback project name when wandb_project is not set.
phase = Field(default=(WandbPhase.UNKNOWN), description='Current pipeline phase for WandB grouping.')
class-attribute
instance-attribute
¶
Current pipeline phase for WandB grouping.
effective_wandb_project
property
¶
Effective wandb project name, falling back to exp_name.
validate_wandb_mode(v)
classmethod
¶
Coerce string or None to WandbMode enum, defaulting to DISABLED.
Source code in src/nemo_safe_synthesizer/cli/wandb_setup.py
validate_phase(v)
classmethod
¶
Coerce string or None to WandbPhase, defaulting to UNKNOWN.
Source code in src/nemo_safe_synthesizer/cli/wandb_setup.py
resolve_wandb_run_id(id_or_path)
¶
Resolve a wandb run ID from a string or file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_or_path
|
str
|
Either a wandb run ID string, or a path to a file containing the ID. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The resolved wandb run ID. |
Source code in src/nemo_safe_synthesizer/cli/wandb_setup.py
log_failure_to_wandb(error, phase)
¶
Log failure to wandb before exiting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
error
|
Exception
|
The exception that caused the failure |
required |
phase
|
str
|
The phase where failure occurred (e.g., "train", "generation", "end_to_end") |
required |
Source code in src/nemo_safe_synthesizer/cli/wandb_setup.py
update_wandb_config(cfg=None, additional_configs=None)
¶
Update the wandb config with the given configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
SafeSynthesizerParameters | None
|
SafeSynthesizerParameters to log |
None
|
additional_configs
|
dict[str, Any] | None
|
Additional key-value pairs to log |
None
|
Source code in src/nemo_safe_synthesizer/cli/wandb_setup.py
initialize_wandb_run(workdir, resume_job_id=None, cfg=None)
¶
Initialize or resume a wandb run with consistent configuration.
This function handles four cases (in priority order): 1. WandB already initialized - just save the run ID 2. Explicit resume_job_id provided - resume that run (ID or file path) 3. Resume existing run from saved run_id file in workdir 4. Create new run
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workdir
|
Workdir
|
Workdir structure containing paths for run ID files |
required |
resume_job_id
|
str | None
|
Optional wandb run ID or path to file containing the ID |
None
|
cfg
|
SafeSynthesizerParameters | None
|
Optional SafeSynthesizerParameters to log to wandb config |
None
|
Source code in src/nemo_safe_synthesizer/cli/wandb_setup.py
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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |