Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to provide Wandb API in Kaggle Kernel #2362

Closed
joyjeni opened this issue Mar 4, 2021 · 10 comments
Closed

Unable to provide Wandb API in Kaggle Kernel #2362

joyjeni opened this issue Mar 4, 2021 · 10 comments
Labels
question Further information is requested

Comments

@joyjeni
Copy link

joyjeni commented Mar 4, 2021

❔Cannot enter kaggle kernel edit mode

When I train Yolo V5 using Kaggle kernel I m unable to paste wandb API key in Kaggle Kernel. How to be in Console edit mode
There was no option to paste api key. Looks like I m not in edit mode.How to enable edit mode inside Kaggle kernel.

![image] (https://i.imgur.com/4cDrffU.png)

Additional context

@joyjeni joyjeni added the question Further information is requested label Mar 4, 2021
@NanoCode012
Copy link
Contributor

I think we should have an argument to disable wandb from command line or pass in the API key... I sometimes find it inconvenient if I have to spawn multiple trainings in containers..

For example, --wandb None vs --wandb APIKey.

@glenn-jocher
Copy link
Member

@AyushExel I think this might be the same issue #1372 I reported in December with wandb and Kaggle.

@joyjeni is your issue the same as #1372 ?

@joyjeni
Copy link
Author

joyjeni commented Mar 5, 2021

yes.

@AyushExel
Copy link
Contributor

AyushExel commented Mar 5, 2021

Try this

import wandb
 from kaggle_secrets import UserSecretsClient
 user_secrets = UserSecretsClient() 

personal_key_for_api = user_secrets.get_secret("wandb-key")

! wandb login $personal_key_for_api

@joyjeni
Copy link
Author

joyjeni commented Mar 5, 2021

Gave above error

BackendError Traceback (most recent call last)
in
4 user_secrets = UserSecretsClient()
5
----> 6 personal_key_for_api = user_secrets.get_secret("c629bfxxxxxxxx1")
7

~/.local/lib/python3.7/site-packages/kaggle_secrets.py in get_secret(self, label)
62 'Label': label,
63 }
---> 64 response_json = self.web_client.make_post_request(request_body, self.GET_USER_SECRET_BY_LABEL_ENDPOINT)
65 if 'secret' not in response_json:
66 raise BackendError(

~/.local/lib/python3.7/site-packages/kaggle_web_client.py in make_post_request(self, data, endpoint, timeout)
48 if not response_json.get('wasSuccessful') or 'result' not in response_json:
49 raise BackendError(
---> 50 f'Unexpected response from the service. Response: {response_json}.')
51 return response_json['result']
52 except (URLError, socket.timeout) as e:

BackendError: Unexpected response from the service. Response: {'errors': ['No user secrets exist for kernel id 151xxxx9 and label c629bfxxxxxxxx1'], 'error': {'code': 5, 'details': []}, 'wasSuccessful': False}.

@AyushExel
Copy link
Contributor

@joyjeni The issue occurs because you cannot directly copy a secret in kaggle console. Here the workaround is to save the API key as a kaggle secret.
Steps:
Click on add-ons in the kernel -> secrets -> add secret
Now copy the api key from wandb.ai/settings under any name you desire( in this case it's "wandb-key")
Screenshot from 2021-03-05 21-14-45

Now if you run the previous snippet, you should be able to log in

@joyjeni
Copy link
Author

joyjeni commented Mar 5, 2021

Thankyou it works

@joyjeni joyjeni closed this as completed Mar 5, 2021
@AyushExel
Copy link
Contributor

@glenn-jocher I found an easier fix for this that'll work out of the box.
Replace !wandb login with wandb.login() works fine.
Here's how the updated cell should look like.

# Weights & Biases (optional)
%pip install -q wandb 
import wandb
wandb.login()  

I have tested this and it works fine on Kaggle Kernels

@glenn-jocher
Copy link
Member

@AyushExel excellent, I'll update the Colab and Kaggle notebook!

@glenn-jocher glenn-jocher reopened this Apr 30, 2021
@glenn-jocher
Copy link
Member

glenn-jocher commented Apr 30, 2021

@joyjeni @AyushExel good news 😃! Your original issue may now been fixed ✅ in 9b91db6. To receive this update you can:

  • git pull from within your yolov5/ directory
  • git clone https://github.com/ultralytics/yolov5 again
  • Force-reload PyTorch Hub: model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • View our updated Colab and Kaggle notebooks

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants