Skip to content

Release 1.7.4.5 #757

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Changelog
====

### 1.7.4.5

A versioning error caused 1.7.4.4 to not be release.

### 1.7.4.4

Version 1.7.4.3 was not release because pre-release testing discovered a bug.
The changes in this release are the same as 1.7.4.3.

### 1.7.4.3

* Fix a problem downloading dataset files (#751)
* Fix competitions category 'all' (#740)
* Clean up indentation per #754
* Fix a problem downloading competition files (#739)

### 1.7.4.2

* Fix a problem in downloading kernel output files.
Expand Down
177 changes: 90 additions & 87 deletions kaggle/api/kaggle_api_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __repr__(self):


class KaggleApi:
__version__ = '1.7.4.2'
__version__ = '1.7.4.5'

CONFIG_NAME_PROXY = 'proxy'
CONFIG_NAME_COMPETITION = 'competition'
Expand Down Expand Up @@ -312,7 +312,7 @@ class KaggleApi:
'unlaunched_community'
]
valid_competition_categories = [
'all', 'featured', 'research', 'recruitment', 'gettingStarted', 'masters',
'unspecified', 'featured', 'research', 'recruitment', 'gettingStarted', 'masters',
'playground'
]
valid_competition_sort_by = [
Expand Down Expand Up @@ -750,7 +750,10 @@ def competitions_list(self,

if category:
if category not in self.valid_competition_categories:
raise ValueError('Invalid category specified. Valid options are ' +
if category == 'all':
category = 'unspecified'
else:
raise ValueError('Invalid category specified. Valid options are ' +
str(self.valid_competition_categories))
category = self.lookup_enum(HostSegment, category)

Expand Down Expand Up @@ -1077,15 +1080,15 @@ def competition_download_file(self,
with self.build_kaggle_client() as kaggle:
request = ApiDownloadDataFileRequest()
request.competition_name = competition
request.file_name = file_name
request.file_name = file_name.replace('/', '%2F')
response = kaggle.competitions.competition_api_client.download_data_file(
request)
url = response.history[0].url
outfile = os.path.join(effective_path, url.split('?')[0].split('/')[-1])

if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, kaggle.http_client(), quiet,
not force)
url = response.history[0].url.replace('%2F', '/')
outfile = os.path.join(effective_path, url.split('?')[0].split('/')[-1])
if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, kaggle.http_client(), quiet,
not force)

def competition_download_files(self,
competition,
Expand All @@ -1112,12 +1115,12 @@ def competition_download_files(self,
request.competition_name = competition
response = kaggle.competitions.competition_api_client.download_data_files(
request)
url = response.url.split('?')[0]
outfile = os.path.join(effective_path,
competition + '.' + url.split('.')[-1])

if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, quiet, not force)
url = response.url.split('?')[0]
outfile = os.path.join(effective_path,
competition + '.' + url.split('.')[-1])
if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, kaggle.http_client(), quiet, not force)

def competition_download_cli(self,
competition,
Expand Down Expand Up @@ -1168,15 +1171,15 @@ def competition_leaderboard_download(self, competition, path, quiet=True):
request.competition_name = competition
response = kaggle.competitions.competition_api_client.download_leaderboard(
request)
if path is None:
effective_path = self.get_default_download_dir('competitions',
competition)
else:
effective_path = path

file_name = competition + '.zip'
outfile = os.path.join(effective_path, file_name)
self.download_file(response, outfile, quiet)
if path is None:
effective_path = self.get_default_download_dir('competitions',
competition)
else:
effective_path = path
file_name = competition + '.zip'
outfile = os.path.join(effective_path, file_name)
self.download_file(response, outfile, kaggle.http_client(), quiet)

def competition_leaderboard_view(self, competition):
"""View a leaderboard based on a competition name.
Expand Down Expand Up @@ -1612,14 +1615,14 @@ def dataset_download_file(self,
request.dataset_version_number = dataset_version_number
request.file_name = file_name
response = kaggle.datasets.dataset_api_client.download_dataset(request)
url = response.history[0].url
outfile = os.path.join(effective_path, url.split('?')[0].split('/')[-1])

if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, quiet, not force)
return True
else:
return False
url = response.history[0].url
outfile = os.path.join(effective_path, url.split('?')[0].split('/')[-1])
if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, kaggle.http_client(), quiet, not force)
return True
else:
return False

def dataset_download_files(self,
dataset,
Expand Down Expand Up @@ -1660,39 +1663,39 @@ def dataset_download_files(self,
request.dataset_version_number = dataset_version_number
response = kaggle.datasets.dataset_api_client.download_dataset(request)

outfile = os.path.join(effective_path, dataset_slug + '.zip')
if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, quiet, not force)
downloaded = True
else:
downloaded = False

if downloaded:
outfile = os.path.join(effective_path, dataset_slug + '.zip')
if unzip:
try:
with zipfile.ZipFile(outfile) as z:
z.extractall(effective_path)
except zipfile.BadZipFile as e:
raise ValueError(
f"The file {outfile} is corrupted or not a valid zip file. "
"Please report this issue at https://www.github.com/kaggle/kaggle-api"
)
except FileNotFoundError:
raise FileNotFoundError(
f"The file {outfile} was not found. "
"Please report this issue at https://www.github.com/kaggle/kaggle-api"
)
except Exception as e:
raise RuntimeError(
f"An unexpected error occurred: {e}. "
"Please report this issue at https://www.github.com/kaggle/kaggle-api"
)

try:
os.remove(outfile)
except OSError as e:
print('Could not delete zip file, got %s' % e)
if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, kaggle.http_client(), quiet, not force)
downloaded = True
else:
downloaded = False

if downloaded:
outfile = os.path.join(effective_path, dataset_slug + '.zip')
if unzip:
try:
with zipfile.ZipFile(outfile) as z:
z.extractall(effective_path)
except zipfile.BadZipFile as e:
raise ValueError(
f"The file {outfile} is corrupted or not a valid zip file. "
"Please report this issue at https://www.github.com/kaggle/kaggle-api"
)
except FileNotFoundError:
raise FileNotFoundError(
f"The file {outfile} was not found. "
"Please report this issue at https://www.github.com/kaggle/kaggle-api"
)
except Exception as e:
raise RuntimeError(
f"An unexpected error occurred: {e}. "
"Please report this issue at https://www.github.com/kaggle/kaggle-api"
)

try:
os.remove(outfile)
except OSError as e:
print('Could not delete zip file, got %s' % e)

def _print_dataset_url_and_license(self, owner_slug, dataset_slug,
dataset_version_number, licenses):
Expand Down Expand Up @@ -3777,28 +3780,28 @@ def model_instance_version_download(self,
response = kaggle.models.model_api_client.download_model_instance_version(
request)

outfile = os.path.join(effective_path, model_slug + '.tar.gz')
if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, quiet, not force)
downloaded = True
else:
downloaded = False

if downloaded:
if untar:
try:
with tarfile.open(outfile, mode='r:gz') as t:
t.extractall(effective_path)
except Exception as e:
raise ValueError(
'Error extracting the tar.gz file, please report on '
'www.github.com/kaggle/kaggle-api', e)

try:
os.remove(outfile)
except OSError as e:
print('Could not delete tar file, got %s' % e)
return outfile
outfile = os.path.join(effective_path, model_slug + '.tar.gz')
if force or self.download_needed(response, outfile, quiet):
self.download_file(response, outfile, kaggle.http_client(), quiet, not force)
downloaded = True
else:
downloaded = False

if downloaded:
if untar:
try:
with tarfile.open(outfile, mode='r:gz') as t:
t.extractall(effective_path)
except Exception as e:
raise ValueError(
'Error extracting the tar.gz file, please report on '
'www.github.com/kaggle/kaggle-api', e)
try:
os.remove(outfile)
except OSError as e:
print('Could not delete tar file, got %s' % e)
return outfile

def model_instance_version_download_cli(self,
model_instance_version,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# https://packaging.python.org/en/latest/guides/modernize-setup-py-project/
setup(
name='kaggle',
version='1.7.4.2',
version='1.7.4.5',
description='Kaggle API',
long_description=(
'Official API for https://www.kaggle.com, accessible using a command line '
Expand Down
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.7.4.2"
__version__ = "1.7.4.5"
Loading
Loading