Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
SDK: fix Project.import_dataset incorrectly waiting for completion (c…
Browse files Browse the repository at this point in the history
…vat-ai#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.
  • Loading branch information
SpecLad authored and mikhail-treskin committed Jul 1, 2023
1 parent 49cd4d0 commit fdadaaf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ non-ascii paths while adding files from "Connected file share" (issue #4428)
- Missing source tag in project annotations (<https://github.com/opencv/cvat/pull/5408>)
- Creating a task with a Git repository via the SDK
(<https://github.com/opencv/cvat/issues/4365>)
- `Project.import_dataset` not waiting for completion correctly
(<https://github.com/opencv/cvat/pull/5459>)

### Security
- TDB
Expand Down
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 fdadaaf

Please sign in to comment.