Skip to content

Commit

Permalink
Move to optional --zarr-dir argument for project add-dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
tcompa committed Nov 5, 2024
1 parent a3951a4 commit 6a6f141
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
**Note**: Numbers like (\#123) point to closed Pull Requests on the fractal repository.

# 2.3.1 (unreleased)
# 2.3.1

> WARNING: This release has a breaking change in the `project add-dataset` command.
* Move to from positional `zarr_dir` argument to optional `--zarr-dir` argument, for `project add-dataset` (\#736).
* Add support for user-settings `project_dir`, introduced in fractal-server 2.8.0 (\#736).
* Internal:
* Update effect of `include_logs` for task-collection check command (\#730).
Expand Down
13 changes: 6 additions & 7 deletions fractal_client/cmd/_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def post_dataset(
*,
project_id: int,
dataset_name: str,
zarr_dir: str,
zarr_dir: str | None = None,
filters: str | None = None,
batch: bool = False,
) -> Interface:
Expand All @@ -22,14 +22,13 @@ def post_dataset(
filters: Path to file containing dataset filters in JSON format.
batch: Dataset filters.
"""
if filters is None:
dataset = dict(name=dataset_name, zarr_dir=zarr_dir)
else:
dataset = dict(name=dataset_name)
if zarr_dir is not None:
dataset["zarr_dir"] = zarr_dir
if filters is not None:
with open(filters, "r") as f:
filters_dict = json.load(f)
dataset = dict(
name=dataset_name, filters=filters_dict, zarr_dir=zarr_dir
)
dataset["filters"] = filters_dict

res = client.post(
f"{settings.BASE_URL}/project/{project_id}/dataset/",
Expand Down
3 changes: 2 additions & 1 deletion fractal_client/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@
help="Name of new dataset.",
)
project_add_dataset_parser.add_argument(
"zarr_dir",
"--zarr-dir",
help="Path to zarr dir.",
required=False,
)
project_add_dataset_parser.add_argument(
"--filters",
Expand Down
20 changes: 17 additions & 3 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
from devtools import debug


def test_create_dataset(invoke, tmp_path, new_name):
def test_create_dataset(
invoke,
tmp_path,
new_name,
invoke_as_superuser,
):
"""
Test some specific branches of the post_dataset function and parser.
"""
Expand All @@ -19,7 +24,8 @@ def test_create_dataset(invoke, tmp_path, new_name):

res = invoke(
(
f"project add-dataset {project_id} {new_name()} /tmp "
f"project add-dataset {project_id} {new_name()} "
"--zarr-dir /tmp "
f"--filters {file_filters}"
)
)
Expand All @@ -28,7 +34,15 @@ def test_create_dataset(invoke, tmp_path, new_name):
assert res.retcode == 0
assert res.data["filters"] == FILTERS

res = invoke(f"--batch project add-dataset {project_id} {new_name()} /tmp")
# Add a project_dir to user-settings
res = invoke("--batch user whoami")
assert res.retcode == 0
user_id = res.data
res = invoke_as_superuser(
f"user edit {user_id} --new-project-dir /something"
)
assert res.retcode == 0
res = invoke(f"--batch project add-dataset {project_id} {new_name()}")
debug(res.data)
assert res.retcode == 0

Expand Down

0 comments on commit 6a6f141

Please sign in to comment.