34
34
import urllib3 .exceptions as urllib3_exceptions
35
35
from requests import RequestException
36
36
37
- from kaggle .models .kaggle_models_extended import ResumableUploadResult , File , Kernel
37
+ from kaggle .models .kaggle_models_extended import ResumableUploadResult , File
38
38
39
39
from requests .adapters import HTTPAdapter
40
40
from slugify import slugify
59
59
ApiDatasetNewFile ,
60
60
ApiUpdateDatasetMetadataRequest ,
61
61
ApiGetDatasetMetadataRequest ,
62
- ApiListDatasetFilesResponse ,
63
62
ApiDatasetFile ,
64
63
)
65
64
from kagglesdk .datasets .types .dataset_enums import (
108
107
109
108
class DirectoryArchive (object ):
110
109
111
- def __init__ (self , fullpath , format ):
110
+ def __init__ (self , fullpath , fmt ):
112
111
self ._fullpath = fullpath
113
- self ._format = format
112
+ self ._format = fmt
114
113
self .name = None
115
114
self .path = None
116
115
@@ -216,7 +215,7 @@ def _is_previous_valid(self, previous):
216
215
and previous .timestamp > time .time () - ResumableFileUpload .RESUMABLE_UPLOAD_EXPIRY_SECONDS
217
216
)
218
217
219
- def upload_initiated (self , start_blob_upload_response ):
218
+ def upload_initiated (self , start_blob_upload_response : ApiStartBlobUploadRequest ):
220
219
if self .context .no_resume :
221
220
return
222
221
@@ -339,7 +338,7 @@ class KaggleApi:
339
338
# Competitions valid types
340
339
valid_competition_groups = ['general' , 'entered' , 'community' , 'hosted' , 'unlaunched' , 'unlaunched_community' ]
341
340
valid_competition_categories = [
342
- 'all ' ,
341
+ 'unspecified ' ,
343
342
'featured' ,
344
343
'research' ,
345
344
'recruitment' ,
@@ -460,7 +459,7 @@ def authenticate(self) -> None:
460
459
# Step 3: load into configuration!
461
460
self ._load_config (config_data )
462
461
463
- def _is_help_or_version_command (self , api_command ):
462
+ def _is_help_or_version_command (self , api_command : str ):
464
463
"""Determines if the string command passed in is for a help or version
465
464
command.
466
465
@@ -471,9 +470,7 @@ def _is_help_or_version_command(self, api_command):
471
470
"""
472
471
return api_command .endswith (('-h' , '--help' , '-v' , '--version' ))
473
472
474
- def read_config_environment (
475
- self , config_data : Optional [Dict [Any , Any ]] = None , quiet : bool = False
476
- ) -> Dict [str , str ]:
473
+ def read_config_environment (self , config_data : Optional [Dict [str , str ]] = None ) -> Dict [str , str ]:
477
474
"""read_config_environment is the second effort to get a username and key
478
475
to authenticate to the Kaggle API. The environment keys are equivalent to
479
476
the kaggle.json file, but with "KAGGLE_" prefix to define a unique
@@ -482,7 +479,6 @@ def read_config_environment(
482
479
Parameters
483
480
==========
484
481
config_data: a partially loaded configuration dictionary (optional)
485
- quiet: suppress verbose print of output (default is False)
486
482
"""
487
483
488
484
# Add all variables that start with KAGGLE_ to config data
@@ -722,7 +718,7 @@ def camel_to_snake(self, name: str) -> str:
722
718
name = re .sub ('(.)([A-Z][a-z]+)' , r'\1_\2' , name )
723
719
return re .sub ('([a-z0-9])([A-Z])' , r'\1_\2' , name ).lower ()
724
720
725
- def lookup_enum (self , enum_class : Any , item_name : str ) -> Enum :
721
+ def lookup_enum (self , enum_class , item_name : str ) -> Enum :
726
722
item = self .camel_to_snake (item_name ).upper ()
727
723
try :
728
724
return enum_class [item ]
@@ -739,7 +735,7 @@ def lookup_enum(self, enum_class: Any, item_name: str) -> Enum:
739
735
return enum_class [item ]
740
736
raise
741
737
742
- def short_enum_name (self , value ):
738
+ def short_enum_name (self , value : str ):
743
739
full_name = str (value )
744
740
names = full_name .split ('.' )
745
741
prefix_len = len (self .camel_to_snake (names [0 ])) + 1 # underscore
@@ -750,10 +746,10 @@ def short_enum_name(self, value):
750
746
def competitions_list (
751
747
self ,
752
748
group : Optional [str ] = None ,
753
- category : None = None ,
754
- sort_by : None = None ,
755
- page : int = 1 ,
756
- search : None = None ,
749
+ category : Optional [ str ] = None ,
750
+ sort_by : Optional [ str ] = None ,
751
+ page : Optional [ int ] = 1 ,
752
+ search : Optional [ str ] = None ,
757
753
):
758
754
"""Make a call to list competitions, format the response, and return a list
759
755
of ApiCompetition instances.
@@ -777,9 +773,12 @@ def competitions_list(
777
773
778
774
if category :
779
775
if category not in self .valid_competition_categories :
780
- raise ValueError (
781
- 'Invalid category specified. Valid options are ' + str (self .valid_competition_categories )
782
- )
776
+ if category == 'all' :
777
+ category = 'unspecified'
778
+ else :
779
+ raise ValueError (
780
+ 'Invalid category specified. Valid options are ' + str (self .valid_competition_categories )
781
+ )
783
782
category = self .lookup_enum (HostSegment , category )
784
783
785
784
if sort_by :
@@ -797,7 +796,15 @@ def competitions_list(
797
796
response = kaggle .competitions .competition_api_client .list_competitions (request )
798
797
return response .competitions
799
798
800
- def competitions_list_cli (self , group = None , category = None , sort_by = None , page = 1 , search = None , csv_display = False ):
799
+ def competitions_list_cli (
800
+ self ,
801
+ group : Optional [str ] = None ,
802
+ category : Optional [str ] = None ,
803
+ sort_by : Optional [str ] = None ,
804
+ page : Optional [int ] = 1 ,
805
+ search : Optional [str ] = None ,
806
+ csv_display : Optional [bool ] = False ,
807
+ ):
801
808
"""A wrapper for competitions_list for the client.
802
809
803
810
Parameters
0 commit comments