Kaggle / kaggle-api

Official Kaggle API
Apache License 2.0
6.3k stars 1.1k forks source link

ValueError: Invalid value for `token`, must not be `None` #566

Closed JavaZeroo closed 6 months ago

JavaZeroo commented 7 months ago

ValueError Traceback (most recent call last) Cell In[20], line 4 2 api = KaggleApi() 3 api.authenticate() ----> 4 api.dataset_create_new( 5 folder='/tmp/aiXcoder', 6 dir_mode="tar", 7 convert_to_csv=False, 8 public=False, 9 )

File /opt/conda/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:1774, in KaggleApi.dataset_create_new(self, folder, public, quiet, convert_to_csv, dir_mode) 1762 request = DatasetNewRequest(title=title, 1763 slug=dataset_slug, 1764 owner_slug=owner_slug, (...) 1770 convert_to_csv=convert_to_csv, 1771 category_ids=keywords) 1773 with ResumableUploadContext() as upload_context: -> 1774 self.upload_files(request, resources, folder, ApiBlobType.DATASET, 1775 upload_context, quiet, dir_mode) 1776 result = DatasetNewResponse( 1777 self.process_response( 1778 self.with_retry( 1779 self.datasets_create_new_with_http_info)(request))) 1781 return result

File /opt/conda/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:3626, in KaggleApi.upload_files(self, request, resources, folder, blob_type, upload_context, quiet, dir_mode) 3620 if (file_name in [ 3621 self.DATASET_METADATA_FILE, self.OLD_DATASET_METADATA_FILE, 3622 self.KERNEL_METADATA_FILE, self.MODEL_METADATA_FILE, 3623 self.MODEL_INSTANCE_METADATA_FILE 3624 ]): 3625 continue -> 3626 upload_file = self._upload_file_or_folder(folder, file_name, 3627 blob_type, 3628 upload_context, dir_mode, 3629 quiet, resources) 3630 if upload_file is not None: 3631 request.files.append(upload_file)

File /opt/conda/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:3643, in KaggleApi._upload_file_or_folder(self, parent_path, file_or_folder_name, blob_type, upload_context, dir_mode, quiet, resources) 3641 full_path = os.path.join(parent_path, file_or_folder_name) 3642 if os.path.isfile(full_path): -> 3643 return self._upload_file(file_or_folder_name, full_path, blob_type, 3644 upload_context, quiet, resources) 3646 elif os.path.isdir(full_path): 3647 if dir_mode in ['zip', 'tar']:

File /opt/conda/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:3678, in KaggleApi._upload_file(self, file_name, full_path, blob_type, upload_context, quiet, resources) 3675 print('Starting upload for file ' + file_name) 3677 content_length = os.path.getsize(full_path) -> 3678 token = self._upload_blob(full_path, quiet, blob_type, upload_context) 3679 if token is None: 3680 if not quiet:

File /opt/conda/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:1535, in KaggleApi._upload_blob(self, path, quiet, blob_type, upload_context) 1530 return file_upload 1532 if not file_upload.can_resume: 1533 # Initiate upload on Kaggle backend to get the url and token. 1534 start_blob_upload_response = self.process_response( -> 1535 self.with_retry(self.upload_file_with_http_info)( 1536 file_upload.start_blob_upload_request)) 1537 file_upload.upload_initiated(start_blob_upload_response) 1539 upload_result = self.upload_complete( 1540 path, 1541 file_upload.start_blob_upload_response.create_url, 1542 quiet, 1543 resume=file_upload.can_resume)

File /opt/conda/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:368, in KaggleApi.with_retry..retriable_func(args) 366 for i in range(1, max_retries + 1): 367 try: --> 368 return func(args) 369 except Exception as e: 370 if self._is_retriable(e) and i < max_retries:

File /opt/conda/lib/python3.10/site-packages/kaggle/api/kaggle_api.py:4243, in KaggleApi.upload_file_with_http_info(self, start_blob_upload_request, **kwargs) 4240 # Authentication setting 4241 auth_settings = ['basicAuth'] # noqa: E501 -> 4243 return self.api_client.call_api( 4244 '/blobs/upload', 'POST', 4245 path_params, 4246 query_params, 4247 header_params, 4248 body=body_params, 4249 post_params=form_params, 4250 files=local_var_files, 4251 response_type='StartBlobUploadResponse', # noqa: E501 4252 auth_settings=auth_settings, 4253 async_req=params.get('async_req'), 4254 _return_http_data_only=params.get('_return_http_data_only'), 4255 _preload_content=params.get('_preload_content', True), 4256 _request_timeout=params.get('_request_timeout'), 4257 collection_formats=collection_formats)

File /opt/conda/lib/python3.10/site-packages/kaggle/api_client.py:329, in ApiClient.call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _request_timeout) 292 """Makes the HTTP request (synchronous) and returns deserialized data. 293 294 To make an async request, set the async_req parameter. (...) 326 then the method will return the response directly. 327 """ 328 if not async_req: --> 329 return self.call_api(resource_path, method, 330 path_params, query_params, header_params, 331 body, post_params, files, 332 response_type, auth_settings, 333 _return_http_data_only, collection_formats, 334 _preload_content, _request_timeout) 335 else: 336 thread = self.pool.apply_async(self.call_api, (resource_path, 337 method, path_params, query_params, 338 header_params, body, (...) 342 collection_formats, 343 _preload_content, _request_timeout))

File /opt/conda/lib/python3.10/site-packages/kaggle/api_client.py:173, in ApiClient.__call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout) 170 if _preload_content: 171 # deserialize response data 172 if response_type: --> 173 return_data = self.deserialize(response_data, response_type) 174 else: 175 return_data = None

File /opt/conda/lib/python3.10/site-packages/kaggle/api_client.py:245, in ApiClient.deserialize(self, response, response_type) 242 except ValueError: 243 data = response.data --> 245 return self.__deserialize(data, response_type)

File /opt/conda/lib/python3.10/site-packages/kaggle/api_client.py:284, in ApiClient.deserialize(self, data, klass) 282 return self.deserialize_datatime(data) 283 else: --> 284 return self.__deserialize_model(data, klass)

File /opt/conda/lib/python3.10/site-packages/kaggle/api_client.py:627, in ApiClient.deserialize_model(self, data, klass) 624 value = data[klass.attribute_map[attr]] 625 kwargs[attr] = self.deserialize(value, attr_type) --> 627 instance = klass(**kwargs) 629 if hasattr(instance, 'get_real_child_model'): 630 klass_name = instance.get_real_child_model(data)

File /opt/conda/lib/python3.10/site-packages/kaggle/models/start_blob_upload_response.py:66, in StartBlobUploadResponse.init(self, token, create_url) 63 self._create_url = None 64 self.discriminator = None ---> 66 self.token = token 67 self.create_url = create_url

File /opt/conda/lib/python3.10/site-packages/kaggle/models/start_blob_upload_response.py:90, in StartBlobUploadResponse.token(self, token) 82 """Sets the token of this StartBlobUploadResponse. 83 84 Opaque string token used to reference the new blob/file. # noqa: E501 (...) 87 :type: str 88 """ 89 if token is None: ---> 90 raise ValueError("Invalid value for token, must not be None") # noqa: E501 92 self._token = token

ValueError: Invalid value for token, must not be None

Kaggle notebook: https://www.kaggle.com/code/jimmyisme1/aixcoder-aixcoder-7b-base/

stevemessick commented 6 months ago

In your notebook, cell 5 has this error message:

Dataset creation error: The requested title "aiXcoder" is already in use by a dataset. Please choose another title.