diff --git a/src/kaggle/api/kaggle_api_extended.py b/src/kaggle/api/kaggle_api_extended.py index 09fdfaf..5b40058 100644 --- a/src/kaggle/api/kaggle_api_extended.py +++ b/src/kaggle/api/kaggle_api_extended.py @@ -83,7 +83,6 @@ class DirectoryArchive(object): - def __init__(self, fullpath, format): self._fullpath = fullpath self._format = format @@ -93,8 +92,9 @@ 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,7 +103,6 @@ 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') @@ -349,7 +348,6 @@ 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: @@ -359,9 +357,8 @@ 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 @@ -389,8 +386,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 @@ -468,8 +465,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! @@ -690,11 +687,12 @@ 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, @@ -715,11 +713,12 @@ 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' @@ -772,9 +771,8 @@ 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 @@ -888,7 +886,7 @@ def competition_list_files(self, competition_list_files_result = self.process_response( self.competitions_data_list_files_with_http_info( id=competition, page_token=page_token, page_size=page_size)) - return [File(f) for f in competition_list_files_result] + return FileList(competition_list_files_result) def competition_list_files_cli(self, competition, @@ -917,14 +915,17 @@ def competition_list_files_cli(self, if competition is None: raise ValueError('No competition specified') else: - files = self.competition_list_files(competition, page_token, - page_size) + result = self.competition_list_files(competition, page_token, + page_size) + next_page_token = result.nextPageToken + if next_page_token != '': + print('Next Page Token = {}'.format(next_page_token)) fields = ['name', 'size', 'creationDate'] - if files: + if result: if csv_display: - self.print_csv(files, fields) + self.print_csv(result.files, fields) else: - self.print_table(files, fields) + self.print_table(result.files, fields) else: print('No files found') @@ -1146,9 +1147,8 @@ 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,17 +1174,18 @@ 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, @@ -1386,8 +1387,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): @@ -1569,19 +1570,21 @@ 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 @@ -1742,9 +1745,8 @@ 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) @@ -1811,8 +1813,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': @@ -1840,16 +1842,17 @@ 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, @@ -1944,28 +1947,30 @@ 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, @@ -2036,18 +2041,19 @@ 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, @@ -2070,18 +2076,19 @@ 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: @@ -2171,11 +2178,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': @@ -2285,9 +2292,8 @@ 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( @@ -2461,8 +2467,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') @@ -2518,10 +2524,8 @@ 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: @@ -2703,11 +2707,12 @@ 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 != '': @@ -2754,12 +2759,18 @@ 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 @@ -2767,8 +2778,10 @@ 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: @@ -2822,14 +2835,15 @@ 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))) @@ -2941,13 +2955,14 @@ 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))) @@ -3039,12 +3054,18 @@ 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 @@ -3058,12 +3079,17 @@ 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: @@ -3103,14 +3129,12 @@ def model_instance_create(self, folder, quiet=False, dir_mode='skip'): license_name = self.get_or_fail(meta_data, 'licenseName') fine_tunable = self.get_or_default(meta_data, 'fineTunable', False) training_data = self.get_or_default(meta_data, 'trainingData', []) - model_instance_type = self.get_or_default(meta_data, - 'modelInstanceType', - 'Unspecified') + 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': @@ -3155,9 +3179,8 @@ 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 @@ -3244,9 +3267,8 @@ 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': @@ -3345,8 +3367,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, @@ -3376,9 +3398,8 @@ 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( @@ -3470,11 +3491,12 @@ 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, @@ -3605,9 +3627,8 @@ 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 @@ -3629,10 +3650,9 @@ 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): @@ -3682,8 +3702,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) + '}') @@ -3835,10 +3855,9 @@ 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) @@ -3920,9 +3939,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 @@ -3966,11 +3985,12 @@ 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: @@ -3979,8 +3999,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) @@ -4304,7 +4324,6 @@ def confirmation(self): class TqdmBufferedReader(io.BufferedReader): - def __init__(self, raw, progress_bar): """ helper class to implement an io.BufferedReader Parameters @@ -4339,7 +4358,8 @@ def __init__(self, init_dict): files = init_dict['files'] if files: for f in files: - f['totalBytes'] = f['size'] + if 'size' in f: + f['totalBytes'] = f['size'] self.files = [File(f) for f in files] else: self.files = {} diff --git a/src/kaggle/cli.py b/src/kaggle/cli.py index 2eb5c5d..3803945 100644 --- a/src/kaggle/cli.py +++ b/src/kaggle/cli.py @@ -28,14 +28,14 @@ def main(): parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter) - parser.add_argument('-v', - '--version', - action='version', - version='Kaggle API ' + KaggleApi.__version__) - - subparsers = parser.add_subparsers(title='commands', - help=Help.kaggle, - dest='command') + parser.add_argument( + '-v', + '--version', + action='version', + version='Kaggle API ' + KaggleApi.__version__) + + subparsers = parser.add_subparsers( + title='commands', help=Help.kaggle, dest='command') subparsers.required = True subparsers.choices = Help.kaggle_choices parse_competitions(subparsers) @@ -121,22 +121,25 @@ 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) @@ -150,30 +153,35 @@ 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) @@ -187,11 +195,12 @@ 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', @@ -204,23 +213,26 @@ 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( @@ -237,27 +249,30 @@ 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) @@ -277,11 +292,12 @@ 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', @@ -322,11 +338,12 @@ 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', @@ -351,8 +368,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 @@ -362,59 +379,58 @@ 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) @@ -424,20 +440,20 @@ 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( + '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._action_groups.append(parser_datasets_files_optional) parser_datasets_files.set_defaults(func=api.dataset_list_files_cli) @@ -448,47 +464,48 @@ 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) @@ -506,21 +523,24 @@ 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', @@ -553,16 +573,18 @@ 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', @@ -586,11 +608,12 @@ 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) @@ -601,15 +624,14 @@ 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', @@ -628,15 +650,14 @@ 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) @@ -654,8 +675,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 @@ -665,63 +686,57 @@ 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) @@ -758,11 +773,12 @@ 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) @@ -772,11 +788,12 @@ 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) @@ -786,27 +803,28 @@ 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', @@ -822,39 +840,42 @@ 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) @@ -864,15 +885,14 @@ 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) @@ -884,8 +904,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 @@ -899,11 +919,12 @@ 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) @@ -913,32 +934,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) @@ -948,11 +969,12 @@ 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) @@ -962,11 +984,12 @@ 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) @@ -977,11 +1000,8 @@ 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) @@ -991,11 +1011,12 @@ 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) @@ -1065,11 +1086,12 @@ 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', @@ -1091,11 +1113,8 @@ 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( @@ -1256,8 +1275,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 @@ -1303,8 +1322,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 @@ -1321,16 +1340,18 @@ 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( @@ -1340,11 +1361,12 @@ 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/src/kaggle/models/kaggle_models_extended.py b/src/kaggle/models/kaggle_models_extended.py index f608cee..b745fd5 100644 --- a/src/kaggle/models/kaggle_models_extended.py +++ b/src/kaggle/models/kaggle_models_extended.py @@ -21,7 +21,6 @@ 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) @@ -32,7 +31,6 @@ 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) @@ -42,7 +40,6 @@ 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) @@ -56,7 +53,6 @@ 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) @@ -66,7 +62,6 @@ 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) @@ -80,7 +75,6 @@ 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) @@ -90,7 +84,6 @@ 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 @@ -103,7 +96,6 @@ 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) @@ -113,7 +105,6 @@ 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) @@ -133,7 +124,6 @@ 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) @@ -143,7 +133,6 @@ 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) @@ -153,7 +142,6 @@ 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) @@ -163,7 +151,6 @@ def __repr__(self): class ListFilesResult(object): - def __init__(self, init_dict): self.error_message = init_dict['errorMessage'] files = init_dict['datasetFiles'] @@ -182,7 +169,6 @@ 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) @@ -192,7 +178,6 @@ 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) @@ -202,7 +187,6 @@ 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) @@ -212,7 +196,6 @@ 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)