disabled.py 963 B

123456789101112131415161718192021222324252627282930
  1. from typing import Any
  2. class SummaryDisabled(dict):
  3. __setattr__ = dict.__setitem__
  4. __delattr__ = dict.__delitem__
  5. def __getattr__(self, key):
  6. return self[key]
  7. def __getitem__(self, key):
  8. val = dict.__getitem__(self, key)
  9. if isinstance(val, dict) and not isinstance(val, SummaryDisabled):
  10. val = SummaryDisabled(val)
  11. self[key] = val
  12. return val
  13. class RunDisabled:
  14. """Compatibility class for integrations that explicitly check for wandb.RunDisabled."""
  15. def __getattr__(self, name: str) -> Any:
  16. from wandb.proto.wandb_telemetry_pb2 import Deprecated
  17. from wandb.sdk.lib.deprecation import warn_and_record_deprecation
  18. warn_and_record_deprecation(
  19. feature=Deprecated(run_disabled=True),
  20. message="RunDisabled is deprecated and is a no-op. "
  21. '`wandb.init(mode="disabled")` now returns an instance of `wandb.Run`.',
  22. )