WandbCacheCleanupCallback#

class WandbCacheCleanupCallback(*args, **kwargs)#

Bases: Callback

Periodically run wandb artifact cache cleanup to cap local cache size.

Parameters:
  • max_cache_size (str) – Size cap passed to the W&B CLI, e.g., “10GB”, “5GB”.

  • every_n_epochs (int) – Run cleanup when (current_epoch + 1) % N == 0.

  • run_on_fit_start (bool) – If True, also run once at fit start.

  • only_on_global_rank_zero (bool) – If True, only run on rank 0 in DDP.

  • executable (str) – CLI executable name/path for wandb (default: “wandb”).

  • extra_env (Mapping[str, str] | None) – Optional environment overrides for the subprocess.

  • background (bool) – If True, run non-blocking via background thread + Popen.

  • timeout (int | None) – Optional timeout (seconds) for blocking mode.

__init__(
max_cache_size='5GB',
every_n_epochs=1,
run_on_fit_start=False,
only_on_global_rank_zero=True,
executable='wandb',
extra_env=None,
background=True,
timeout=None,
)#

Initializes the WandbCacheCleanupCallback.

Parameters:
  • max_cache_size (str)

  • every_n_epochs (int)

  • run_on_fit_start (bool)

  • only_on_global_rank_zero (bool)

  • executable (str)

  • extra_env (Mapping[str, str] | None)

  • background (bool)

  • timeout (int | None)

Return type:

None

on_fit_start(trainer, pl_module)#

Runs cleanup at the start of fitting.

Parameters:
  • trainer (pytorch_lightning.Trainer)

  • pl_module (pytorch_lightning.LightningModule)

Return type:

None

on_train_epoch_end(trainer, pl_module)#

Runs cleanup at the end of each training epoch.

Parameters:
  • trainer (pytorch_lightning.Trainer)

  • pl_module (pytorch_lightning.LightningModule)

Return type:

None