Kaggle / kaggle-api

Official Kaggle API
Apache License 2.0
6.16k stars 1.08k forks source link

`KeyError: last-modified` in `kaggle_api_extended.py` #513

Open prabhanjan-jadhav opened 11 months ago

prabhanjan-jadhav commented 11 months ago

This line of code (1829-1830): remote_date = datetime.strptime(response.headers['Last-Modified'], '%a, %d %b %Y %H:%M:%S %Z') in kaggle/api/kaggle_api_extended.py tries to access non-existent key "last-modified" from responses.headers.

kaggle version: 1.5.16

Philmod commented 11 months ago

What is the API command I can use to reproduce this problem?

malharpandya commented 9 months ago

I can confirm that the issue still persists, and modifying the function locally with the change in the PR fixes the issue.

Sample script to reproduce the error:

import os
from kaggle.api.kaggle_api_extended import KaggleApi

# set up environment variables (now we don't need kaggle.json)
os.environ["KAGGLE_USERNAME"] = "username" # replace with account username
os.environ["KAGGLE_KEY"] = "key" # replace with generated token

# Initialize and authenticate
api = KaggleApi()
api.authenticate()

"""FETCH"""
competitions = ["llm-detect-ai-generated-text", "blood-vessel-segmentation", "UBC-OCEAN"] # sample competitions
for comp in competitions:
    api.competition_leaderboard_download(competition=comp, path=None)