HumanSignal / HumanSignal/label-studio-sdk
Single file upload option missing
- Dominant language
- Python
- Stars
- 192
- Forks
- 127
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 1
Description
In the Label Studio UI, I can upload a single file, which, as far as I can tell, calls the task import endpoint `api/projects/{project_id}/import` with the file being specified in a multipart request. Currently, I don't see a way of doing this using the official SDK. I can achieve this by calling the internal client:
```python
upload_response = ls._client_wrapper.httpx_client.request(
f'api/projects/{project_id}/import',
method='POST',
files={'file': (uploaded_file_name, file_content, 'image/jpeg')},
json=task,
params={'return_task_ids': True}
)
task_id = str(upload_response['task_ids'][0])
```
However, this completely ignores the task dictionary, so it seems to be necessary to get the task id and then send another request to update the task with the task dictionary. However, it has some weird effects:
1. `annotations` become just another generic field, so I don't see them in the UI.
2. Uploaded file gets renamed internally by adding a prefix, but when I get its new name by the upload id:
```python
file_upload_id = upload_response['file_upload_ids'][0]
new_filename = ls.files.get(file_upload_id).file
task['data']['image'] = f'/data/{new_filename}'
ls.tasks.update(task_id, data=task, project=project_id)
```
and then add it back to the task dictionary and update the task, the image file is not shown in the UI.
Is there a recommeded way to achieve the same UI functionality without having to register additional storages?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.