Skip to content

Commit

Permalink
Release 1.6.1 (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philmod authored Jan 8, 2024
1 parent 75dfa27 commit 69629f7
Show file tree
Hide file tree
Showing 32 changed files with 335 additions and 52 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
Changelog
====

### 1.6.1
Release date: 01/08/24
* Fix dataset/model upload.

### 1.6.0
Release date: 01/04/24
* Release the pre-release branch with models endpoints.

#### 1.6.0a7
Release date: 11/22/23
* Add model_instance_type and base_model_instance_id to ModelInstance

#### 1.6.0a6
Release date: 9/19/23
* Include version_number and version_id in the model-instance-metadata.json file

#### 1.6.0a5
Release date: 8/02/23
* Add Keras framework

#### 1.5.16
Release date: 7/17/23
* Fix dataset download bug with locale
* Resumable uploads
* Retry some failed requests

#### 1.6.0a4
Release date: 7/07/23
Expand Down
39 changes: 36 additions & 3 deletions KaggleSwagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,7 @@ definitions:
- FDL-1.3
- EU-ODP-Legal-Notice
- apache-2.0
- GPL-3.0
subtitle:
type: string
description: The subtitle to be set on the dataset
Expand Down Expand Up @@ -1713,7 +1714,8 @@ definitions:
- AGPL-3.0
- FDL-1.3
- EU-ODP-Legal-Notice
- apache-2.0
- apache-2.0
- GPL-3.0
Collaborator:
type: object
required:
Expand Down Expand Up @@ -1818,6 +1820,7 @@ definitions:
- scikitLearn
- mxnet
- onnx
- keras
overview:
type: string
description: The overview of the model instance (markdown)
Expand All @@ -1826,7 +1829,7 @@ definitions:
description: The description of how to use the model instance (markdown)
licenseName:
type: string
description: The license that should be associated with the model
description: The license that should be associated with the model instance
default: Apache 2.0
enum:
- CC0: Public Domain
Expand All @@ -1851,6 +1854,7 @@ definitions:
- Apache 2.0
- MIT
- BSD-3-Clause
- GPL 3
fineTunable:
type: boolean
description: Whether the model instance is fine tunable
Expand All @@ -1860,6 +1864,20 @@ definitions:
description: A list of training data (urls or names)
items:
type: string
modelInstanceType:
type: string
description: Whether the model instance is a base model, external variant, internal variant, or unspecified
enum:
- Unspecified
- BaseModel
- KaggleVariant
- ExternalVariant
baseModelInstance:
type: string
description: If this is an internal variant, the `{owner-slug}/{model-slug}/{framework}/{instance-slug}` of the base model instance
externalBaseModelUrl:
type: integer
description: If this is an external variant, a URL to the base model
files:
type: array
description: A list of files that should be associated with the model instance version
Expand All @@ -1878,7 +1896,7 @@ definitions:
description: The description of how to use the model instance (markdown)
licenseName:
type: string
description: The license that should be associated with the model
description: The license that should be associated with the model instance
default: Apache 2.0
enum:
- CC0: Public Domain
Expand All @@ -1903,6 +1921,7 @@ definitions:
- Apache 2.0
- MIT
- BSD-3-Clause
- GPL 3
fineTunable:
type: boolean
description: Whether the model instance is fine tunable
Expand All @@ -1912,6 +1931,20 @@ definitions:
description: A list of training data (urls or names)
items:
type: string
modelInstanceType:
type: string
description: Whether the model instance is a base model, external variant, internal variant, or unspecified
enum:
- Unspecified
- BaseModel
- KaggleVariant
- ExternalVariant
baseModelInstance:
type: string
description: If this is an internal variant, the `{owner-slug}/{model-slug}/{framework}/{instance-slug}` of the base model instance
externalBaseModelUrl:
type: integer
description: If this is an external variant, a URL to the base model
updateMask:
type: string
description: Describes which fields to update
Expand Down
2 changes: 1 addition & 1 deletion kaggle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion kaggle/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion kaggle/api/kaggle_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
54 changes: 49 additions & 5 deletions kaggle/api/kaggle_api_extended.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -271,7 +271,7 @@ def __repr__(self):


class KaggleApi(KaggleApi):
__version__ = '1.5.16'
__version__ = '1.6.1'

CONFIG_NAME_PROXY = 'proxy'
CONFIG_NAME_COMPETITION = 'competition'
Expand Down Expand Up @@ -909,7 +909,7 @@ def competition_download_file(self,
""" download a competition file to a designated location, or use
a default location
Paramters
Parameters
=========
competition: the name of the competition
file_name: the configuration file name
Expand Down Expand Up @@ -2880,6 +2880,16 @@ def model_instance_get_cli(self, model_instance, folder=None):
data['licenseName'] = mi['licenseName']
data['fineTunable'] = mi['fineTunable']
data['trainingData'] = mi['trainingData']
data['versionId'] = mi['versionId']
data['versionNumber'] = mi['versionNumber']
data['modelInstanceType'] = mi['modelInstanceType']
if mi['baseModelInstanceInformation'] is not None:
data['baseModelInstance'] = '{}/{}/{}/{}'.format(
mi['baseModelInstanceInformation']['owner']['slug'],
mi['baseModelInstanceInformation']['modelSlug'],
mi['baseModelInstanceInformation']['framework'],
mi['baseModelInstanceInformation']['instanceSlug'])
data['externalBaseModelUrl'] = mi['externalBaseModelUrl']

with open(meta_file, 'w') as f:
json.dump(data, f, indent=2)
Expand Down Expand Up @@ -2924,7 +2934,13 @@ def model_instance_initialize(self, folder):
'Apache 2.0',
'fineTunable':
False,
'trainingData': []
'trainingData': [],
'modelInstanceType':
'Unspecified',
'baseModelInstanceId':
0,
'externalBaseModelUrl':
''
}
meta_file = os.path.join(folder, self.MODEL_INSTANCE_METADATA_FILE)
with open(meta_file, 'w') as f:
Expand Down Expand Up @@ -2964,6 +2980,12 @@ def model_instance_create(self, folder, quiet=False, dir_mode='skip'):
license_name = self.get_or_fail(meta_data, 'licenseName')
fine_tunable = self.get_or_default(meta_data, 'fineTunable', False)
training_data = self.get_or_default(meta_data, 'trainingData', [])
model_instance_type = self.get_or_default(
meta_data, 'modelInstanceType', 'Unspecified')
base_model_instance = self.get_or_default(meta_data,
'baseModelInstance', '')
external_base_model_url = self.get_or_default(
meta_data, 'externalBaseModelUrl', '')

# validations
if owner_slug == 'INSERT_OWNER_SLUG_HERE':
Expand Down Expand Up @@ -2997,6 +3019,9 @@ def model_instance_create(self, folder, quiet=False, dir_mode='skip'):
license_name=license_name,
fine_tunable=fine_tunable,
training_data=training_data,
model_instance_type=model_instance_type,
base_model_instance=base_model_instance,
external_base_model_url=external_base_model_url,
files=[])

with ResumableUploadContext() as upload_context:
Expand Down Expand Up @@ -3089,6 +3114,12 @@ def model_instance_update(self, folder):
license_name = self.get_or_default(meta_data, 'licenseName', None)
fine_tunable = self.get_or_default(meta_data, 'fineTunable', None)
training_data = self.get_or_default(meta_data, 'trainingData', None)
model_instance_type = self.get_or_default(meta_data,
'modelInstanceType', None)
base_model_instance = self.get_or_default(meta_data,
'baseModelInstance', None)
external_base_model_url = self.get_or_default(
meta_data, 'externalBaseModelUrl', None)

# validations
if owner_slug == 'INSERT_OWNER_SLUG_HERE':
Expand Down Expand Up @@ -3128,13 +3159,22 @@ def model_instance_update(self, folder):
update_mask['paths'].append('fine_tunable')
if training_data != None:
update_mask['paths'].append('training_data')
if model_instance_type != None:
update_mask['paths'].append('model_instance_type')
if base_model_instance != None:
update_mask['paths'].append('base_model_instance')
if external_base_model_url != None:
update_mask['paths'].append('external_base_model_url')

request = ModelInstanceUpdateRequest(
overview=overview,
usage=usage,
license_name=license_name,
fine_tunable=fine_tunable,
training_data=training_data,
model_instance_type=model_instance_type,
base_model_instance=base_model_instance,
external_base_model_url=external_base_model_url,
update_mask=update_mask)
result = ModelNewResponse(
self.process_response(
Expand Down Expand Up @@ -3283,6 +3323,7 @@ def model_instance_version_download(self,
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 All @@ -3301,7 +3342,7 @@ def model_instance_version_download_cli(self,
quiet: suppress verbose output (default is False)
untar: if True, untar files upon download (default is False)
"""
self.model_instance_version_download(
return self.model_instance_version_download(
model_instance_version,
path=path,
untar=untar,
Expand Down Expand Up @@ -3528,6 +3569,9 @@ def process_response(self, result):
'Version, please consider updating (server ' +
api_version + ' / client ' + self.__version__ + ')')
self.already_printed_version_warning = True
if isinstance(data,
dict) and 'code' in data and data['code'] != 200:
raise Exception(data['message'])
return data
return result

Expand Down
2 changes: 1 addition & 1 deletion kaggle/api_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
12 changes: 8 additions & 4 deletions kaggle/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,7 +57,7 @@ def main():
parse_competitions(subparsers)
parse_datasets(subparsers)
parse_kernels(subparsers)
# parse_models(subparsers)
parse_models(subparsers)
parse_files(subparsers)
parse_config(subparsers)
args = parser.parse_args()
Expand Down Expand Up @@ -1347,8 +1347,12 @@ class Help(object):
kaggle = 'Use one of:\ncompetitions {' + ', '.join(
competitions_choices) + '}\ndatasets {' + ', '.join(
datasets_choices) + '}\nkernels {' + ', '.join(
kernels_choices) + '}\nconfig {' + ', '.join(
config_choices) + '}'
kernels_choices) + '}\nmodels {' + ', '.join(
models_choices) + '}\nmodels instances {' + ', '.join(
model_instances_choices
) + '}\nmodels instances versions {' + ', '.join(
model_instance_versions_choices
) + '}\nconfig {' + ', '.join(config_choices) + '}'

group_competitions = 'Commands related to Kaggle competitions'
group_datasets = 'Commands related to Kaggle datasets'
Expand Down
2 changes: 1 addition & 1 deletion kaggle/configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion kaggle/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion kaggle/models/api_blob_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion kaggle/models/collaborator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion kaggle/models/create_inbox_file_request.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion kaggle/models/dataset_column.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2023 Kaggle Inc
# Copyright 2024 Kaggle Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 69629f7

Please sign in to comment.