Skip to content

Commit

Permalink
feat: add dataset to space
Browse files Browse the repository at this point in the history
  • Loading branch information
xgui3783 committed Oct 17, 2023
1 parent 8ebf022 commit 86bb8c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions api/models/core/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Model as _CommonCoordinateSpaceModel,
AxesOrigin,
)
from api.models._retrieval.datasets import EbrainsDatasetModel
from typing import List, Optional
from pydantic import Field

Expand All @@ -16,3 +17,7 @@ class CommonCoordinateSpaceModel(_CommonCoordinateSpaceModel, ConfigBaseModel, t
min_items=1,
title='defaultImage',
)
datasets: Optional[List[EbrainsDatasetModel]] = Field(
None,
alias="datasets",
)
1 change: 1 addition & 0 deletions api/serialization/core/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ def space_to_model(space: Space, **kwargs) -> CommonCoordinateSpaceModel:
release_date=str(date(2015, 1, 1)),
short_name=space.shortname,
version_identifier=space.name,
datasets=[instance_to_model(ds) for ds in (space.datasets or [])]
)
4 changes: 3 additions & 1 deletion test/serialization/test_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from api.models.core.space import CommonCoordinateSpaceModel

all_spaces = [s for s in spaces]
spaces_without_ds = ("ICBM 2009c nonl asym", "Allen Mouse CCF v3", "hcp32k")

@pytest.mark.parametrize("space", all_spaces)
def test_space(space: Space):
model = instance_to_model(space)
assert isinstance(model, CommonCoordinateSpaceModel)
model.dict()

if model.short_name not in spaces_without_ds:
assert len(model.datasets) > 0

0 comments on commit 86bb8c7

Please sign in to comment.