Skip to content

Commit

Permalink
Optional relative path for set local config (#1384)
Browse files Browse the repository at this point in the history
  • Loading branch information
michal-lightly authored Sep 11, 2023
1 parent 80cd4e0 commit afced0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
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

0 comments on commit afced0a

Please sign in to comment.