Skip to content

Commit fb91c13

Browse files
Conengmorysteboe
authored andcommitted
Warn user when kaggle.json not found
If kaggle.json is not found and the credentials were also not set in the environment, raise an error showing the expected location of kaggle.json
1 parent 50333ec commit fb91c13

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

kaggle/api/kaggle_api_extended.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,17 @@ def authenticate(self):
9999

100100
config_data = {}
101101

102-
# Step 1: read in configuration file, if it exists
103-
if os.path.exists(self.config):
104-
config_data = self.read_config_file(config_data)
105-
106-
# Step 2:, get username/password from environment
102+
# Step 1: try getting username/password from environment
107103
config_data = self.read_config_environment(config_data)
108104

105+
# Step 2: if credentials were not in environment read in configuration file
106+
if 'username' not in config_data or 'key' not in config_data:
107+
if os.path.exists(self.config):
108+
config_data = self.read_config_file(config_data)
109+
else:
110+
raise IOError('Could not find kaggle.json. Make sure it\'s located in {}.'
111+
' Or use the environment method.'.format(self.config_dir))
112+
109113
# Step 3: load into configuration!
110114
self._load_config(config_data)
111115

0 commit comments

Comments
 (0)