Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing SDK task.upload_data() to accept resources of the Path type #9114

Merged
merged 5 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.d/20250220_003314_ravinduwe_resource_path_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Changed

- SDK `task.upload_data()` can accept resources of the `Path` type
when `resource_type` is `REMOTE` or `SHARE`
(<https://github.com/cvat-ai/cvat/pull/9114>)
10 changes: 5 additions & 5 deletions cvat-sdk/cvat_sdk/core/proxies/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
import json
import mimetypes
import os
import shutil
from collections.abc import Sequence
from enum import Enum
Expand Down Expand Up @@ -109,14 +110,13 @@ def upload_data(
data["frame_filter"] = f"step={params.get('frame_step')}"

if resource_type in [ResourceType.REMOTE, ResourceType.SHARE]:
for resource in resources:
if not isinstance(resource, str):
raise TypeError(f"resources: expected instances of str, got {type(resource)}")

str_resources = list(map(os.fspath, resources))

if resource_type is ResourceType.REMOTE:
data["remote_files"] = resources
data["remote_files"] = str_resources
elif resource_type is ResourceType.SHARE:
data["server_files"] = resources
data["server_files"] = str_resources

result, _ = self.api.create_data(
self.id,
Expand Down
Loading