Skip to content

Commit 10b04df

Browse files
authored
Patch API for release (#692)
This contains minor bug fixes I found after the bug bash. It also removes a couple Swagger files.
1 parent 970a36e commit 10b04df

File tree

11 files changed

+66
-19
lines changed

11 files changed

+66
-19
lines changed

.swagger-codegen-ignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Changelog
22
====
3-
### 1.7
3+
### 1.7.3b0
44

55
* Remove Swagger. No user-visible changes to the command-line tool. However, projects that
66
use `kaggle/api/kaggle_api.py` may be affected. That file is deprecated and will be removed.
7-
Most of it functions still work, but those that involve uploading files no longer work.
7+
Most of its functions still work, but those that involve uploading files no longer work.
88
The command-line tool uses a higher-level abstraction for uploading and client code needs
99
to be converted to use that.
1010

LICENSE renamed to LICENSE.txt

File renamed without changes.

kaggle/api/kaggle_api_extended.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def __repr__(self):
251251

252252

253253
class KaggleApi:
254-
__version__ = '1.7'
254+
__version__ = '1.7.3b0'
255255

256256
CONFIG_NAME_PROXY = 'proxy'
257257
CONFIG_NAME_COMPETITION = 'competition'
@@ -862,7 +862,7 @@ def competition_submit_cli(self,
862862
return None
863863
else:
864864
raise e
865-
return submit_result
865+
return submit_result.message
866866

867867
def competition_submissions(self,
868868
competition,
@@ -4635,3 +4635,21 @@ def __init__(self, init_dict):
46354635

46364636
def __repr__(self):
46374637
return ''
4638+
4639+
# This defines print_attributes(), which is very handy for inspecting
4640+
# objects returned by the Kaggle API.
4641+
4642+
from pprint import pprint
4643+
from inspect import getmembers
4644+
from types import FunctionType
4645+
4646+
def attributes(obj):
4647+
disallowed_names = {
4648+
name for name, value in getmembers(type(obj))
4649+
if isinstance(value, FunctionType)}
4650+
return {
4651+
name: getattr(obj, name) for name in dir(obj)
4652+
if name[0] != '_' and name not in disallowed_names and hasattr(obj, name)}
4653+
4654+
def print_attributes(obj):
4655+
pprint(attributes(obj))

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[build-system]
2-
requires = ["hatchling"]
2+
requires = [
3+
"hatchling",
4+
]
35
build-backend = "hatchling.build"
46

57
[project]
@@ -11,7 +13,7 @@ description = "Access Kaggle resources anywhere"
1113
authors = [
1214
{ name = "Kaggle", email = "support@kaggle.com" },
1315
]
14-
license = { file = "LICENSE" }
16+
license = { file = "LICENSE.txt" }
1517
readme = "README.md"
1618
classifiers = [
1719
"Programming Language :: Python :: 3",
@@ -46,6 +48,8 @@ Issues = "https://github.com/Kaggle/kaggle-api/issues"
4648

4749
[tool.hatch.version]
4850
path = "src/__init__.py"
51+
# TODO: Remove validate-bump = false for next stable release
52+
validate-bump = false
4953

5054
[tool.hatch.envs.default]
5155
dependencies = [

setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
from setuptools import setup, find_packages
33

44
# Note: pyproject.toml seems to be chosen by pip install over setup.py, so this
5-
# file is likely not being used anymore. We should verify and merge this into
6-
# pyproject.toml instead of maintaining both flows.
5+
# file should not be used anymore. However, cloudbuild.yaml still uses setup.py
6+
# to drive the build that is published to pypi.org. That needs to be changed
7+
# before this file can be removed. And, due to that, pyproject.toml needs to be
8+
# deleted before a release can be made.
79
setup(
810
name='kaggle',
9-
version='1.7',
11+
version='1.7.3b0',
1012
description='Kaggle API',
1113
long_description=(
1214
'Official API for https://www.kaggle.com, accessible using a command line '
@@ -24,7 +26,8 @@
2426
entry_points={'console_scripts': ['kaggle = kaggle.cli:main']},
2527
install_requires=[
2628
'six >= 1.10', 'certifi >= 2023.7.22', 'python-dateutil', 'requests',
27-
'tqdm', 'python-slugify', 'urllib3', 'bleach', 'protobuf'
29+
'tqdm', 'python-slugify', 'urllib3', 'bleach', 'protobuf',
30+
'hatchling >= 1.27.0'
2831
],
2932
packages=find_packages(
3033
where='src',

src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.7"
1+
__version__ = "1.7.3b0"

src/kaggle/api/kaggle_api_extended.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def __repr__(self):
251251

252252

253253
class KaggleApi:
254-
__version__ = '1.7'
254+
__version__ = '1.7.3b0'
255255

256256
CONFIG_NAME_PROXY = 'proxy'
257257
CONFIG_NAME_COMPETITION = 'competition'
@@ -862,7 +862,7 @@ def competition_submit_cli(self,
862862
return None
863863
else:
864864
raise e
865-
return submit_result
865+
return submit_result.message
866866

867867
def competition_submissions(self,
868868
competition,
@@ -4635,3 +4635,21 @@ def __init__(self, init_dict):
46354635

46364636
def __repr__(self):
46374637
return ''
4638+
4639+
# This defines print_attributes(), which is very handy for inspecting
4640+
# objects returned by the Kaggle API.
4641+
4642+
from pprint import pprint
4643+
from inspect import getmembers
4644+
from types import FunctionType
4645+
4646+
def attributes(obj):
4647+
disallowed_names = {
4648+
name for name, value in getmembers(type(obj))
4649+
if isinstance(value, FunctionType)}
4650+
return {
4651+
name: getattr(obj, name) for name in dir(obj)
4652+
if name[0] != '_' and name not in disallowed_names and hasattr(obj, name)}
4653+
4654+
def print_attributes(obj):
4655+
pprint(attributes(obj))

src/setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
from setuptools import setup, find_packages
33

44
# Note: pyproject.toml seems to be chosen by pip install over setup.py, so this
5-
# file is likely not being used anymore. We should verify and merge this into
6-
# pyproject.toml instead of maintaining both flows.
5+
# file should not be used anymore. However, cloudbuild.yaml still uses setup.py
6+
# to drive the build that is published to pypi.org. That needs to be changed
7+
# before this file can be removed. And, due to that, pyproject.toml needs to be
8+
# deleted before a release can be made.
79
setup(
810
name='kaggle',
9-
version='1.7',
11+
version='1.7.3b0',
1012
description='Kaggle API',
1113
long_description=(
1214
'Official API for https://www.kaggle.com, accessible using a command line '
@@ -24,7 +26,8 @@
2426
entry_points={'console_scripts': ['kaggle = kaggle.cli:main']},
2527
install_requires=[
2628
'six >= 1.10', 'certifi >= 2023.7.22', 'python-dateutil', 'requests',
27-
'tqdm', 'python-slugify', 'urllib3', 'bleach', 'protobuf'
29+
'tqdm', 'python-slugify', 'urllib3', 'bleach', 'protobuf',
30+
'hatchling >= 1.27.0'
2831
],
2932
packages=find_packages(
3033
where='src',

tests/unit_tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ def test_competition_a_list(self):
348348
def test_competition_b_submit(self):
349349
try:
350350
self.skip_submissions = False
351-
api.competition_submit(up_file, description, competition)
351+
result = api.competition_submit_cli(up_file, description, competition)
352+
if not result or not result.startswith('Successfully submitted'):
353+
self.fail(f'competition_submit failed: {result}')
352354
except HTTPError:
353355
# Handle submission limit reached gracefully (potentially skip the test)
354356
print('Competition submission limit reached for the day')

tools/swagger-codegen-cli.jar

-13.9 MB
Binary file not shown.

0 commit comments

Comments
 (0)