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

Optional relative path for set local config #1384

Merged
merged 1 commit into from
Sep 11, 2023
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
2 changes: 1 addition & 1 deletion lightly/api/api_workflow_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def set_gcs_config(

def set_local_config(
self,
relative_path: str,
relative_path: str = "",
web_server_location: Optional[str] = "http://localhost:3456",
thumbnail_suffix: Optional[
str
Expand Down
23 changes: 19 additions & 4 deletions tests/api_workflow/test_api_workflow_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
DatasourceConfigLOCAL,
DatasourceConfigS3,
DatasourceConfigS3DelegatedAccess,
DatasourcePurpose,
DatasourceRawSamplesDataRow,
)
from lightly.openapi_generated.swagger_client.models.datasource_config_verify_data import (
Expand Down Expand Up @@ -239,19 +240,33 @@ def test_set_local_config(mocker: MockerFixture) -> None:
web_server_location="http://localhost:1234",
relative_path="path/to/my/data",
thumbnail_suffix=".lightly/thumbnails/[filename]-thumb-[extension]",
purpose=DatasourcePurpose.INPUT,
)
kwargs = mocked_datasources_api.update_datasource_by_dataset_id.call_args[1]
datasource_config = kwargs["datasource_config"].actual_instance
assert isinstance(datasource_config, DatasourceConfigLOCAL)

client.set_local_config(
relative_path="path/to/my/data",
thumbnail_suffix=".lightly/thumbnails/[filename]-thumb-[extension]",
assert datasource_config.type == "LOCAL"
assert datasource_config.web_server_location == "http://localhost:1234"
assert datasource_config.full_path == "path/to/my/data"
assert (
datasource_config.thumb_suffix
== ".lightly/thumbnails/[filename]-thumb-[extension]"
)
assert datasource_config.purpose == DatasourcePurpose.INPUT

# Test defaults
client.set_local_config()
kwargs = mocked_datasources_api.update_datasource_by_dataset_id.call_args[1]
datasource_config = kwargs["datasource_config"].actual_instance
assert isinstance(datasource_config, DatasourceConfigLOCAL)
assert datasource_config.type == "LOCAL"
assert datasource_config.web_server_location == "http://localhost:3456"
assert datasource_config.full_path == ""
assert (
datasource_config.thumb_suffix
== ".lightly/thumbnails/[filename]_thumb.[extension]"
)
assert datasource_config.purpose == DatasourcePurpose.INPUT_OUTPUT


def test_set_s3_config(mocker: MockerFixture) -> None:
Expand Down
Loading