Skip to content

Commit

Permalink
SDK: fix Project.import_dataset incorrectly waiting for completion
Browse files Browse the repository at this point in the history
You have to use the `import_status` action in order to query the input
status. Otherwise, the `/api/projects/{id}/dataset/` endpoint initiates a
dataset export. Currently, `import_dataset` inadvertently monitors the
status of that export, not the original import.
  • Loading branch information
SpecLad committed Dec 13, 2022
1 parent a3b4f97 commit 2acca28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions cvat-sdk/cvat_sdk/core/proxies/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def import_dataset(

DatasetUploader(self._client).upload_file_and_wait(
self.api.create_dataset_endpoint,
self.api.retrieve_dataset_endpoint,
filename,
format_name,
url_params={"id": self.id},
Expand Down
7 changes: 5 additions & 2 deletions cvat-sdk/cvat_sdk/core/uploading.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,23 @@ def upload_file_and_wait(
class DatasetUploader(Uploader):
def upload_file_and_wait(
self,
endpoint: Endpoint,
upload_endpoint: Endpoint,
retrieve_endpoint: Endpoint,
filename: Path,
format_name: str,
*,
url_params: Optional[Dict[str, Any]] = None,
pbar: Optional[ProgressReporter] = None,
status_check_period: Optional[int] = None,
):
url = self._client.api_map.make_endpoint_url(endpoint.path, kwsub=url_params)
url = self._client.api_map.make_endpoint_url(upload_endpoint.path, kwsub=url_params)
params = {"format": format_name, "filename": filename.name}
self.upload_file(
url, filename, pbar=pbar, query_params=params, meta={"filename": params["filename"]}
)

url = self._client.api_map.make_endpoint_url(retrieve_endpoint.path, kwsub=url_params)
params = {"action": "import_status"}
self._wait_for_completion(
url,
success_status=201,
Expand Down

0 comments on commit 2acca28

Please sign in to comment.