Skip to content

Commit

Permalink
Merge pull request #166 from pyiron/use_h5iostorage_directly
Browse files Browse the repository at this point in the history
Use h5iostorage directly
  • Loading branch information
liamhuber committed Jan 18, 2024
2 parents bd62c77 + bba2ec5 commit 00a5709
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
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)

0 comments on commit 00a5709

Please sign in to comment.