Esempio n. 1
0
    def _load_entity(self, api, network):
        if not api.api_key:
            raise CommError(
                "Can't find API key, run wandb login or set WANDB_API_KEY")

        entity = api.settings('entity')
        if network:
            if api.settings('entity') is None:
                # Kaggle has internet disabled by default, this checks for that case
                async_viewer = util.async_call(api.viewer, timeout=3)
                viewer, viewer_thread = async_viewer()
                if viewer_thread.is_alive():
                    if is_kaggle():
                        raise CommError(
                            "To use W&B in kaggle you must enable internet in the settings panel on the right."
                        )
                    else:
                        raise CommError(
                            "Can't connect to network to query entity from API key"
                        )
                if viewer.get('entity'):
                    api.set_setting('entity', viewer['entity'])

            entity = api.settings('entity')

        if not entity:
            # This can happen on network failure
            raise CommError(
                "Can't connect to network to query entity from API key")

        return entity
Esempio n. 2
0
 def _load_viewer(self):
     if self.mode != "dryrun" and not self._api.disabled() and self._api.api_key:
         # Kaggle has internet disabled by default, this checks for that case
         async_viewer = util.async_call(self._api.viewer, timeout=env.get_http_timeout(5))
         viewer, viewer_thread = async_viewer()
         if viewer_thread.is_alive():
             if is_kaggle():
                 raise CommError("To use W&B in kaggle you must enable internet in the settings panel on the right.")
         else:
             self._viewer = viewer
             self._flags = json.loads(viewer.get("flags", "{}"))