lightly-ai / lightly

A python library for self-supervised learning on images.
https://docs.lightly.ai/self-supervised-learning/
MIT License
3.17k stars 285 forks source link

Improve lightly-upload/magic error message when dataset name is malformed #614

Closed guarin closed 1 year ago

guarin commented 2 years ago

I tried to upload a dataset with points in its name and got the error message below. We should improve the error message to highlight that it failed due to the malformed dataset name, right now it is very cryptic.

(lightly) guarin_lightly_ai@guarin-gpu:~/lightly$ lightly-magic token=$TOKEN input_dir=/datasets/aquarium/ new_dataset_name="aquarium_v1.2.0" trainer.max_epochs=0
########## Starting to embed your dataset.
Compute efficiency: 0.22: 100%|█████████████████████████████████████████████████████████████████████████████| 28/28 [00:02<00:00, 10.77it/s]
Embeddings are stored at /home/guarin_lightly_ai/lightly/lightly_outputs/2021-12-01/09-50-15/embeddings.csv
########## Starting to upload your dataset to the Lightly platform.
Error executing job with overrides: ['token=###########', 'input_dir=/datasets/aquarium/', 'new_dataset_name=aquarium_v1.2.0', 'trainer.max_epochs=0']
Traceback (most recent call last):
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/api/api_workflow_datasets.py", line 25, in set_dataset_id_by_name
    dataset_with_specified_name = next(dataset for dataset in current_datasets if dataset.name == dataset_name)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/api/api_workflow_datasets.py", line 41, in create_dataset
    self.set_dataset_id_by_name(dataset_name)
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/api/api_workflow_datasets.py", line 28, in set_dataset_id_by_name
    raise ValueError(f"A dataset with the name {dataset_name} does not exist on the web platform. "
ValueError: A dataset with the name aquarium_v1.2.0 does not exist on the web platform. Please create it first.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/cli/lightly_cli.py", line 87, in lightly_cli
    return _lightly_cli(cfg)
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/cli/lightly_cli.py", line 38, in _lightly_cli
    _upload_cli(cfg)
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/cli/upload_cli.py", line 56, in _upload_cli
    api_workflow_client.create_dataset(dataset_name=new_dataset_name)
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/api/api_workflow_datasets.py", line 43, in create_dataset
    self._create_dataset_without_check_existing(dataset_name=dataset_name)
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/api/api_workflow_datasets.py", line 55, in _create_dataset_without_check_existing
    response: CreateEntityResponse = self._datasets_api.create_dataset(body=body)
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/openapi_generated/swagger_client/api/datasets_api.py", line 55, in create_dataset
    (data) = self.create_dataset_with_http_info(body, **kwargs)  # noqa: E501
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/openapi_generated/swagger_client/api/datasets_api.py", line 119, in create_dataset_with_http_info
    return self.api_client.call_api(
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/openapi_generated/swagger_client/api_client.py", line 326, in call_api
    return self.__call_api(resource_path, method,
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/openapi_generated/swagger_client/api_client.py", line 158, in __call_api
    response_data = self.request(
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/openapi_generated/swagger_client/api_client.py", line 368, in request
    return self.rest_client.POST(url,
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/openapi_generated/swagger_client/rest.py", line 269, in POST
    return self.request("POST", url,
  File "/opt/conda/envs/lightly/lib/python3.8/site-packages/lightly/openapi_generated/swagger_client/rest.py", line 228, in request
    raise ApiException(http_resp=r)
lightly.openapi_generated.swagger_client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'x-cloud-trace-context': '45f5bd891267965a023e87f37942eaa2/9331232448435279249;o=1', 'Vary': 'Origin, Accept-Encoding', 'Content-Security-Policy': "script-src https://*.lightly.ai https://*.youtube.com https://*.gstatic.com https://*.google.com https://*.doubleclick.net https://*.google-analytics.com https://*.googletagmanager.com https://*.fullstory.com;img-src *;default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';object-src 'none';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests", 'X-DNS-Prefetch-Control': 'off', 'Expect-CT': 'max-age=0', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'X-Download-Options': 'noopen', 'X-Content-Type-Options': 'nosniff', 'X-Permitted-Cross-Domain-Policies': 'none', 'Origin-Agent-Cluster': '?1', 'X-XSS-Protection': '0', 'Cross-Origin-Opener-Policy': 'same-origin-allow-popups', 'Cross-Origin-Resource-Policy': 'same-site', 'ETag': 'W/"6e-sL9x5RrfZDjQ8KLTI80MVYOs42s"', 'Date': 'Wed, 01 Dec 2021 09:50:25 GMT', 'Server': 'Google Frontend', 'Content-Length': '110'})
HTTP response body: {
    "code": "MALFORMED_REQUEST",
    "error": "name must match the following: \"/^[a-zA-Z0-9-_\\\\s]+$/\""
}

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
guarin commented 1 year ago

Dataset upload is deprecated.