Skip to content

Commit

Permalink
Solved Issues JovianHQ#8 🔨 ✔️
Browse files Browse the repository at this point in the history
  • Loading branch information
Codechickdev committed Dec 28, 2022
1 parent df87512 commit d20cec2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ dmypy.json

# Pyre type checker
.pyre/

# Production Folders and Files for testing
production/
production/*
18 changes: 11 additions & 7 deletions opendatasets/utils/kaggle_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ def _get_kaggle_key():


def read_kaggle_creds():
path: str = None
try:
if os.path.exists('./kaggle.json'):
with open('./kaggle.json', 'r') as f:
key = f.read()
data = json.loads(key)
if 'username' in data and 'key' in data:
os.environ['KAGGLE_USERNAME'] = data['username']
os.environ['KAGGLE_KEY'] = data['key']
return True
path = './kaggle.json'
elif os.path.exists('../root/.kaggle/kaggle.json'):
path = '../root/.kaggle/kaggle.json'
with open(path, 'r') as f:
key = f.read()
data = json.loads(key)
if 'username' in data and 'key' in data:
os.environ['KAGGLE_USERNAME'] = data['username']
os.environ['KAGGLE_KEY'] = data['key']
return True
except Exception:
return False

Expand Down

0 comments on commit d20cec2

Please sign in to comment.