Ejemplo n.º 1
0
Archivo: auth.py Proyecto: xwzy/client
def sagemaker_auth(overrides=None, path=".", api_key=None):
    """Write a secrets.env file with the W&B ApiKey and any additional secrets passed.

    Args:
        overrides (dict, optional): Additional environment variables to write
                                    to secrets.env
        path (str, optional): The path to write the secrets file.
    """

    settings = wandb.setup().settings
    current_api_key = apikey.api_key(settings=settings)

    overrides = overrides or dict()
    api_key = overrides.get(env.API_KEY, api_key or current_api_key)
    if api_key is None:
        raise ValueError(
            "Can't find W&B ApiKey, set the WANDB_API_KEY env variable "
            "or run `wandb login`")
    overrides[env.API_KEY] = api_key
    with open(os.path.join(path, "secrets.env"), "w") as file:
        for k, v in six.iteritems(overrides):
            file.write("{}={}\n".format(k, v))
Ejemplo n.º 2
0
def is_logged_in(settings=None):
    wl = wandb.setup()
    wl_settings = wl.settings()
    wl_settings._apply_settings(settings=settings)
    return apikey.api_key(settings=wl_settings) is not None
Ejemplo n.º 3
0
 def is_apikey_configured(self):
     return apikey.api_key(settings=self._settings) is not None
Ejemplo n.º 4
0
import wandb
from wandb.lib import apikey

if __name__ == '__main__':
    wl = wandb.setup()
    settings = wl.settings()
    current_api_key = apikey.api_key(settings=settings)
    with open("wandb.key","w") as f:
        f.write(current_api_key)
Ejemplo n.º 5
0
 def is_logged_in(self):
     return apikey.api_key(settings=self._settings) is not None