Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use h5iostorage directly #166

Merged
merged 7 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ channels:
- conda-forge
dependencies:
- ipykernel
- myst-parser
- nbsphinx
- sphinx-gallery
- sphinx-rtd-theme
- coveralls
- coverage
- bidict =0.22.1
Expand All @@ -13,4 +16,3 @@ dependencies:
- python-graphviz =0.20.1
- toposort =1.10
- typeguard =4.1.5
- myst-parser
27 changes: 17 additions & 10 deletions pyiron_workflow/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ class Node(HasToDict, ABC, metaclass=AbstractHasPost):

package_identifier = None

_STORAGE_FILE_NAME = "project.h5"
# This isn't nice, just a technical necessity in the current implementation
# Eventually, of course, this needs to be _at least_ file-format independent

def __init__(
self,
label: str,
Expand Down Expand Up @@ -267,15 +271,16 @@ def __post__(
run_after_init: bool = False,
**kwargs,
):
hardcoded_tinybase_filename = "project.h5"
save_exists = self.working_directory.file_exists(hardcoded_tinybase_filename)
save_exists = self.working_directory.file_exists(self._STORAGE_FILE_NAME)

if save_exists and overwrite_save:
self.working_directory.remove_files(hardcoded_tinybase_filename)
self.working_directory.remove_files(self._STORAGE_FILE_NAME)

self.working_directory.delete(only_if_empty=True)
# Touching the working directory may have created it -- if it's there and empty
# just clean it up
if self.working_directory.is_empty():
self.working_directory.delete()
self._working_directory = None
# Touching the working directory may have created it -- if it's there and
# empty just clean it up

do_load = save_exists and not overwrite_save

Expand Down Expand Up @@ -1097,8 +1102,10 @@ def load(self):

@property
def storage(self):
from pyiron_contrib.tinybase.project.h5io import SingleHdfProject
from pyiron_contrib.tinybase.storage import H5ioStorage
from h5io_browser import Pointer

return SingleHdfProject.open_location(
str(self.working_directory.path.resolve())
).create_storage(self.label)
storage_file = str(
(self.working_directory.path / self._STORAGE_FILE_NAME).resolve()
)
return H5ioStorage(Pointer(storage_file), None)
Loading