wandb: [CLI]: initializing twice leads to `AttributeError: 'Run' object has no attribute '_telemetry_obj'.`

Describe the bug

Description

Starting from wandb==0.17.6, I noticed an issue that if I initialize twice as run = wandb.init(mode="disabled") I get AttributeError: 'Run' object has no attribute '_telemetry_obj'.

Ordinary mode, i.e., run = wandb.init() can be called many times.

Up until 0.17.5, run = wandb.init(mode="disabled") returned an instance of RunDisabled. This seems to have changed from 0.17.6.

Steps to reproduce the issue

import wandb
run = wandb.init(mode="disabled")
run = wandb.init(mode="disabled")

Traceback

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ryoto/conda/envs/materials/lib/python3.10/site-packages/wandb/sdk/wandb_init.py", line 1191, in init
    wandb._sentry.reraise(e)
  File "/home/ryoto/conda/envs/materials/lib/python3.10/site-packages/wandb/analytics/sentry.py", line 155, in reraise
    raise exc.with_traceback(sys.exc_info()[2])
  File "/home/ryoto/conda/envs/materials/lib/python3.10/site-packages/wandb/sdk/wandb_init.py", line 1176, in init
    wi.setup(kwargs)
  File "/home/ryoto/conda/envs/materials/lib/python3.10/site-packages/wandb/sdk/wandb_init.py", line 211, in setup
    with telemetry.context(obj=self._init_telemetry_obj) as tel:
  File "/home/ryoto/conda/envs/materials/lib/python3.10/site-packages/wandb/sdk/lib/telemetry.py", line 43, in __exit__
    self._run._telemetry_callback(self._obj)
  File "/home/ryoto/conda/envs/materials/lib/python3.10/site-packages/wandb/sdk/wandb_run.py", line 799, in _telemetry_callback
    self._telemetry_obj.MergeFrom(telem_obj)
AttributeError: 'Run' object has no attribute '_telemetry_obj'. Did you mean: '_telemetry_flush'?

Additional Files

No response

Environment

WandB version: 0.17.6 OS: Ubuntu 22.04

Python version: 3.10

Versions of relevant libraries:

Additional Context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 9
  • Comments: 28

Most upvoted comments

Last working version is wandb==0.17.5 for wandb.init(mode=“disabled”)

Both wandb==0.17.6 and wandb==0.17.7 need tedious workarounds.

@kptkin With 0.17.8 the error message changes, but it is still broken. Please reopen.

predictors.py:138: in train
    with wandb.init(job_type="train", **wandb_kwargs) as run:
.venv/lib/python3.12/site-packages/wandb/sdk/wandb_run.py:3616: in __exit__
    self._finish(exit_code=exit_code)
.venv/lib/python3.12/site-packages/wandb/sdk/wandb_run.py:2173: in _finish
    if self._wl and len(self._wl._global_run_stack) > 0:
E   AttributeError: 'Run' object has no attribute '_wl'

I am also getting this with wandb.init(mode='disabled') and wandb 0.17.7

Me too, same error in 0.17.7.

Jason Davenport commented: Would you mind updating your client to the latest version (0.17.7) and giving it a try? We’re hopeful this should resolve the issue for you, but if you’re still experiencing any problems after the update, please don’t hesitate to let me know. I’m here to help make sure everything’s running smoothly for you.Looking forward to hearing how it goes!

0.17.7 is ok!

Still experiencing the same error with WANDB_MODE=disabled and 0.17.7.

Jason Davenport commented: I wanted to update here an ensure everyone this has been fixed. Please let us know if you run into any more issues here. Thanks!

Same, upgrading to 0.17.7 did not fix it when using wandb.init(mode='disabled'). Currently i have the following snipped in my tests to mock it out explicitly.

from unittest import mock
from unittest.mock import Mock
class Dummy:
    def __enter__(self):
        return Mock()

    def __exit__(self, *args):
        pass

with mock.patch('wandb.init', return_value=Dummy()):
    # run whatever code you want to test that uses wandb.init to track experiments

can ok?use 0.17.7?

test ok!

BTW: Is there any rational behind the weird API funneling everything through wand.init and having static global variables all over the place? Seems like a super smelly design decision 😄.