From e018b10e002ad1aaaf5f4899d15f4755a7158768 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Fri, 16 Dec 2022 16:57:01 +0300 Subject: [PATCH] SDK: fix `Project.import_dataset` incorrectly waiting for completion (#5459) 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. --- CHANGELOG.md | 2 ++ cvat-sdk/cvat_sdk/core/proxies/projects.py | 1 + cvat-sdk/cvat_sdk/core/uploading.py | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50c0527f..fd341423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,8 @@ non-ascii paths while adding files from "Connected file share" (issue #4428) - Missing source tag in project annotations () - Creating a task with a Git repository via the SDK () +- `Project.import_dataset` not waiting for completion correctly + () ### Security - TDB diff --git a/cvat-sdk/cvat_sdk/core/proxies/projects.py b/cvat-sdk/cvat_sdk/core/proxies/projects.py index 63a9fa37..05646ee8 100644 --- a/cvat-sdk/cvat_sdk/core/proxies/projects.py +++ b/cvat-sdk/cvat_sdk/core/proxies/projects.py @@ -54,6 +54,7 @@ class Project( 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}, diff --git a/cvat-sdk/cvat_sdk/core/uploading.py b/cvat-sdk/cvat_sdk/core/uploading.py index 721a2038..c6f592f7 100644 --- a/cvat-sdk/cvat_sdk/core/uploading.py +++ b/cvat-sdk/cvat_sdk/core/uploading.py @@ -325,7 +325,8 @@ class AnnotationUploader(Uploader): class DatasetUploader(Uploader): def upload_file_and_wait( self, - endpoint: Endpoint, + upload_endpoint: Endpoint, + retrieve_endpoint: Endpoint, filename: Path, format_name: str, *, @@ -333,12 +334,14 @@ class DatasetUploader(Uploader): 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,