From 34eee97e4306e0d1235f70d302f81b4aa3c2badf Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 22 Aug 2024 17:17:59 +1000 Subject: [PATCH 1/3] renamed save|load_frameset_definition (was missed) --- docs/source/contributing.rst | 2 +- frametree/core/store/base.py | 10 ++++++---- frametree/core/store/local.py | 4 ++-- frametree/core/store/remote.py | 4 ++-- frametree/core/store/tests/test_store.py | 4 ++-- frametree/testing/store.py | 6 ++++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 4badb31..c2452af 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -68,7 +68,7 @@ be implemented, such as `connect` and `disconnect`, which handle the login/out m .. autoclass:: frametree.core.store.RemoteStore :noindex: - :members: populate_tree, populate_row, download_files, download_value, upload_files, upload_value, get_provenance, put_provenance, create_data_tree, create_fileset_entry, create_field_entry, get_checksums, put_checksums, calculate_checksums, connect, disconnect, put_provenance, get_provenance, save_grid_definition, load_grid_definition + :members: populate_tree, populate_row, download_files, download_value, upload_files, upload_value, get_provenance, put_provenance, create_data_tree, create_fileset_entry, create_field_entry, get_checksums, put_checksums, calculate_checksums, connect, disconnect, put_provenance, get_provenance, save_frameset_definition, load_frameset_definition .. _adding_formats: diff --git a/frametree/core/store/base.py b/frametree/core/store/base.py index 1c06f88..4aef989 100644 --- a/frametree/core/store/base.py +++ b/frametree/core/store/base.py @@ -259,7 +259,7 @@ def save_frameset(self, frameset: FrameSet, name: str = ""): if name is None: name = frameset.name with self.connection: - self.save_grid_definition(frameset.id, definition, name=save_name) + self.save_frameset_definition(frameset.id, definition, name=save_name) def load_frameset(self, id, name: str = "", **kwargs) -> FrameSet: """Load an existing dataset definition @@ -286,7 +286,7 @@ def load_frameset(self, id, name: str = "", **kwargs) -> FrameSet: name = "" saved_name = name if name else self.EMPTY_DATASET_NAME with self.connection: - dct = self.load_grid_definition(id, saved_name) + dct = self.load_frameset_definition(id, saved_name) if dct is None: raise KeyError(f"Did not find a dataset '{id}@{name}'") store_version = dct.pop(self.VERSION_KEY) @@ -759,7 +759,7 @@ def get_provenance(self, entry: DataEntry) -> ty.Dict[str, ty.Any]: """ @abstractmethod - def save_grid_definition( + def save_frameset_definition( self, dataset_id: str, definition: ty.Dict[str, ty.Any], name: str ): """Save definition of dataset within the store @@ -778,7 +778,9 @@ def save_grid_definition( """ @abstractmethod - def load_grid_definition(self, dataset_id: str, name: str) -> ty.Dict[str, ty.Any]: + def load_frameset_definition( + self, dataset_id: str, name: str + ) -> ty.Dict[str, ty.Any]: """Load definition of a dataset saved within the store Parameters diff --git a/frametree/core/store/local.py b/frametree/core/store/local.py index d51cdfb..32717d8 100644 --- a/frametree/core/store/local.py +++ b/frametree/core/store/local.py @@ -249,13 +249,13 @@ def create_entry(self, path: str, datatype: type, row: DataRow) -> DataEntry: uri = self.field_uri(path, datatype, row) return row.add_entry(path=path, datatype=datatype, uri=uri) - def save_grid_definition(self, dataset_id, definition, name): + def save_frameset_definition(self, dataset_id, definition, name): definition_path = self.definition_save_path(dataset_id, name) definition_path.parent.mkdir(exist_ok=True, parents=True) with open(definition_path, "w") as f: yaml.dump(definition, f) - def load_grid_definition(self, dataset_id, name): + def load_frameset_definition(self, dataset_id, name): fspath = self.definition_save_path(dataset_id, name) if fspath.exists(): with open(fspath) as f: diff --git a/frametree/core/store/remote.py b/frametree/core/store/remote.py index cf0a652..9b07d36 100644 --- a/frametree/core/store/remote.py +++ b/frametree/core/store/remote.py @@ -92,9 +92,9 @@ def cache_dir_validator(self, _, cache_dir): # populate_row - # save_grid_definition + # save_frameset_definition - # load_grid_definition + # load_frameset_definition # connect diff --git a/frametree/core/store/tests/test_store.py b/frametree/core/store/tests/test_store.py index 58da019..cddc6bb 100644 --- a/frametree/core/store/tests/test_store.py +++ b/frametree/core/store/tests/test_store.py @@ -111,10 +111,10 @@ def test_grid_roundtrip(dataset: FrameSet): data_store = dataset.store with data_store.connection: - data_store.save_grid_definition( + data_store.save_frameset_definition( dataset_id=dataset.id, definition=definition, name="test_dataset" ) - reloaded_definition = data_store.load_grid_definition( + reloaded_definition = data_store.load_frameset_definition( dataset_id=dataset.id, name="test_dataset" ) assert definition == reloaded_definition diff --git a/frametree/testing/store.py b/frametree/testing/store.py index 470b28a..8bf53c4 100644 --- a/frametree/testing/store.py +++ b/frametree/testing/store.py @@ -101,7 +101,7 @@ def populate_row(self, row: DataRow): uri=full_path(path).relative_to(self.remote_dir), ) - def save_grid_definition( + def save_frameset_definition( self, dataset_id: str, definition: ty.Dict[str, ty.Any], name: str ): """Save definition of dataset within the store @@ -123,7 +123,9 @@ def save_grid_definition( with open(definition_path, "w") as f: yaml.dump(definition, f) - def load_grid_definition(self, dataset_id: str, name: str) -> ty.Dict[str, ty.Any]: + def load_frameset_definition( + self, dataset_id: str, name: str + ) -> ty.Dict[str, ty.Any]: """Load definition of a dataset saved within the store Parameters From 6194b2fb06f5c63dc38a1bbc1de5e9253a30e170 Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 22 Aug 2024 17:21:53 +1000 Subject: [PATCH 2/3] added sphinx-togglebutton dep to docs build --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a32b975..a47edf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ docs = [ "sphinx >=2.1.2", "sphinx-argparse>=0.2.0", "sphinx-click>=3.1", + "sphinx-togglebutton >=0.3.2", ] test = [ "fileformats-medimage-extras", From 78d9e7ee7de59bac21678107abfa67c96de4985c Mon Sep 17 00:00:00 2001 From: Tom Close Date: Thu, 22 Aug 2024 17:30:45 +1000 Subject: [PATCH 3/3] [skip ci] fixed up typing import --- frametree/core/store/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frametree/core/store/base.py b/frametree/core/store/base.py index 4aef989..a72da42 100644 --- a/frametree/core/store/base.py +++ b/frametree/core/store/base.py @@ -32,7 +32,7 @@ if ty.TYPE_CHECKING: # pragma: no cover - from ..set import FrameSet + from ..frameset import FrameSet from ..tree import DataTree from ..entry import DataEntry from ..row import DataRow