diff --git a/kaggle/__init__.py b/kaggle/__init__.py index 94a24d9..4d2f819 100644 --- a/kaggle/__init__.py +++ b/kaggle/__init__.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding=utf-8 from __future__ import absolute_import from kaggle.api.kaggle_api_extended import KaggleApi diff --git a/kaggle/api/__init__.py b/kaggle/api/__init__.py index 3bf6881..bd47882 100644 --- a/kaggle/api/__init__.py +++ b/kaggle/api/__init__.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from __future__ import absolute_import # flake8: noqa diff --git a/kaggle/api/kaggle_api.py b/kaggle/api/kaggle_api.py index 9ffc866..15d6834 100644 --- a/kaggle/api/kaggle_api.py +++ b/kaggle/api/kaggle_api.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ @@ -3011,7 +3027,7 @@ def kernels_list(self, **kwargs): # noqa: E501 :param async_req bool :param int page: Page number - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str search: Search terms :param str group: Display only your kernels :param str user: Display kernels by a particular group @@ -3043,7 +3059,7 @@ def kernels_list_with_http_info(self, **kwargs): # noqa: E501 :param async_req bool :param int page: Page number - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str search: Search terms :param str group: Display only your kernels :param str user: Display kernels by a particular group @@ -3146,7 +3162,7 @@ def kernels_list_files(self, user_name, kernel_slug, **kwargs): # noqa: E501 :param str user_name: Kernel owner (required) :param str kernel_slug: Kernel name (required) :param str kernel_version_number: Kernel version number - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, @@ -3171,7 +3187,7 @@ def kernels_list_files_with_http_info(self, user_name, kernel_slug, **kwargs): :param str user_name: Kernel owner (required) :param str kernel_slug: Kernel name (required) :param str kernel_version_number: Kernel version number - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, @@ -3600,7 +3616,7 @@ def model_instance_versions_files(self, owner_slug, model_slug, framework, insta :param str framework: Model instance framework (required) :param str instance_slug: Model instance slug (required) :param str version_number: Model instance version number (required) - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, @@ -3627,7 +3643,7 @@ def model_instance_versions_files_with_http_info(self, owner_slug, model_slug, f :param str framework: Model instance framework (required) :param str instance_slug: Model instance slug (required) :param str version_number: Model instance version number (required) - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, @@ -4070,7 +4086,7 @@ def models_list(self, **kwargs): # noqa: E501 :param str search: Search terms :param str sort_by: Sort the results :param str owner: Display models by a specific user or organization - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, @@ -4095,7 +4111,7 @@ def models_list_with_http_info(self, **kwargs): # noqa: E501 :param str search: Search terms :param str sort_by: Sort the results :param str owner: Display models by a specific user or organization - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, @@ -4175,7 +4191,7 @@ def models_list_files(self, owner_slug, model_slug, **kwargs): # noqa: E501 :param str owner_slug: Model owner (required) :param str model_slug: Model name (required) :param str model_version_number: Model version number - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, @@ -4200,7 +4216,7 @@ def models_list_files_with_http_info(self, owner_slug, model_slug, **kwargs): # :param str owner_slug: Model owner (required) :param str model_slug: Model name (required) :param str model_version_number: Model version number - :param int page_size: Page size + :param int page_size: Number of items per page (default 20) :param str page_token: Page token for pagination :return: Result If the method is called asynchronously, diff --git a/kaggle/api/kaggle_api_extended.py b/kaggle/api/kaggle_api_extended.py index 654a004..16f5787 100644 --- a/kaggle/api/kaggle_api_extended.py +++ b/kaggle/api/kaggle_api_extended.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/usr/bin/python # # Copyright 2019 Kaggle Inc @@ -83,6 +99,7 @@ class DirectoryArchive(object): + def __init__(self, fullpath, format): self._fullpath = fullpath self._format = format @@ -92,9 +109,8 @@ def __init__(self, fullpath, format): def __enter__(self): self._temp_dir = tempfile.mkdtemp() _, dir_name = os.path.split(self._fullpath) - self.path = shutil.make_archive( - os.path.join(self._temp_dir, dir_name), self._format, - self._fullpath) + self.path = shutil.make_archive(os.path.join(self._temp_dir, dir_name), + self._format, self._fullpath) _, self.name = os.path.split(self.path) return self @@ -103,6 +119,7 @@ def __exit__(self, *args): class ResumableUploadContext(object): + def __init__(self, no_resume=False): self.no_resume = no_resume self._temp_dir = os.path.join(tempfile.gettempdir(), '.kaggle/uploads') @@ -348,6 +365,7 @@ def with_retry(self, initial_delay_millis=500, retry_multiplier=1.7, randomness_factor=0.5): + def retriable_func(*args): for i in range(1, max_retries + 1): try: @@ -357,8 +375,9 @@ def retriable_func(*args): total_delay = self._calculate_backoff_delay( i, initial_delay_millis, retry_multiplier, randomness_factor) - print('Request failed: %s. Will retry in %2.1f seconds' - % (e, total_delay)) + print( + 'Request failed: %s. Will retry in %2.1f seconds' % + (e, total_delay)) time.sleep(total_delay) continue raise @@ -386,8 +405,8 @@ def authenticate(self): or self.CONFIG_NAME_KEY not in config_data: if os.path.exists(self.config): config_data = self.read_config_file(config_data) - elif self._is_help_or_version_command(api_command) or ( - len(sys.argv) > 2 and api_command.startswith( + elif self._is_help_or_version_command(api_command) or (len( + sys.argv) > 2 and api_command.startswith( self.command_prefixes_allowing_anonymous_access)): # Some API commands should be allowed without authentication. return @@ -465,8 +484,8 @@ def _load_config(self, config_data): # Cert File if self.CONFIG_NAME_SSL_CA_CERT in config_data: - configuration.ssl_ca_cert = config_data[self. - CONFIG_NAME_SSL_CA_CERT] + configuration.ssl_ca_cert = config_data[ + self.CONFIG_NAME_SSL_CA_CERT] # Keep config values with class instance, and load api client! @@ -687,12 +706,11 @@ def competitions_list(self, str(self.valid_competition_sort_by)) competitions_list_result = self.process_response( - self.competitions_list_with_http_info( - group=group or '', - category=category or '', - sort_by=sort_by or '', - page=page, - search=search or '')) + self.competitions_list_with_http_info(group=group or '', + category=category or '', + sort_by=sort_by or '', + page=page, + search=search or '')) return [Competition(c) for c in competitions_list_result] def competitions_list_cli(self, @@ -713,12 +731,11 @@ def competitions_list_cli(self, search: a search term to use (default is empty string) csv_display: if True, print comma separated values """ - competitions = self.competitions_list( - group=group, - category=category, - sort_by=sort_by, - page=page, - search=search) + competitions = self.competitions_list(group=group, + category=category, + sort_by=sort_by, + page=page, + search=search) fields = [ 'ref', 'deadline', 'category', 'reward', 'teamCount', 'userHasEntered' @@ -771,8 +788,9 @@ def competition_submit(self, file_name, message, competition, quiet=False): upload_result_token = upload_result['token'] else: # New submissions path! - upload_status = self.upload_complete( - file_name, url_result['createUrl'], quiet) + upload_status = self.upload_complete(file_name, + url_result['createUrl'], + quiet) if upload_status != ResumableUploadResult.COMPLETE: # Actual error is printed during upload_complete. Not # ideal but changing would not be backwards compatible @@ -1147,8 +1165,9 @@ def dataset_list(self, ) if file_type and file_type not in self.valid_dataset_file_types: - raise ValueError('Invalid file type specified. Valid options are ' - + str(self.valid_dataset_file_types)) + raise ValueError( + 'Invalid file type specified. Valid options are ' + + str(self.valid_dataset_file_types)) if license_name and license_name not in self.valid_dataset_license_names: raise ValueError('Invalid license specified. Valid options are ' + @@ -1174,18 +1193,17 @@ def dataset_list(self, group = 'user' datasets_list_result = self.process_response( - self.datasets_list_with_http_info( - group=group, - sort_by=sort_by or 'hottest', - size=size, - filetype=file_type or 'all', - license=license_name or 'all', - tagids=tag_ids or '', - search=search or '', - user=user or '', - page=page, - max_size=max_size, - min_size=min_size)) + self.datasets_list_with_http_info(group=group, + sort_by=sort_by or 'hottest', + size=size, + filetype=file_type or 'all', + license=license_name or 'all', + tagids=tag_ids or '', + search=search or '', + user=user or '', + page=page, + max_size=max_size, + min_size=min_size)) return [Dataset(d) for d in datasets_list_result] def dataset_list_cli(self, @@ -1387,8 +1405,8 @@ def dataset_status(self, dataset): owner_slug = self.get_config_value(self.CONFIG_NAME_USER) dataset_slug = dataset dataset_status_result = self.process_response( - self.datasets_status_with_http_info( - owner_slug=owner_slug, dataset_slug=dataset_slug)) + self.datasets_status_with_http_info(owner_slug=owner_slug, + dataset_slug=dataset_slug)) return dataset_status_result def dataset_status_cli(self, dataset, dataset_opt=None): @@ -1570,21 +1588,19 @@ def dataset_download_cli(self, ] if file_name is None: - self.dataset_download_files( - dataset, - path=path, - unzip=unzip, - force=force, - quiet=quiet, - licenses=licenses) + self.dataset_download_files(dataset, + path=path, + unzip=unzip, + force=force, + quiet=quiet, + licenses=licenses) else: - self.dataset_download_file( - dataset, - file_name, - path=path, - force=force, - quiet=quiet, - licenses=licenses) + self.dataset_download_file(dataset, + file_name, + path=path, + force=force, + quiet=quiet, + licenses=licenses) def _upload_blob(self, path, quiet, blob_type, upload_context): """ upload a file @@ -1745,8 +1761,9 @@ def dataset_create_version_cli(self, ('The following are not valid tags and could not be added to ' 'the dataset: ') + str(result.invalidTags)) elif result.status.lower() == 'ok': - print('Dataset version is being created. Please check progress at ' - + result.url) + print( + 'Dataset version is being created. Please check progress at ' + + result.url) else: print('Dataset version creation error: ' + result.error) @@ -1813,8 +1830,8 @@ def dataset_create_new(self, dataset_slug = ref_list[1] # validations - if ref == self.config_values[self. - CONFIG_NAME_USER] + '/INSERT_SLUG_HERE': + if ref == self.config_values[ + self.CONFIG_NAME_USER] + '/INSERT_SLUG_HERE': raise ValueError( 'Default slug detected, please change values before uploading') if title == 'INSERT_TITLE_HERE': @@ -1842,17 +1859,16 @@ def dataset_create_new(self, raise ValueError( 'Subtitle length must be between 20 and 80 characters') - request = DatasetNewRequest( - title=title, - slug=dataset_slug, - owner_slug=owner_slug, - license_name=license_name, - subtitle=subtitle, - description=description, - files=[], - is_private=not public, - convert_to_csv=convert_to_csv, - category_ids=keywords) + request = DatasetNewRequest(title=title, + slug=dataset_slug, + owner_slug=owner_slug, + license_name=license_name, + subtitle=subtitle, + description=description, + files=[], + is_private=not public, + convert_to_csv=convert_to_csv, + category_ids=keywords) with ResumableUploadContext() as upload_context: self.upload_files(request, resources, folder, ApiBlobType.DATASET, @@ -1947,30 +1963,28 @@ def download_file(self, headers={'Range': 'bytes=%d-' % (size_read, )}, _preload_content=False) - with tqdm( - total=size, - initial=size_read, - unit='B', - unit_scale=True, - unit_divisor=1024, - disable=quiet) as pbar: + with tqdm(total=size, + initial=size_read, + unit='B', + unit_scale=True, + unit_divisor=1024, + disable=quiet) as pbar: with open(outfile, open_mode) as out: while True: data = response.read(chunk_size) if not data: break out.write(data) - os.utime( - outfile, - times=(remote_date_timestamp - 1, - remote_date_timestamp - 1)) + os.utime(outfile, + times=(remote_date_timestamp - 1, + remote_date_timestamp - 1)) size_read = min(size, size_read + chunk_size) pbar.update(len(data)) if not quiet: print('\n', end='') - os.utime( - outfile, times=(remote_date_timestamp, remote_date_timestamp)) + os.utime(outfile, + times=(remote_date_timestamp, remote_date_timestamp)) def kernels_list(self, page=1, @@ -2041,19 +2055,18 @@ def kernels_list(self, group = 'profile' kernels_list_result = self.process_response( - self.kernels_list_with_http_info( - page=page, - page_size=page_size, - group=group, - user=user or '', - language=language or 'all', - kernel_type=kernel_type or 'all', - output_type=output_type or 'all', - sort_by=sort_by or 'hotness', - dataset=dataset or '', - competition=competition or '', - parent_kernel=parent_kernel or '', - search=search or '')) + self.kernels_list_with_http_info(page=page, + page_size=page_size, + group=group, + user=user or '', + language=language or 'all', + kernel_type=kernel_type or 'all', + output_type=output_type or 'all', + sort_by=sort_by or 'hotness', + dataset=dataset or '', + competition=competition or '', + parent_kernel=parent_kernel or '', + search=search or '')) return [Kernel(k) for k in kernels_list_result] def kernels_list_cli(self, @@ -2076,19 +2089,18 @@ def kernels_list_cli(self, ========== csv_display: if True, print comma separated values instead of table """ - kernels = self.kernels_list( - page=page, - page_size=page_size, - search=search, - mine=mine, - dataset=dataset, - competition=competition, - parent_kernel=parent, - user=user, - language=language, - kernel_type=kernel_type, - output_type=output_type, - sort_by=sort_by) + kernels = self.kernels_list(page=page, + page_size=page_size, + search=search, + mine=mine, + dataset=dataset, + competition=competition, + parent_kernel=parent, + user=user, + language=language, + kernel_type=kernel_type, + output_type=output_type, + sort_by=sort_by) fields = ['ref', 'title', 'author', 'lastRunTime', 'totalVotes'] if kernels: if csv_display: @@ -2113,11 +2125,10 @@ def kernels_list_files(self, kernel, page_token=None, page_size=20): kernel) kernels_list_files_result = self.process_response( - self.kernels_list_files_with_http_info( - kernel_slug=kernel_slug, - user_name=user_name, - page_token=page_token, - page_size=page_size)) + self.kernels_list_files_with_http_info(kernel_slug=kernel_slug, + user_name=user_name, + page_token=page_token, + page_size=page_size)) return FileList(kernels_list_files_result) def kernels_list_files_cli(self, @@ -2180,11 +2191,11 @@ def kernels_initialize(self, folder): 'code_file': 'INSERT_CODE_FILE_PATH_HERE', 'language': - 'Pick one of: {' + ','.join( - x for x in self.valid_push_language_types) + '}', + 'Pick one of: {' + + ','.join(x for x in self.valid_push_language_types) + '}', 'kernel_type': - 'Pick one of: {' + ','.join( - x for x in self.valid_push_kernel_types) + '}', + 'Pick one of: {' + + ','.join(x for x in self.valid_push_kernel_types) + '}', 'is_private': 'true', 'enable_gpu': @@ -2294,8 +2305,9 @@ def kernels_push(self, folder): for source in model_sources: self.validate_model_string(source) - docker_pinning_type = self.get_or_default( - meta_data, 'docker_image_pinning_type', None) + docker_pinning_type = self.get_or_default(meta_data, + 'docker_image_pinning_type', + None) if (docker_pinning_type is not None and docker_pinning_type not in self.valid_push_pinning_types): raise ValueError( @@ -2469,8 +2481,8 @@ def kernels_pull(self, kernel, path, metadata=False, quiet=True): if file_name is None: print( 'Unknown language %s + kernel type %s - please report this ' - 'on the kaggle-api github issues' % (language, - kernel_type)) + 'on the kaggle-api github issues' % + (language, kernel_type)) print( 'Saving as a python file, even though this may not be the ' 'correct language') @@ -2526,8 +2538,10 @@ def kernels_pull_cli(self, """ client wrapper for kernels_pull """ kernel = kernel or kernel_opt - effective_path = self.kernels_pull( - kernel, path=path, metadata=metadata, quiet=False) + effective_path = self.kernels_pull(kernel, + path=path, + metadata=metadata, + quiet=False) if metadata: print('Source code and metadata downloaded to ' + effective_path) else: @@ -2709,12 +2723,11 @@ def model_list(self, raise ValueError('Page size must be >= 1') models_list_result = self.process_response( - self.models_list_with_http_info( - sort_by=sort_by or 'hotness', - search=search or '', - owner=owner or '', - page_size=page_size, - page_token=page_token)) + self.models_list_with_http_info(sort_by=sort_by or 'hotness', + search=search or '', + owner=owner or '', + page_size=page_size, + page_token=page_token)) next_page_token = models_list_result['nextPageToken'] if next_page_token: @@ -2761,18 +2774,12 @@ def model_initialize(self, folder): raise ValueError('Invalid folder: ' + folder) meta_data = { - 'ownerSlug': - 'INSERT_OWNER_SLUG_HERE', - 'title': - 'INSERT_TITLE_HERE', - 'slug': - 'INSERT_SLUG_HERE', - 'subtitle': - '', - 'isPrivate': - True, - 'description': - '''# Model Summary + 'ownerSlug': 'INSERT_OWNER_SLUG_HERE', + 'title': 'INSERT_TITLE_HERE', + 'slug': 'INSERT_SLUG_HERE', + 'subtitle': '', + 'isPrivate': True, + 'description': '''# Model Summary # Model Characteristics @@ -2780,10 +2787,8 @@ def model_initialize(self, folder): # Evaluation Results ''', - 'publishTime': - '', - 'provenanceSources': - '' + 'publishTime': '', + 'provenanceSources': '' } meta_file = os.path.join(folder, self.MODEL_METADATA_FILE) with open(meta_file, 'w') as f: @@ -2837,15 +2842,14 @@ def model_create_new(self, folder): if publish_time: self.validate_date(publish_time) - request = ModelNewRequest( - owner_slug=owner_slug, - slug=slug, - title=title, - subtitle=subtitle, - is_private=is_private, - description=description, - publish_time=publish_time, - provenance_sources=provenance_sources) + request = ModelNewRequest(owner_slug=owner_slug, + slug=slug, + title=title, + subtitle=subtitle, + is_private=is_private, + description=description, + publish_time=publish_time, + provenance_sources=provenance_sources) result = ModelNewResponse( self.process_response( self.models_create_new_with_http_info(request))) @@ -2957,14 +2961,13 @@ def model_update(self, folder): if provenance_sources != None: update_mask['paths'].append('provenance_sources') - request = ModelUpdateRequest( - title=title, - subtitle=subtitle, - is_private=is_private, - description=description, - publish_time=publish_time, - provenance_sources=provenance_sources, - update_mask=update_mask) + request = ModelUpdateRequest(title=title, + subtitle=subtitle, + is_private=is_private, + description=description, + publish_time=publish_time, + provenance_sources=provenance_sources, + update_mask=update_mask) result = ModelNewResponse( self.process_response( self.update_model_with_http_info(owner_slug, slug, request))) @@ -3056,18 +3059,12 @@ def model_instance_initialize(self, folder): raise ValueError('Invalid folder: ' + folder) meta_data = { - 'ownerSlug': - 'INSERT_OWNER_SLUG_HERE', - 'modelSlug': - 'INSERT_EXISTING_MODEL_SLUG_HERE', - 'instanceSlug': - 'INSERT_INSTANCE_SLUG_HERE', - 'framework': - 'INSERT_FRAMEWORK_HERE', - 'overview': - '', - 'usage': - '''# Model Format + 'ownerSlug': 'INSERT_OWNER_SLUG_HERE', + 'modelSlug': 'INSERT_EXISTING_MODEL_SLUG_HERE', + 'instanceSlug': 'INSERT_INSTANCE_SLUG_HERE', + 'framework': 'INSERT_FRAMEWORK_HERE', + 'overview': '', + 'usage': '''# Model Format # Training Data @@ -3081,17 +3078,12 @@ def model_instance_initialize(self, folder): # Changelog ''', - 'licenseName': - 'Apache 2.0', - 'fineTunable': - False, + 'licenseName': 'Apache 2.0', + 'fineTunable': False, 'trainingData': [], - 'modelInstanceType': - 'Unspecified', - 'baseModelInstanceId': - 0, - 'externalBaseModelUrl': - '' + 'modelInstanceType': 'Unspecified', + 'baseModelInstanceId': 0, + 'externalBaseModelUrl': '' } meta_file = os.path.join(folder, self.MODEL_INSTANCE_METADATA_FILE) with open(meta_file, 'w') as f: @@ -3131,12 +3123,14 @@ 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') + 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', '') + external_base_model_url = self.get_or_default(meta_data, + 'externalBaseModelUrl', + '') # validations if owner_slug == 'INSERT_OWNER_SLUG_HERE': @@ -3181,8 +3175,9 @@ def model_instance_create(self, folder, quiet=False, dir_mode='skip'): result = ModelNewResponse( self.process_response( self.with_retry( - self.models_create_instance_with_http_info)( - owner_slug, model_slug, request))) + self.models_create_instance_with_http_info)(owner_slug, + model_slug, + request))) return result @@ -3269,8 +3264,9 @@ def model_instance_update(self, folder): '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) + external_base_model_url = self.get_or_default(meta_data, + 'externalBaseModelUrl', + None) # validations if owner_slug == 'INSERT_OWNER_SLUG_HERE': @@ -3369,8 +3365,8 @@ def model_instance_version_create(self, owner_slug, model_slug, framework, instance_slug = self.split_model_instance_string( model_instance) - request = ModelInstanceNewVersionRequest( - version_notes=version_notes, files=[]) + request = ModelInstanceNewVersionRequest(version_notes=version_notes, + files=[]) with ResumableUploadContext() as upload_context: self.upload_files(request, None, folder, ApiBlobType.MODEL, @@ -3400,8 +3396,9 @@ def model_instance_version_create_cli(self, quiet: suppress verbose output (default is False) dir_mode: what to do with directories: "skip" - ignore; "zip" - compress and upload """ - result = self.model_instance_version_create( - model_instance, folder, version_notes, quiet, dir_mode) + result = self.model_instance_version_create(model_instance, folder, + version_notes, quiet, + dir_mode) if result.hasId: print('Your model instance version was created. Url={}'.format( @@ -3493,12 +3490,11 @@ def model_instance_version_download_cli(self, quiet: suppress verbose output (default is False) untar: if True, untar files upon download (default is False) """ - return self.model_instance_version_download( - model_instance_version, - path=path, - untar=untar, - force=force, - quiet=quiet) + return self.model_instance_version_download(model_instance_version, + path=path, + untar=untar, + force=force, + quiet=quiet) def model_instance_version_files(self, model_instance_version, @@ -3557,11 +3553,10 @@ def model_instance_version_files_cli(self, page_size: the number of items per page csv_display: if True, print comma separated values instead of table """ - result = self.model_instance_version_files( - model_instance_version, - page_token=page_token, - page_size=page_size, - csv_display=csv_display) + result = self.model_instance_version_files(model_instance_version, + page_token=page_token, + page_size=page_size, + csv_display=csv_display) if result and result.files is not None: fields = ['name', 'size', 'creationDate'] if csv_display: @@ -3626,8 +3621,9 @@ def files_upload_cli(self, local_paths, inbox_path, no_resume, files_to_create = [] with ResumableUploadContext(no_resume) as upload_context: for local_path in local_paths: - (upload_file, file_name) = self.file_upload_cli( - local_path, inbox_path, no_compress, upload_context) + (upload_file, + file_name) = self.file_upload_cli(local_path, inbox_path, + no_compress, upload_context) if upload_file is None: continue @@ -3649,9 +3645,10 @@ def file_upload_cli(self, local_path, inbox_path, no_compress, file_or_folder_name = os.path.basename(full_path) dir_mode = 'tar' if no_compress else 'zip' - upload_file = self._upload_file_or_folder( - parent_path, file_or_folder_name, ApiBlobType.INBOX, - upload_context, dir_mode) + upload_file = self._upload_file_or_folder(parent_path, + file_or_folder_name, + ApiBlobType.INBOX, + upload_context, dir_mode) return (upload_file, file_or_folder_name) def print_obj(self, obj, indent=2): @@ -3701,8 +3698,8 @@ def print_table(self, items, fields): if len(items) == 0: return for f in fields: - length = max( - len(f), max([len(self.string(getattr(i, f))) for i in items])) + length = max(len(f), + max([len(self.string(getattr(i, f))) for i in items])) justify = '>' if isinstance(getattr( items[0], f), int) or f == 'size' or f == 'reward' else '<' formats.append('{:' + justify + self.string(length + 2) + '}') @@ -3854,9 +3851,10 @@ def upload_files(self, self.MODEL_INSTANCE_METADATA_FILE ]): continue - upload_file = self._upload_file_or_folder( - folder, file_name, blob_type, upload_context, dir_mode, quiet, - resources) + upload_file = self._upload_file_or_folder(folder, file_name, + blob_type, + upload_context, dir_mode, + quiet, resources) if upload_file is not None: request.files.append(upload_file) @@ -3938,9 +3936,9 @@ def process_column(self, column): ========== column: a list of values in a column to be processed """ - processed_column = DatasetColumn( - name=self.get_or_fail(column, 'name'), - description=self.get_or_default(column, 'description', '')) + processed_column = DatasetColumn(name=self.get_or_fail(column, 'name'), + description=self.get_or_default( + column, 'description', '')) if 'type' in column: original_type = column['type'].lower() processed_column.original_type = original_type @@ -3984,12 +3982,11 @@ def upload_complete(self, path, url, quiet, resume=False): start_at = resumable_upload_result.start_at upload_size = file_size - start_at - with tqdm( - total=upload_size, - unit='B', - unit_scale=True, - unit_divisor=1024, - disable=quiet) as progress_bar: + with tqdm(total=upload_size, + unit='B', + unit_scale=True, + unit_divisor=1024, + disable=quiet) as progress_bar: with io.open(path, 'rb', buffering=0) as fp: session = requests.Session() if start_at > 0: @@ -3998,8 +3995,8 @@ def upload_complete(self, path, url, quiet, resume=False): 'Content-Length': '%d' % upload_size, 'Content-Range': - 'bytes %d-%d/%d' % (start_at, file_size - 1, - file_size) + 'bytes %d-%d/%d' % + (start_at, file_size - 1, file_size) }) reader = TqdmBufferedReader(fp, progress_bar) retries = Retry(total=10, backoff_factor=0.5) @@ -4323,6 +4320,7 @@ def confirmation(self): class TqdmBufferedReader(io.BufferedReader): + def __init__(self, raw, progress_bar): """ helper class to implement an io.BufferedReader Parameters @@ -4352,6 +4350,7 @@ def increment(self, length): class FileList(object): + def __init__(self, init_dict): self.error_message = '' files = init_dict['files'] diff --git a/kaggle/api_client.py b/kaggle/api_client.py index 5a4ac36..a13ef35 100644 --- a/kaggle/api_client.py +++ b/kaggle/api_client.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ Kaggle API diff --git a/kaggle/cli.py b/kaggle/cli.py index 83c3fec..7d4a6ae 100644 --- a/kaggle/cli.py +++ b/kaggle/cli.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/usr/bin/python # # Copyright 2019 Kaggle Inc @@ -28,14 +44,14 @@ def main(): parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter) - parser.add_argument( - '-v', - '--version', - action='version', - version='Kaggle API ' + KaggleApi.__version__) + parser.add_argument('-v', + '--version', + action='version', + version='Kaggle API ' + KaggleApi.__version__) - subparsers = parser.add_subparsers( - title='commands', help=Help.kaggle, dest='command') + subparsers = parser.add_subparsers(title='commands', + help=Help.kaggle, + dest='command') subparsers.required = True subparsers.choices = Help.kaggle_choices parse_competitions(subparsers) @@ -121,25 +137,22 @@ def parse_competitions(subparsers): dest='sort_by', required=False, help=Help.param_competition_sort_by) - parser_competitions_list_optional.add_argument( - '-p', - '--page', - dest='page', - default=1, - required=False, - help=Help.param_page) - parser_competitions_list_optional.add_argument( - '-s', - '--search', - dest='search', - required=False, - help=Help.param_search) - parser_competitions_list_optional.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) + parser_competitions_list_optional.add_argument('-p', + '--page', + dest='page', + default=1, + required=False, + help=Help.param_page) + parser_competitions_list_optional.add_argument('-s', + '--search', + dest='search', + required=False, + help=Help.param_search) + parser_competitions_list_optional.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) parser_competitions_list._action_groups.append( parser_competitions_list_optional) parser_competitions_list.set_defaults(func=api.competitions_list_cli) @@ -153,35 +166,30 @@ def parse_competitions(subparsers): ) parser_competitions_files_optional.add_argument( 'competition', nargs='?', default=None, help=Help.param_competition) - parser_competitions_files_optional.add_argument( - '-c', - '--competition', - dest='competition_opt', - required=False, - help=argparse.SUPPRESS) - parser_competitions_files_optional.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) - parser_competitions_files_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - help=Help.param_quiet) - parser_competitions_files_optional.add_argument( - '--page-token', - dest='page_token', - required=False, - help=Help.param_page_token) - parser_competitions_files_optional.add_argument( - '--page-size', - dest='page_size', - required=False, - default=20, - help=Help.param_page_size) + parser_competitions_files_optional.add_argument('-c', + '--competition', + dest='competition_opt', + required=False, + help=argparse.SUPPRESS) + parser_competitions_files_optional.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) + parser_competitions_files_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + help=Help.param_quiet) + parser_competitions_files_optional.add_argument('--page-token', + dest='page_token', + required=False, + help=Help.param_page_token) + parser_competitions_files_optional.add_argument('--page-size', + dest='page_size', + required=False, + default=20, + help=Help.param_page_size) parser_competitions_files._action_groups.append( parser_competitions_files_optional) parser_competitions_files.set_defaults(func=api.competition_list_files_cli) @@ -195,12 +203,11 @@ def parse_competitions(subparsers): ) parser_competitions_download_optional.add_argument( 'competition', nargs='?', default=None, help=Help.param_competition) - parser_competitions_download_optional.add_argument( - '-c', - '--competition', - dest='competition_opt', - required=False, - help=argparse.SUPPRESS) + parser_competitions_download_optional.add_argument('-c', + '--competition', + dest='competition_opt', + required=False, + help=argparse.SUPPRESS) parser_competitions_download_optional.add_argument( '-f', '--file', @@ -213,26 +220,23 @@ def parse_competitions(subparsers): dest='path', required=False, help=Help.param_downfolder) - parser_competitions_download_optional.add_argument( - '-w', - '--wp', - dest='path', - action='store_const', - const='.', - required=False, - help=Help.param_wp) - parser_competitions_download_optional.add_argument( - '-o', - '--force', - dest='force', - action='store_true', - help=Help.param_force) - parser_competitions_download_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - help=Help.param_quiet) + parser_competitions_download_optional.add_argument('-w', + '--wp', + dest='path', + action='store_const', + const='.', + required=False, + help=Help.param_wp) + parser_competitions_download_optional.add_argument('-o', + '--force', + dest='force', + action='store_true', + help=Help.param_force) + parser_competitions_download_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + help=Help.param_quiet) parser_competitions_download._action_groups.append( parser_competitions_download_optional) parser_competitions_download.set_defaults( @@ -249,30 +253,27 @@ def parse_competitions(subparsers): 'required arguments') parser_competitions_submit_optional.add_argument( 'competition', nargs='?', default=None, help=Help.param_competition) - parser_competitions_submit_optional.add_argument( - '-c', - '--competition', - dest='competition_opt', - required=False, - help=argparse.SUPPRESS) - parser_competitions_submit_required.add_argument( - '-f', - '--file', - dest='file_name', - required=True, - help=Help.param_upfile) + parser_competitions_submit_optional.add_argument('-c', + '--competition', + dest='competition_opt', + required=False, + help=argparse.SUPPRESS) + parser_competitions_submit_required.add_argument('-f', + '--file', + dest='file_name', + required=True, + help=Help.param_upfile) parser_competitions_submit_required.add_argument( '-m', '--message', dest='message', required=True, help=Help.param_competition_message) - parser_competitions_submit_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - help=Help.param_quiet) + parser_competitions_submit_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + help=Help.param_quiet) parser_competitions_submit._action_groups.append( parser_competitions_submit_optional) parser_competitions_submit.set_defaults(func=api.competition_submit_cli) @@ -292,12 +293,11 @@ def parse_competitions(subparsers): dest='competition_opt', required=False, help=argparse.SUPPRESS) - parser_competitions_submissions_optional.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) + parser_competitions_submissions_optional.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) parser_competitions_submissions_optional.add_argument( '-q', '--quiet', @@ -338,12 +338,11 @@ def parse_competitions(subparsers): help=Help.param_competition_leaderboard_download) parser_competitions_leaderboard_optional.add_argument( '-p', '--path', dest='path', help=Help.param_downfolder) - parser_competitions_leaderboard_optional.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) + parser_competitions_leaderboard_optional.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) parser_competitions_leaderboard_optional.add_argument( '-q', '--quiet', @@ -368,8 +367,8 @@ def parse_datasets(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.group_datasets, aliases=['d']) - subparsers_datasets = parser_datasets.add_subparsers( - title='commands', dest='command') + subparsers_datasets = parser_datasets.add_subparsers(title='commands', + dest='command') subparsers_datasets.required = True subparsers_datasets.choices = Help.datasets_choices @@ -379,58 +378,59 @@ def parse_datasets(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_datasets_list) parser_datasets_list_optional = parser_datasets_list._action_groups.pop() - parser_datasets_list.add_argument( - '--sort-by', - dest='sort_by', - required=False, - help=Help.param_dataset_sort_by) - parser_datasets_list.add_argument( - '--size', dest='size', required=False, help=Help.param_dataset_size) - parser_datasets_list.add_argument( - '--file-type', - dest='file_type', - required=False, - help=Help.param_dataset_file_type) - parser_datasets_list.add_argument( - '--license', - dest='license_name', - required=False, - help=Help.param_dataset_license) - parser_datasets_list.add_argument( - '--tags', dest='tag_ids', required=False, help=Help.param_dataset_tags) - parser_datasets_list.add_argument( - '-s', - '--search', - dest='search', - required=False, - help=Help.param_search) - parser_datasets_list.add_argument( - '-m', '--mine', dest='mine', action='store_true', help=Help.param_mine) - parser_datasets_list.add_argument( - '--user', dest='user', required=False, help=Help.param_dataset_user) - parser_datasets_list.add_argument( - '-p', - '--page', - dest='page', - default=1, - required=False, - help=Help.param_page) - parser_datasets_list.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) - parser_datasets_list.add_argument( - '--max-size', - dest='max_size', - required=False, - help=Help.param_dataset_maxsize) - parser_datasets_list.add_argument( - '--min-size', - dest='min_size', - required=False, - help=Help.param_dataset_minsize) + parser_datasets_list.add_argument('--sort-by', + dest='sort_by', + required=False, + help=Help.param_dataset_sort_by) + parser_datasets_list.add_argument('--size', + dest='size', + required=False, + help=Help.param_dataset_size) + parser_datasets_list.add_argument('--file-type', + dest='file_type', + required=False, + help=Help.param_dataset_file_type) + parser_datasets_list.add_argument('--license', + dest='license_name', + required=False, + help=Help.param_dataset_license) + parser_datasets_list.add_argument('--tags', + dest='tag_ids', + required=False, + help=Help.param_dataset_tags) + parser_datasets_list.add_argument('-s', + '--search', + dest='search', + required=False, + help=Help.param_search) + parser_datasets_list.add_argument('-m', + '--mine', + dest='mine', + action='store_true', + help=Help.param_mine) + parser_datasets_list.add_argument('--user', + dest='user', + required=False, + help=Help.param_dataset_user) + parser_datasets_list.add_argument('-p', + '--page', + dest='page', + default=1, + required=False, + help=Help.param_page) + parser_datasets_list.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) + parser_datasets_list.add_argument('--max-size', + dest='max_size', + required=False, + help=Help.param_dataset_maxsize) + parser_datasets_list.add_argument('--min-size', + dest='min_size', + required=False, + help=Help.param_dataset_minsize) parser_datasets_list._action_groups.append(parser_datasets_list_optional) parser_datasets_list.set_defaults(func=api.dataset_list_cli) @@ -440,31 +440,29 @@ def parse_datasets(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_datasets_files) parser_datasets_files_optional = parser_datasets_files._action_groups.pop() - parser_datasets_files_optional.add_argument( - 'dataset', nargs='?', default=None, help=Help.param_dataset) - parser_datasets_files_optional.add_argument( - '-d', - '--dataset', - dest='dataset_opt', - required=False, - help=argparse.SUPPRESS) - parser_datasets_files_optional.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) - parser_datasets_files_optional.add_argument( - '--page-token', - dest='page_token', - required=False, - help=Help.param_page_token) - parser_datasets_files_optional.add_argument( - '--page-size', - dest='page_size', - required=False, - default=20, - help=Help.param_page_size) + parser_datasets_files_optional.add_argument('dataset', + nargs='?', + default=None, + help=Help.param_dataset) + parser_datasets_files_optional.add_argument('-d', + '--dataset', + dest='dataset_opt', + required=False, + help=argparse.SUPPRESS) + parser_datasets_files_optional.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) + parser_datasets_files_optional.add_argument('--page-token', + dest='page_token', + required=False, + help=Help.param_page_token) + parser_datasets_files_optional.add_argument('--page-size', + dest='page_size', + required=False, + default=20, + help=Help.param_page_size) parser_datasets_files._action_groups.append(parser_datasets_files_optional) parser_datasets_files.set_defaults(func=api.dataset_list_files_cli) @@ -475,48 +473,47 @@ def parse_datasets(subparsers): help=Help.command_datasets_download) parser_datasets_download_optional = parser_datasets_download._action_groups.pop( ) - parser_datasets_download_optional.add_argument( - 'dataset', nargs='?', default=None, help=Help.param_dataset) - parser_datasets_download_optional.add_argument( - '-d', - '--dataset', - dest='dataset_opt', - required=False, - help=argparse.SUPPRESS) + parser_datasets_download_optional.add_argument('dataset', + nargs='?', + default=None, + help=Help.param_dataset) + parser_datasets_download_optional.add_argument('-d', + '--dataset', + dest='dataset_opt', + required=False, + help=argparse.SUPPRESS) parser_datasets_download_optional.add_argument( '-f', '--file', dest='file_name', required=False, help=Help.param_dataset_file) - parser_datasets_download_optional.add_argument( - '-p', - '--path', - dest='path', - required=False, - help=Help.param_downfolder) - parser_datasets_download_optional.add_argument( - '-w', - '--wp', - dest='path', - action='store_const', - const='.', - required=False, - help=Help.param_wp) - parser_datasets_download_optional.add_argument( - '--unzip', dest='unzip', action='store_true', help=Help.param_unzip) - parser_datasets_download_optional.add_argument( - '-o', - '--force', - dest='force', - action='store_true', - help=Help.param_force) - parser_datasets_download_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - help=Help.param_quiet) + parser_datasets_download_optional.add_argument('-p', + '--path', + dest='path', + required=False, + help=Help.param_downfolder) + parser_datasets_download_optional.add_argument('-w', + '--wp', + dest='path', + action='store_const', + const='.', + required=False, + help=Help.param_wp) + parser_datasets_download_optional.add_argument('--unzip', + dest='unzip', + action='store_true', + help=Help.param_unzip) + parser_datasets_download_optional.add_argument('-o', + '--force', + dest='force', + action='store_true', + help=Help.param_force) + parser_datasets_download_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + help=Help.param_quiet) parser_datasets_download._action_groups.append( parser_datasets_download_optional) parser_datasets_download.set_defaults(func=api.dataset_download_cli) @@ -534,24 +531,21 @@ def parse_datasets(subparsers): dest='folder', required=False, help=Help.param_dataset_upfile) - parser_datasets_create_optional.add_argument( - '-u', - '--public', - dest='public', - action='store_true', - help=Help.param_public) - parser_datasets_create_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - help=Help.param_quiet) - parser_datasets_create_optional.add_argument( - '-t', - '--keep-tabular', - dest='convert_to_csv', - action='store_false', - help=Help.param_keep_tabular) + parser_datasets_create_optional.add_argument('-u', + '--public', + dest='public', + action='store_true', + help=Help.param_public) + parser_datasets_create_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + help=Help.param_quiet) + parser_datasets_create_optional.add_argument('-t', + '--keep-tabular', + dest='convert_to_csv', + action='store_false', + help=Help.param_keep_tabular) parser_datasets_create_optional.add_argument( '-r', '--dir-mode', @@ -584,18 +578,16 @@ def parse_datasets(subparsers): dest='folder', required=False, help=Help.param_dataset_upfile) - parser_datasets_version_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - help=Help.param_quiet) - parser_datasets_version_optional.add_argument( - '-t', - '--keep-tabular', - dest='convert_to_csv', - action='store_false', - help=Help.param_keep_tabular) + parser_datasets_version_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + help=Help.param_quiet) + parser_datasets_version_optional.add_argument('-t', + '--keep-tabular', + dest='convert_to_csv', + action='store_false', + help=Help.param_keep_tabular) parser_datasets_version_optional.add_argument( '-r', '--dir-mode', @@ -619,12 +611,11 @@ def parse_datasets(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_datasets_init) parser_datasets_init_optional = parser_datasets_init._action_groups.pop() - parser_datasets_init_optional.add_argument( - '-p', - '--path', - dest='folder', - required=False, - help=Help.param_dataset_upfile) + parser_datasets_init_optional.add_argument('-p', + '--path', + dest='folder', + required=False, + help=Help.param_dataset_upfile) parser_datasets_init._action_groups.append(parser_datasets_init_optional) parser_datasets_init.set_defaults(func=api.dataset_initialize_cli) @@ -635,14 +626,15 @@ def parse_datasets(subparsers): help=Help.command_datasets_metadata) parser_datasets_metadata_optional = parser_datasets_metadata._action_groups.pop( ) - parser_datasets_metadata_optional.add_argument( - 'dataset', nargs='?', default=None, help=Help.param_dataset) - parser_datasets_metadata_optional.add_argument( - '-d', - '--dataset', - dest='dataset_opt', - required=False, - help=argparse.SUPPRESS) + parser_datasets_metadata_optional.add_argument('dataset', + nargs='?', + default=None, + help=Help.param_dataset) + parser_datasets_metadata_optional.add_argument('-d', + '--dataset', + dest='dataset_opt', + required=False, + help=argparse.SUPPRESS) parser_datasets_metadata_optional.add_argument( '--update', dest='update', @@ -661,14 +653,15 @@ def parse_datasets(subparsers): help=Help.command_datasets_status) parser_datasets_status_optional = parser_datasets_status._action_groups.pop( ) - parser_datasets_status_optional.add_argument( - 'dataset', nargs='?', default=None, help=Help.param_dataset) - parser_datasets_status_optional.add_argument( - '-d', - '--dataset', - dest='dataset_opt', - required=False, - help=argparse.SUPPRESS) + parser_datasets_status_optional.add_argument('dataset', + nargs='?', + default=None, + help=Help.param_dataset) + parser_datasets_status_optional.add_argument('-d', + '--dataset', + dest='dataset_opt', + required=False, + help=argparse.SUPPRESS) parser_datasets_status._action_groups.append( parser_datasets_status_optional) parser_datasets_status.set_defaults(func=api.dataset_status_cli) @@ -686,8 +679,8 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.group_kernels, aliases=['k']) - subparsers_kernels = parser_kernels.add_subparsers( - title='commands', dest='command') + subparsers_kernels = parser_kernels.add_subparsers(title='commands', + dest='command') subparsers_kernels.required = True subparsers_kernels.choices = Help.kernels_choices @@ -697,57 +690,63 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_kernels_list) parser_kernels_list_optional = parser_kernels_list._action_groups.pop() - parser_kernels_list_optional.add_argument( - '-m', '--mine', dest='mine', action='store_true', help=Help.param_mine) - parser_kernels_list_optional.add_argument( - '-p', '--page', dest='page', default=1, help=Help.param_page) - parser_kernels_list_optional.add_argument( - '--page-size', dest='page_size', default=20, help=Help.param_page_size) - parser_kernels_list_optional.add_argument( - '-s', '--search', dest='search', help=Help.param_search) - parser_kernels_list_optional.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) - parser_kernels_list_optional.add_argument( - '--parent', - dest='parent', - required=False, - help=Help.param_kernel_parent) + parser_kernels_list_optional.add_argument('-m', + '--mine', + dest='mine', + action='store_true', + help=Help.param_mine) + parser_kernels_list_optional.add_argument('-p', + '--page', + dest='page', + default=1, + help=Help.param_page) + parser_kernels_list_optional.add_argument('--page-size', + dest='page_size', + default=20, + help=Help.param_page_size) + parser_kernels_list_optional.add_argument('-s', + '--search', + dest='search', + help=Help.param_search) + parser_kernels_list_optional.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) + parser_kernels_list_optional.add_argument('--parent', + dest='parent', + required=False, + help=Help.param_kernel_parent) parser_kernels_list_optional.add_argument( '--competition', dest='competition', required=False, help=Help.param_kernel_competition) - parser_kernels_list_optional.add_argument( - '--dataset', - dest='dataset', - required=False, - help=Help.param_kernel_dataset) - parser_kernels_list_optional.add_argument( - '--user', dest='user', required=False, help=Help.param_kernel_user) - parser_kernels_list_optional.add_argument( - '--language', - dest='language', - required=False, - help=Help.param_kernel_language) - parser_kernels_list_optional.add_argument( - '--kernel-type', - dest='kernel_type', - required=False, - help=Help.param_kernel_type) + parser_kernels_list_optional.add_argument('--dataset', + dest='dataset', + required=False, + help=Help.param_kernel_dataset) + parser_kernels_list_optional.add_argument('--user', + dest='user', + required=False, + help=Help.param_kernel_user) + parser_kernels_list_optional.add_argument('--language', + dest='language', + required=False, + help=Help.param_kernel_language) + parser_kernels_list_optional.add_argument('--kernel-type', + dest='kernel_type', + required=False, + help=Help.param_kernel_type) parser_kernels_list_optional.add_argument( '--output-type', dest='output_type', required=False, help=Help.param_kernel_output_type) - parser_kernels_list_optional.add_argument( - '--sort-by', - dest='sort_by', - required=False, - help=Help.param_kernel_sort_by) + parser_kernels_list_optional.add_argument('--sort-by', + dest='sort_by', + required=False, + help=Help.param_kernel_sort_by) parser_kernels_list._action_groups.append(parser_kernels_list_optional) parser_kernels_list.set_defaults(func=api.kernels_list_cli) @@ -757,24 +756,27 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_kernels_files) parser_kernels_files_optional = parser_kernels_files._action_groups.pop() - parser_kernels_files_optional.add_argument( - 'kernel', nargs='?', default=None, help=Help.param_kernel) - parser_kernels_files_optional.add_argument( - '-k', - '--kernel', - dest='kernel_opt', - required=False, - help=argparse.SUPPRESS) - parser_kernels_files_optional.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) - parser_kernels_files_optional.add_argument( - '--page-token', dest='page_token', help=Help.param_page_token) - parser_kernels_files_optional.add_argument( - '--page-size', dest='page_size', default=20, help=Help.param_page_size) + parser_kernels_files_optional.add_argument('kernel', + nargs='?', + default=None, + help=Help.param_kernel) + parser_kernels_files_optional.add_argument('-k', + '--kernel', + dest='kernel_opt', + required=False, + help=argparse.SUPPRESS) + parser_kernels_files_optional.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) + parser_kernels_files_optional.add_argument('--page-token', + dest='page_token', + help=Help.param_page_token) + parser_kernels_files_optional.add_argument('--page-size', + dest='page_size', + default=20, + help=Help.param_page_size) parser_kernels_files._action_groups.append(parser_kernels_files_optional) parser_kernels_files.set_defaults(func=api.kernels_list_files_cli) @@ -784,12 +786,11 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_kernels_init) parser_kernels_init_optional = parser_kernels_init._action_groups.pop() - parser_kernels_init_optional.add_argument( - '-p', - '--path', - dest='folder', - required=False, - help=Help.param_kernel_upfile) + parser_kernels_init_optional.add_argument('-p', + '--path', + dest='folder', + required=False, + help=Help.param_kernel_upfile) parser_kernels_init._action_groups.append(parser_kernels_init_optional) parser_kernels_init.set_defaults(func=api.kernels_initialize_cli) @@ -799,12 +800,11 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_kernels_push) parser_kernels_push_optional = parser_kernels_push._action_groups.pop() - parser_kernels_push_optional.add_argument( - '-p', - '--path', - dest='folder', - required=False, - help=Help.param_kernel_upfile) + parser_kernels_push_optional.add_argument('-p', + '--path', + dest='folder', + required=False, + help=Help.param_kernel_upfile) parser_kernels_push._action_groups.append(parser_kernels_push_optional) parser_kernels_push.set_defaults(func=api.kernels_push_cli) @@ -814,28 +814,27 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_kernels_pull) parser_kernels_pull_optional = parser_kernels_pull._action_groups.pop() - parser_kernels_pull_optional.add_argument( - 'kernel', nargs='?', default=None, help=Help.param_kernel) - parser_kernels_pull_optional.add_argument( - '-k', - '--kernel', - dest='kernel', - required=False, - help=argparse.SUPPRESS) - parser_kernels_pull_optional.add_argument( - '-p', - '--path', - dest='path', - required=False, - help=Help.param_downfolder) - parser_kernels_pull_optional.add_argument( - '-w', - '--wp', - dest='path', - action='store_const', - const='.', - required=False, - help=Help.param_wp) + parser_kernels_pull_optional.add_argument('kernel', + nargs='?', + default=None, + help=Help.param_kernel) + parser_kernels_pull_optional.add_argument('-k', + '--kernel', + dest='kernel', + required=False, + help=argparse.SUPPRESS) + parser_kernels_pull_optional.add_argument('-p', + '--path', + dest='path', + required=False, + help=Help.param_downfolder) + parser_kernels_pull_optional.add_argument('-w', + '--wp', + dest='path', + action='store_const', + const='.', + required=False, + help=Help.param_wp) parser_kernels_pull_optional.add_argument( '-m', '--metadata', @@ -851,42 +850,39 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_kernels_output) parser_kernels_output_optional = parser_kernels_output._action_groups.pop() - parser_kernels_output_optional.add_argument( - 'kernel', nargs='?', default=None, help=Help.param_kernel) - parser_kernels_output_optional.add_argument( - '-k', - '--kernel', - dest='kernel_opt', - required=False, - help=argparse.SUPPRESS) - parser_kernels_output_optional.add_argument( - '-p', - '--path', - dest='path', - required=False, - help=Help.param_downfolder) - parser_kernels_output_optional.add_argument( - '-w', - '--wp', - dest='path', - action='store_const', - const='.', - required=False, - help=Help.param_wp) - parser_kernels_output_optional.add_argument( - '-o', - '--force', - dest='force', - action='store_true', - required=False, - help=Help.param_force) - parser_kernels_output_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - required=False, - help=Help.param_quiet) + parser_kernels_output_optional.add_argument('kernel', + nargs='?', + default=None, + help=Help.param_kernel) + parser_kernels_output_optional.add_argument('-k', + '--kernel', + dest='kernel_opt', + required=False, + help=argparse.SUPPRESS) + parser_kernels_output_optional.add_argument('-p', + '--path', + dest='path', + required=False, + help=Help.param_downfolder) + parser_kernels_output_optional.add_argument('-w', + '--wp', + dest='path', + action='store_const', + const='.', + required=False, + help=Help.param_wp) + parser_kernels_output_optional.add_argument('-o', + '--force', + dest='force', + action='store_true', + required=False, + help=Help.param_force) + parser_kernels_output_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + required=False, + help=Help.param_quiet) parser_kernels_output._action_groups.append(parser_kernels_output_optional) parser_kernels_output.set_defaults(func=api.kernels_output_cli) @@ -896,14 +892,15 @@ def parse_kernels(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_kernels_status) parser_kernels_status_optional = parser_kernels_status._action_groups.pop() - parser_kernels_status_optional.add_argument( - 'kernel', nargs='?', default=None, help=Help.param_kernel) - parser_kernels_status_optional.add_argument( - '-k', - '--kernel', - dest='kernel_opt', - required=False, - help=argparse.SUPPRESS) + parser_kernels_status_optional.add_argument('kernel', + nargs='?', + default=None, + help=Help.param_kernel) + parser_kernels_status_optional.add_argument('-k', + '--kernel', + dest='kernel_opt', + required=False, + help=argparse.SUPPRESS) parser_kernels_status._action_groups.append(parser_kernels_status_optional) parser_kernels_status.set_defaults(func=api.kernels_status_cli) @@ -915,8 +912,8 @@ def parse_models(subparsers): help=Help.group_models, aliases=['m']) - subparsers_models = parser_models.add_subparsers( - title='commands', dest='command') + subparsers_models = parser_models.add_subparsers(title='commands', + dest='command') subparsers_models.required = True subparsers_models.choices = Help.models_choices @@ -930,12 +927,11 @@ def parse_models(subparsers): help=Help.command_models_get) parser_models_get_optional = parser_models_get._action_groups.pop() parser_models_get_optional.add_argument('model', help=Help.param_model) - parser_models_get_optional.add_argument( - '-p', - '--path', - dest='folder', - required=False, - help=Help.param_model_downfile) + parser_models_get_optional.add_argument('-p', + '--path', + dest='folder', + required=False, + help=Help.param_model_downfile) parser_models_get._action_groups.append(parser_models_get_optional) parser_models_get.set_defaults(func=api.model_get_cli) @@ -945,32 +941,32 @@ def parse_models(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_models_list) parser_models_list_optional = parser_models_list._action_groups.pop() - parser_models_list.add_argument( - '--sort-by', - dest='sort_by', - required=False, - help=Help.param_model_sort_by) - parser_models_list.add_argument( - '-s', - '--search', - dest='search', - required=False, - help=Help.param_search) - parser_models_list.add_argument( - '--owner', dest='owner', required=False, help=Help.param_model_owner) - parser_models_list.add_argument( - '--page-size', dest='page_size', default=20, help=Help.param_page_size) - parser_models_list.add_argument( - '--page-token', - dest='page_token', - required=False, - help=Help.param_page_token) - parser_models_list.add_argument( - '-v', - '--csv', - dest='csv_display', - action='store_true', - help=Help.param_csv) + parser_models_list.add_argument('--sort-by', + dest='sort_by', + required=False, + help=Help.param_model_sort_by) + parser_models_list.add_argument('-s', + '--search', + dest='search', + required=False, + help=Help.param_search) + parser_models_list.add_argument('--owner', + dest='owner', + required=False, + help=Help.param_model_owner) + parser_models_list.add_argument('--page-size', + dest='page_size', + default=20, + help=Help.param_page_size) + parser_models_list.add_argument('--page-token', + dest='page_token', + required=False, + help=Help.param_page_token) + parser_models_list.add_argument('-v', + '--csv', + dest='csv_display', + action='store_true', + help=Help.param_csv) parser_models_list._action_groups.append(parser_models_list_optional) parser_models_list.set_defaults(func=api.model_list_cli) @@ -980,12 +976,11 @@ def parse_models(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_models_init) parser_models_init_optional = parser_models_init._action_groups.pop() - parser_models_init_optional.add_argument( - '-p', - '--path', - dest='folder', - required=False, - help=Help.param_model_upfile) + parser_models_init_optional.add_argument('-p', + '--path', + dest='folder', + required=False, + help=Help.param_model_upfile) parser_models_init._action_groups.append(parser_models_init_optional) parser_models_init.set_defaults(func=api.model_initialize_cli) @@ -995,12 +990,11 @@ def parse_models(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_models_new) parser_models_create_optional = parser_models_create._action_groups.pop() - parser_models_create_optional.add_argument( - '-p', - '--path', - dest='folder', - required=False, - help=Help.param_model_upfile) + parser_models_create_optional.add_argument('-p', + '--path', + dest='folder', + required=False, + help=Help.param_model_upfile) parser_models_create._action_groups.append(parser_models_create_optional) parser_models_create.set_defaults(func=api.model_create_new_cli) @@ -1011,8 +1005,11 @@ def parse_models(subparsers): help=Help.command_models_delete) parser_models_delete_optional = parser_models_delete._action_groups.pop() parser_models_delete_optional.add_argument('model', help=Help.param_model) - parser_models_delete_optional.add_argument( - '-y', '--yes', dest='yes', action='store_true', help=Help.param_yes) + parser_models_delete_optional.add_argument('-y', + '--yes', + dest='yes', + action='store_true', + help=Help.param_yes) parser_models_delete._action_groups.append(parser_models_delete_optional) parser_models_delete.set_defaults(func=api.model_delete_cli) @@ -1022,12 +1019,11 @@ def parse_models(subparsers): formatter_class=argparse.RawTextHelpFormatter, help=Help.command_models_update) parser_models_update_optional = parser_models_update._action_groups.pop() - parser_models_update_optional.add_argument( - '-p', - '--path', - dest='folder', - required=False, - help=Help.param_model_upfile) + parser_models_update_optional.add_argument('-p', + '--path', + dest='folder', + required=False, + help=Help.param_model_upfile) parser_models_update._action_groups.append(parser_models_update_optional) parser_models_update.set_defaults(func=api.model_update_cli) @@ -1097,12 +1093,11 @@ def parse_model_instances(subparsers): dest='folder', required=False, help=Help.param_model_instance_upfile) - parser_model_instances_create_optional.add_argument( - '-q', - '--quiet', - dest='quiet', - action='store_true', - help=Help.param_quiet) + parser_model_instances_create_optional.add_argument('-q', + '--quiet', + dest='quiet', + action='store_true', + help=Help.param_quiet) parser_model_instances_create_optional.add_argument( '-r', '--dir-mode', @@ -1124,8 +1119,11 @@ def parse_model_instances(subparsers): ) parser_model_instances_delete_optional.add_argument( 'model_instance', help=Help.param_model_instance) - parser_model_instances_delete_optional.add_argument( - '-y', '--yes', dest='yes', action='store_true', help=Help.param_yes) + parser_model_instances_delete_optional.add_argument('-y', + '--yes', + dest='yes', + action='store_true', + help=Help.param_yes) parser_model_instances_delete._action_groups.append( parser_model_instances_delete_optional) parser_model_instances_delete.set_defaults( @@ -1286,8 +1284,8 @@ def parse_files(subparsers): help=Help.group_files, aliases=['f']) - subparsers_files = parser_files.add_subparsers( - title='commands', dest='command') + subparsers_files = parser_files.add_subparsers(title='commands', + dest='command') subparsers_files.required = True subparsers_files.choices = Help.files_choices @@ -1333,8 +1331,8 @@ def parse_config(subparsers): 'config', formatter_class=argparse.RawTextHelpFormatter, help=Help.group_config) - subparsers_config = parser_config.add_subparsers( - title='commands', dest='command') + subparsers_config = parser_config.add_subparsers(title='commands', + dest='command') subparsers_config.required = True subparsers_config.choices = Help.config_choices @@ -1351,18 +1349,16 @@ def parse_config(subparsers): parser_config_set._action_groups.pop() parser_config_set_required = parser_config_set.add_argument_group( 'required arguments') - parser_config_set_required.add_argument( - '-n', - '--name', - dest='name', - required=True, - help=Help.param_config_name) - parser_config_set_required.add_argument( - '-v', - '--value', - dest='value', - required=True, - help=Help.param_config_value) + parser_config_set_required.add_argument('-n', + '--name', + dest='name', + required=True, + help=Help.param_config_name) + parser_config_set_required.add_argument('-v', + '--value', + dest='value', + required=True, + help=Help.param_config_value) parser_config_set.set_defaults(func=api.set_config_value) parser_config_unset = subparsers_config.add_parser( @@ -1372,12 +1368,11 @@ def parse_config(subparsers): parser_config_unset._action_groups.pop() parser_config_unset_required = parser_config_unset.add_argument_group( 'required arguments') - parser_config_unset_required.add_argument( - '-n', - '--name', - dest='name', - required=True, - help=Help.param_config_name) + parser_config_unset_required.add_argument('-n', + '--name', + dest='name', + required=True, + help=Help.param_config_name) parser_config_unset.set_defaults(func=api.unset_config_value) diff --git a/kaggle/configuration.py b/kaggle/configuration.py index 9610cad..4308e17 100644 --- a/kaggle/configuration.py +++ b/kaggle/configuration.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/__init__.py b/kaggle/models/__init__.py index c1faa09..999007e 100644 --- a/kaggle/models/__init__.py +++ b/kaggle/models/__init__.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 # flake8: noqa diff --git a/kaggle/models/api_blob_type.py b/kaggle/models/api_blob_type.py index 73b8766..dc6e44e 100644 --- a/kaggle/models/api_blob_type.py +++ b/kaggle/models/api_blob_type.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/collaborator.py b/kaggle/models/collaborator.py index d134ef1..16c5d6c 100644 --- a/kaggle/models/collaborator.py +++ b/kaggle/models/collaborator.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/create_inbox_file_request.py b/kaggle/models/create_inbox_file_request.py index f40be73..cc40603 100644 --- a/kaggle/models/create_inbox_file_request.py +++ b/kaggle/models/create_inbox_file_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/dataset_column.py b/kaggle/models/dataset_column.py index a2b4ff9..72008d2 100644 --- a/kaggle/models/dataset_column.py +++ b/kaggle/models/dataset_column.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/dataset_new_request.py b/kaggle/models/dataset_new_request.py index 58f2c8b..175a542 100644 --- a/kaggle/models/dataset_new_request.py +++ b/kaggle/models/dataset_new_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/dataset_new_version_request.py b/kaggle/models/dataset_new_version_request.py index ab7140c..941184f 100644 --- a/kaggle/models/dataset_new_version_request.py +++ b/kaggle/models/dataset_new_version_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/dataset_update_settings_request.py b/kaggle/models/dataset_update_settings_request.py index 36469f9..eef92f1 100644 --- a/kaggle/models/dataset_update_settings_request.py +++ b/kaggle/models/dataset_update_settings_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/error.py b/kaggle/models/error.py index 7abab1f..ac7253e 100644 --- a/kaggle/models/error.py +++ b/kaggle/models/error.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/kaggle_models_extended.py b/kaggle/models/kaggle_models_extended.py index b745fd5..3f11b6d 100644 --- a/kaggle/models/kaggle_models_extended.py +++ b/kaggle/models/kaggle_models_extended.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + #!/usr/bin/python # # Copyright 2019 Kaggle Inc @@ -21,6 +37,7 @@ class Competition(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -31,6 +48,7 @@ def __repr__(self): class SubmitResult(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -40,6 +58,7 @@ def __repr__(self): class Submission(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -53,6 +72,7 @@ def __repr__(self): class LeaderboardEntry(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -62,6 +82,7 @@ def __repr__(self): class Dataset(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -75,6 +96,7 @@ def __repr__(self): class Model(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -84,6 +106,7 @@ def __repr__(self): class Metadata(object): + def __init__(self, init_info): parsed_info = {k: parse(v) for k, v in init_info.items()} # backwards compatibility @@ -96,6 +119,7 @@ def __repr__(self): class DatasetVersion(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -105,6 +129,7 @@ def __repr__(self): class File(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -124,6 +149,7 @@ def get_size(size, precision=0): class Tag(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -133,6 +159,7 @@ def __repr__(self): class DatasetNewVersionResponse(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -142,6 +169,7 @@ def __repr__(self): class DatasetNewResponse(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -151,6 +179,7 @@ def __repr__(self): class ListFilesResult(object): + def __init__(self, init_dict): self.error_message = init_dict['errorMessage'] files = init_dict['datasetFiles'] @@ -169,6 +198,7 @@ def __repr__(self): class Kernel: + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -178,6 +208,7 @@ def __repr__(self): class KernelPushResponse(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -187,6 +218,7 @@ def __repr__(self): class ModelNewResponse(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) @@ -196,6 +228,7 @@ def __repr__(self): class ModelDeleteResponse(object): + def __init__(self, init_dict): parsed_dict = {k: parse(v) for k, v in init_dict.items()} self.__dict__.update(parsed_dict) diff --git a/kaggle/models/kernel_push_request.py b/kaggle/models/kernel_push_request.py index a4022aa..8d7cac8 100644 --- a/kaggle/models/kernel_push_request.py +++ b/kaggle/models/kernel_push_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/license.py b/kaggle/models/license.py index 48d8164..0135e8e 100644 --- a/kaggle/models/license.py +++ b/kaggle/models/license.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/model_instance_new_version_request.py b/kaggle/models/model_instance_new_version_request.py index 2c9e6e9..d6bdb9e 100644 --- a/kaggle/models/model_instance_new_version_request.py +++ b/kaggle/models/model_instance_new_version_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/model_instance_update_request.py b/kaggle/models/model_instance_update_request.py index 05ce871..9288b70 100644 --- a/kaggle/models/model_instance_update_request.py +++ b/kaggle/models/model_instance_update_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/model_new_instance_request.py b/kaggle/models/model_new_instance_request.py index 346ad1b..43830dc 100644 --- a/kaggle/models/model_new_instance_request.py +++ b/kaggle/models/model_new_instance_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/model_new_request.py b/kaggle/models/model_new_request.py index f9f2d18..767c4e7 100644 --- a/kaggle/models/model_new_request.py +++ b/kaggle/models/model_new_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/model_update_request.py b/kaggle/models/model_update_request.py index a15f573..fd4b969 100644 --- a/kaggle/models/model_update_request.py +++ b/kaggle/models/model_update_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/result.py b/kaggle/models/result.py index e4ce2de..3cf8bfe 100644 --- a/kaggle/models/result.py +++ b/kaggle/models/result.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/start_blob_upload_request.py b/kaggle/models/start_blob_upload_request.py index 19443a9..4c78202 100644 --- a/kaggle/models/start_blob_upload_request.py +++ b/kaggle/models/start_blob_upload_request.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/start_blob_upload_response.py b/kaggle/models/start_blob_upload_response.py index 9fabaf7..75adc58 100644 --- a/kaggle/models/start_blob_upload_response.py +++ b/kaggle/models/start_blob_upload_response.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/models/upload_file.py b/kaggle/models/upload_file.py index 77059ba..61a7d83 100644 --- a/kaggle/models/upload_file.py +++ b/kaggle/models/upload_file.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/rest.py b/kaggle/rest.py index 94c68a9..d8e26ab 100644 --- a/kaggle/rest.py +++ b/kaggle/rest.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # coding: utf-8 """ diff --git a/kaggle/test/__init__.py b/kaggle/test/__init__.py index e69de29..7aaef87 100644 --- a/kaggle/test/__init__.py +++ b/kaggle/test/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/kaggle/test/test_authenticate.py b/kaggle/test/test_authenticate.py index e50f90e..af8e92f 100644 --- a/kaggle/test/test_authenticate.py +++ b/kaggle/test/test_authenticate.py @@ -1,3 +1,19 @@ +#!/usr/bin/python +# +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from kaggle.api.kaggle_api_extended import KaggleApi # python -m unittest tests.test_authenticate @@ -7,6 +23,7 @@ class TestAuthenticate(unittest.TestCase): + def setUp(self): print("setup class:%s" % self)