Skip to content
2 changes: 1 addition & 1 deletion webknossos/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
### Breaking Changes

### Added
- Added argument `require_unique_name` to `Dataset.announce_manual_upload()`. Additionally, the method returns a tuple of `new_dataset_id` and `directory_name` now. [#1283](https://github.com/scalableminds/webknossos-libs/pull/1283)

### Changed

Expand Down Expand Up @@ -46,7 +47,6 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
- Fixed an issue with upsampling views. [#1287](https://github.com/scalableminds/webknossos-libs/pull/1287)



## [2.1.0](https://github.com/scalableminds/webknossos-libs/releases/tag/v2.1.0) - 2025-04-01
[Commits](https://github.com/scalableminds/webknossos-libs/compare/v2.0.7...v2.1.0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from webknossos.client.api_client.models import (
ApiDatasetAnnounceUpload,
ApiDatasetManualUploadSuccess,
ApiDatasetUploadInformation,
ApiDatasetUploadSuccess,
ApiReserveDatasetUploadInformation,
Expand Down Expand Up @@ -72,10 +73,12 @@ def dataset_reserve_manual_upload(
self,
dataset_announce: ApiDatasetAnnounceUpload,
token: str | None,
) -> None:
) -> ApiDatasetManualUploadSuccess:
route = "/datasets/reserveManualUpload"
query: Query = {"token": token}
self._post_json(route, dataset_announce, query)
return self._post_json_with_json_response(
route, dataset_announce, ApiDatasetManualUploadSuccess, query
)

def dataset_get_raw_data(
self,
Expand Down
7 changes: 7 additions & 0 deletions webknossos/webknossos/client/api_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class ApiDatasetAnnounceUpload:
organization: str
initial_team_ids: list[str]
folder_id: str
require_unique_name: bool


@attr.s(auto_attribs=True)
Expand All @@ -155,6 +156,12 @@ class ApiDatasetUploadSuccess:
new_dataset_id: str


@attr.s(auto_attribs=True)
class ApiDatasetManualUploadSuccess:
new_dataset_id: str
directory_name: str


@attr.s(auto_attribs=True)
class ApiLinkedLayerIdentifier:
organization_id: str
Expand Down
9 changes: 7 additions & 2 deletions webknossos/webknossos/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,9 @@ def announce_manual_upload(
organization: str,
initial_team_ids: list[str],
folder_id: str | RemoteFolder,
require_unique_name: bool = False,
token: str | None = None,
) -> None:
) -> tuple[str, str]:
"""Announce a manual dataset upload to WEBKNOSSOS.

Used when manually uploading datasets to the file system of a datastore.
Expand Down Expand Up @@ -512,10 +513,14 @@ def announce_manual_upload(
organization=organization,
initial_team_ids=initial_team_ids,
folder_id=folder_id,
require_unique_name=require_unique_name,
)
upload_url = _cached_get_upload_datastore(context)
datastore_api = context.get_datastore_api_client(upload_url)
datastore_api.dataset_reserve_manual_upload(dataset_announce, token=token)
response = datastore_api.dataset_reserve_manual_upload(
dataset_announce, token=token
)
return response.new_dataset_id, response.directory_name

@classmethod
def trigger_reload_in_datastore(
Expand Down
Loading