wandb: Logging results to Weights & Biases. Couldn't load entity due to error: Can't connect to network to query entity from API key

  • Weights and Biases version: 0.8.15
  • Python version: 3.7.4
  • Operating System: Windows 10

Description

I updated the library and logged into wandb successfully through cli. I tried importing this snippet of code:

from wandb.keras import WandbCallback
wandb.init(project="my_project_name")

into my jupyter notebook and when I run all of my cells sequentially, I get this error:

AttributeError                            Traceback (most recent call last)
C:\Python37\lib\site-packages\wandb\meta.py in setup(self)
     46             import __main__
---> 47             self.data["program"] = __main__.__file__
     48         except (ImportError, AttributeError):

AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
 in 
      1 import wandb
      2 from wandb.keras import WandbCallback
----> 3 wandb.init(project="my_project_name")

C:\Python37\lib\site-packages\wandb\__init__.py in init(job_type, dir, config, project, entity, reinit, tags, group, allow_val_change, resume, force, tensorboard, sync_tensorboard, monitor_gym, name, notes, id, magic, anonymous)
   1068         allow_val_change = True
   1069     if config or telemetry_updated:
-> 1070         run.config._update(config, allow_val_change=allow_val_change, as_defaults=not allow_val_change)
   1071 
   1072     # Access history to ensure resumed is set when resuming

C:\Python37\lib\site-packages\wandb\wandb_config.py in _update(self, params, allow_val_change, as_defaults)
    276                 continue
    277             self._items[key] = val
--> 278         self.persist()
    279 
    280     def update(self, params, allow_val_change=False):

C:\Python37\lib\site-packages\wandb\wandb_config.py in persist(self)
    194             conf_file.write(str(self))
    195         if wandb.run and wandb.run._jupyter_agent:
--> 196             wandb.run._jupyter_agent.start()
    197 
    198     def get(self, *args):

C:\Python37\lib\site-packages\wandb\jupyter.py in start(self)
    120     def start(self):
    121         if self.paused:
--> 122             self.rm = RunManager(wandb.run, output=False, cloud=wandb.run.mode != "dryrun")
    123             wandb.run.api._file_stream_api = None
    124             self.rm.mirror_stdout_stderr()

C:\Python37\lib\site-packages\wandb\run_manager.py in __init__(self, run, project, tags, cloud, output, port)
    504         # Calling .start() on _meta and _system_stats will spin a thread that reports system stats every 30 seconds
    505         self._system_stats = stats.SystemStats(run, self._api)
--> 506         self._meta = meta.Meta(self._api, self._run.dir)
    507         self._meta.data["jobType"] = self._run.job_type
    508         self._meta.data["mode"] = self._run.mode

C:\Python37\lib\site-packages\wandb\meta.py in __init__(self, api, out_dir)
     34             self.data = {}
     35         self.lock = threading.Lock()
---> 36         self.setup()
     37         self._thread = threading.Thread(target=self._thread_body)
     38         self._thread.daemon = True

C:\Python37\lib\site-packages\wandb\meta.py in setup(self)
     52                     self.data["program"] = os.getenv(env.NOTEBOOK_NAME)
     53                 else:
---> 54                     meta = wandb.jupyter.notebook_metadata()
     55                     if meta.get("path"):
     56                         if "fileId=" in meta["path"]:

C:\Python37\lib\site-packages\wandb\jupyter.py in notebook_metadata()
    108             if isinstance(nn, dict) and nn.get("kernel"):
    109                 if nn['kernel']['id'] == kernel_id:
--> 110                     return {"root": s['notebook_dir'], "path": nn['notebook']['path'], "name": nn['notebook']['name']}
    111     return {}
    112 

KeyError: 'notebook'

What I Did

pip install --upgrade wandb
wandb login <insert token>


import wandb
from wandb.keras import WandbCallback
wandb.init(project="my_project_name")


About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

@jwanga Sorry about that. I had updated my wandb package but not jupyter. So I updated and restarted jupyter and now it is working.

@ajay340 set enitity to your username when you call wandb.init

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.92. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@vanpelt

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/wandb/meta.py in setup(self)
     46             import __main__
---> 47             self.data["program"] = __main__.__file__
     48         except (ImportError, AttributeError):

AttributeError: module '__main__' has no attribute '__file__'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
 in 
      3 get_ipython().system(' wandb login 12121212121212121212121212121212121')
----> 4 wandb.init(project="project-name", entity="username")

/usr/local/lib/python3.7/site-packages/wandb/__init__.py in init(job_type, dir, config, project, entity, reinit, tags, group, allow_val_change, resume, force, tensorboard, sync_tensorboard, monitor_gym, name, notes, id, magic, anonymous)
   1084         allow_val_change = True
   1085     if config or telemetry_updated:
-> 1086         run.config._update(config, allow_val_change=allow_val_change, as_defaults=not allow_val_change)
   1087 
   1088     # Access history to ensure resumed is set when resuming

/usr/local/lib/python3.7/site-packages/wandb/wandb_config.py in _update(self, params, allow_val_change, as_defaults)
    277                 continue
    278             self._items[key] = val
--> 279         self.persist()
    280 
    281     def update(self, params, allow_val_change=False):

/usr/local/lib/python3.7/site-packages/wandb/wandb_config.py in persist(self)
    195             conf_file.write(str(self))
    196         if wandb.run and wandb.run._jupyter_agent:
--> 197             wandb.run._jupyter_agent.start()
    198 
    199     def get(self, *args):

/usr/local/lib/python3.7/site-packages/wandb/jupyter.py in start(self)
    120     def start(self):
    121         if self.paused:
--> 122             self.rm = RunManager(wandb.run, output=False, cloud=wandb.run.mode != "dryrun")
    123             wandb.run.api._file_stream_api = None
    124             self.rm.mirror_stdout_stderr()

/usr/local/lib/python3.7/site-packages/wandb/run_manager.py in __init__(self, run, project, tags, cloud, output, port)
    504         # Calling .start() on _meta and _system_stats will spin a thread that reports system stats every 30 seconds
    505         self._system_stats = stats.SystemStats(run, self._api)
--> 506         self._meta = meta.Meta(self._api, self._run.dir)
    507         self._meta.data["jobType"] = self._run.job_type
    508         self._meta.data["mode"] = self._run.mode

/usr/local/lib/python3.7/site-packages/wandb/meta.py in __init__(self, api, out_dir)
     34             self.data = {}
     35         self.lock = threading.Lock()
---> 36         self.setup()
     37         self._thread = threading.Thread(target=self._thread_body)
     38         self._thread.daemon = True

/usr/local/lib/python3.7/site-packages/wandb/meta.py in setup(self)
     52                     self.data["program"] = os.getenv(env.NOTEBOOK_NAME)
     53                 else:
---> 54                     meta = wandb.jupyter.notebook_metadata()
     55                     if meta.get("path"):
     56                         if "fileId=" in meta["path"]:

/usr/local/lib/python3.7/site-packages/wandb/jupyter.py in notebook_metadata()
    108             if isinstance(nn, dict) and nn.get("kernel"):
    109                 if nn['kernel']['id'] == kernel_id:
--> 110                     return {"root": s['notebook_dir'], "path": nn['notebook']['path'], "name": nn['notebook']['name']}
    111     return {}
    112 

KeyError: 'notebook'