Skip to content

Commit 1122485

Browse files
authored
Allow supplying datastore_url in announce_manual_upload (#1336)
* Allow supplying datastore_url in announce_manual_upload * format * changelog * rstrip slashes from passed datastore and wk uris
1 parent 9554718 commit 1122485

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1515
### Breaking Changes
1616

1717
### Added
18+
- The function `Dataset.announce_manual_upload` now takes an additional optional parameter `dataset_url` to select the correct datastore in a multi-datastore setup. [#1336](https://github.com/scalableminds/webknossos-libs/pull/1336)
1819

1920
### Changed
2021
- Every file that sends logging messages has its own logger now. This can be used to selectively disable loggers. [#1335](https://github.com/scalableminds/webknossos-libs/pull/1335)

webknossos/webknossos/client/api_client/datastore_api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(
2222
headers: dict[str, str] | None = None,
2323
):
2424
super().__init__(timeout_seconds, headers)
25-
self.datastore_base_url = datastore_base_url
25+
self.datastore_base_url = datastore_base_url.rstrip("/")
2626

2727
@property
2828
def url_prefix(self) -> str:

webknossos/webknossos/client/api_client/wk_api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(
4646
headers: dict[str, str] | None = None,
4747
):
4848
super().__init__(timeout_seconds, headers)
49-
self.base_wk_url = base_wk_url
49+
self.base_wk_url = base_wk_url.rstrip("/")
5050

5151
@property
5252
def url_prefix(self) -> str:

webknossos/webknossos/dataset/dataset.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def announce_manual_upload(
470470
folder_id: str | RemoteFolder | None,
471471
require_unique_name: bool = False,
472472
token: str | None = None,
473+
datastore_url: str | None = None,
473474
) -> tuple[str, str]:
474475
"""Announce a manual dataset upload to WEBKNOSSOS.
475476
@@ -483,6 +484,7 @@ def announce_manual_upload(
483484
folder_id: Optional ID of folder where dataset should be placed
484485
require_unique_name: Whether to make request fail in case a dataset with the name already exists
485486
token: Optional authentication token
487+
datastore_url: If the WEBKNOSSOS instance has multiple datastores, supply a url to select one.
486488
487489
Note:
488490
This is typically only used by administrators with direct file system
@@ -514,8 +516,9 @@ def announce_manual_upload(
514516
folder_id=folder_id,
515517
require_unique_name=require_unique_name,
516518
)
517-
upload_url = _cached_get_upload_datastore(context)
518-
datastore_api = context.get_datastore_api_client(upload_url)
519+
if datastore_url is None:
520+
datastore_url = _cached_get_upload_datastore(context)
521+
datastore_api = context.get_datastore_api_client(datastore_url)
519522
response = datastore_api.dataset_reserve_manual_upload(
520523
dataset_announce, token=token
521524
)

0 commit comments

Comments
 (0)