Skip to content

Commit

Permalink
Merge pull request #7 from ArcanaFramework/missed-refactor
Browse files Browse the repository at this point in the history
renamed save|load_frameset_definition (was missed)
  • Loading branch information
tclose authored Aug 22, 2024
2 parents 91373c3 + 78d9e7e commit dd03f12
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 7 additions & 5 deletions frametree/core/store/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions frametree/core/store/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions frametree/core/store/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions frametree/core/store/tests/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions frametree/testing/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dd03f12

Please sign in to comment.