# Clarity on wandb offline

**URL:** <https://community.wandb.ai/t/clarity-on-wandb-offline/429>\
**Category:** W&B Help\
**Tags:** wandb\
**Created:** [September 5, 2021, 8:09am UTC](https://community.wandb.ai/t/clarity-on-wandb-offline/429 "2021-09-05T08:09:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![harveenchadha](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/harveenchadha/32/575_2.png) [@harveenchadha](https://community.wandb.ai/u/harveenchadha)\
**Post date:** [September 5, 2021, 8:09am UTC](https://community.wandb.ai/t/clarity-on-wandb-offline/429/1 "2021-09-05T08:09:48Z")

</div>

Hi,

I was using wandb offline on kaggle. During submission time Internet has to be disabled I noticed that even if you mention the wandb key in secrets, it won’t be able to fetch it because

```auto
user_secrets = UserSecretsClient()
wandb_api = user_secrets.get_secret("wandb_api")

```

user\_secrets.get\_secret requires an active internet connection.

It took me some time to find out that we can specify a dummy key like this to login in offline mode:

```auto
key='X'*40
wandb.login(key=key)

```

If my understanding is correct, Can we please update the same information on wandb offline documentation page with a subsection on kaggle?

Thanks!

---

<div class="post-metadata">

**Author:** ![ayut](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/ayut/32/21_2.png) [@ayut](https://community.wandb.ai/u/ayut)\
**Post date:** [September 6, 2021, 3:53pm UTC](https://community.wandb.ai/t/clarity-on-wandb-offline/429/2 "2021-09-06T15:53:58Z")

</div>

Hey, you are correct that Kaggle User Secrets cannot be used when the internet is turned off. I tried it myself and running a cell with the code snippet shown below throw the` ConnectionError: Connection error trying to communicate with service` error.

I don’t think you need to log in to use W&B offline. The whole idea of using offline mode is to write metrics easily on a disk which can later be synced online with a single command line.

Over Kaggle, if you have turned off the internet (submission kernel) you simply need to do these steps:

```auto
import wandb
print(wandb. __version__ )
>>> 0.10.33 # Note that the Kaggle W&B version is always few versions old but we can't pip install. 

!wandb offline
>>> W&B offline, running your script from this directory will only write metadata locally.

# Example logging
wandb.init()
for i in range(10):
    wandb.log({"i": i})
wandb.finish()

>>> wandb sync /kaggle/working/wandb/offline-run-20210906_152752-3mkpi45e # You get the path to the directory where the run is saved. 

```

I made this [kernel](https://www.kaggle.com/ayuraj/testing-w-b-offline-flow) to show the flow. Let me know if it’s what you are trying to do.

I have a question from you - Why do you want to use W&B with the submission kernel? Would love to know your thoughts.

---

<div class="post-metadata">

**Author:** ![harveenchadha](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/harveenchadha/32/575_2.png) [@harveenchadha](https://community.wandb.ai/u/harveenchadha)\
**Post date:** [September 6, 2021, 5:04pm UTC](https://community.wandb.ai/t/clarity-on-wandb-offline/429/3 "2021-09-06T17:04:42Z")

</div>

Thanks for the notebook. 2 kernels are good but that’s not always the case. 😃

Sometimes when I create a baseline, I tend to create a single kernel to keep it simple just like [here](https://www.kaggle.com/harveenchadha/chaii-muril-hf-keras-wb). If you edit, you will be able to see the below code I used to setup wandb.

```auto
#Intialize wandb run

if config['use_wandb']:
    import wandb
    from wandb.keras import WandbCallback
    from kaggle_secrets import UserSecretsClient
    

    if config['wandb_mode'] == 'offline':
        os.environ["WANDB_MODE"] = "offline"
        key='X'*40
        wandb.login(key=key)
    else:
        user_secrets = UserSecretsClient()
        wandb_api = user_secrets.get_secret("wandb_api")
        wandb.login(key=wandb_api)

    run = wandb.init(project='chaii', 
                     group =config['group'], 
                     job_type='train',
                     config = config)

    LOGGER.info("Wandb is initialized")

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [April 20, 2022, 6:02pm UTC](https://community.wandb.ai/t/clarity-on-wandb-offline/429/4 "2022-04-20T18:02:05Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
