From 10db67c3084b25e41f97fa3146285dfdd55af2f3 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Tue, 16 Jan 2024 13:47:15 -0800 Subject: [PATCH 1/7] Clean the working directory attribute --- pyiron_workflow/node.py | 2 +- pyiron_workflow/snippets/files.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyiron_workflow/node.py b/pyiron_workflow/node.py index 87b18a65a..7707cbfb9 100644 --- a/pyiron_workflow/node.py +++ b/pyiron_workflow/node.py @@ -273,7 +273,7 @@ def __post__( if save_exists and overwrite_save: self.working_directory.remove_files(hardcoded_tinybase_filename) - self.working_directory.delete(only_if_empty=True) + self._working_directory = 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 diff --git a/pyiron_workflow/snippets/files.py b/pyiron_workflow/snippets/files.py index bb2957a6c..0412649dc 100644 --- a/pyiron_workflow/snippets/files.py +++ b/pyiron_workflow/snippets/files.py @@ -46,6 +46,8 @@ def create(self): def delete(self, only_if_empty: bool = False): if self.is_empty() or not only_if_empty: delete_files_and_directories_recursively(self.path) + else: + return self def list_content(self): return categorize_folder_items(self.path) From 110a8f71658036d92878532b2f8f66bd9fdc61df Mon Sep 17 00:00:00 2001 From: liamhuber Date: Tue, 16 Jan 2024 13:47:40 -0800 Subject: [PATCH 2/7] Use H5ioStorage directly Instead of the project --- pyiron_workflow/node.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyiron_workflow/node.py b/pyiron_workflow/node.py index 7707cbfb9..9ad724d43 100644 --- a/pyiron_workflow/node.py +++ b/pyiron_workflow/node.py @@ -1097,8 +1097,9 @@ 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) + # UGLY -- make sure it exists, as accessing .path directly doesn't! + storage_file = str((self.working_directory.path / "project.h5").resolve()) # self.label + return H5ioStorage(Pointer(storage_file), None) From 028ecbc4532e1e1904abd8011ca9969d518c7c64 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Wed, 17 Jan 2024 16:24:05 -0800 Subject: [PATCH 3/7] Don't rely on `return` behaviour on `DirectoryObject.delete` --- pyiron_workflow/node.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyiron_workflow/node.py b/pyiron_workflow/node.py index 9ad724d43..dc1db5d87 100644 --- a/pyiron_workflow/node.py +++ b/pyiron_workflow/node.py @@ -273,9 +273,11 @@ def __post__( if save_exists and overwrite_save: self.working_directory.remove_files(hardcoded_tinybase_filename) - self._working_directory = 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 From 90dc5ab07d7679dca975db781a9bda45078dea2d Mon Sep 17 00:00:00 2001 From: liamhuber Date: Wed, 17 Jan 2024 16:25:06 -0800 Subject: [PATCH 4/7] Revert the return behaviour on `DirectoryObject.delete` It was just weird. Just explicitly check for empty. Honestly, we can probably revert the `only_if_empty` kwarg too, but that can be its own PR. --- pyiron_workflow/snippets/files.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyiron_workflow/snippets/files.py b/pyiron_workflow/snippets/files.py index 0412649dc..bb2957a6c 100644 --- a/pyiron_workflow/snippets/files.py +++ b/pyiron_workflow/snippets/files.py @@ -46,8 +46,6 @@ def create(self): def delete(self, only_if_empty: bool = False): if self.is_empty() or not only_if_empty: delete_files_and_directories_recursively(self.path) - else: - return self def list_content(self): return categorize_folder_items(self.path) From 2c5fbe52f44af5da7a6cf971e3e74a988cb81991 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Wed, 17 Jan 2024 16:28:06 -0800 Subject: [PATCH 5/7] Remove comment --- pyiron_workflow/node.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyiron_workflow/node.py b/pyiron_workflow/node.py index dc1db5d87..fbb5b8ad5 100644 --- a/pyiron_workflow/node.py +++ b/pyiron_workflow/node.py @@ -1102,6 +1102,5 @@ def storage(self): from pyiron_contrib.tinybase.storage import H5ioStorage from h5io_browser import Pointer - # UGLY -- make sure it exists, as accessing .path directly doesn't! storage_file = str((self.working_directory.path / "project.h5").resolve()) # self.label return H5ioStorage(Pointer(storage_file), None) From 2cb5167cb9ecef9f90583f7015ffd400d7703166 Mon Sep 17 00:00:00 2001 From: liamhuber Date: Wed, 17 Jan 2024 16:36:08 -0800 Subject: [PATCH 6/7] No magic strings --- pyiron_workflow/node.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pyiron_workflow/node.py b/pyiron_workflow/node.py index fbb5b8ad5..12ec45167 100644 --- a/pyiron_workflow/node.py +++ b/pyiron_workflow/node.py @@ -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, @@ -267,11 +271,10 @@ 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) if self.working_directory.is_empty(): self.working_directory.delete() @@ -1102,5 +1105,7 @@ def storage(self): from pyiron_contrib.tinybase.storage import H5ioStorage from h5io_browser import Pointer - storage_file = str((self.working_directory.path / "project.h5").resolve()) # self.label + storage_file = str( + (self.working_directory.path / self._STORAGE_FILE_NAME).resolve() + ) return H5ioStorage(Pointer(storage_file), None) From bba2ec55c59e31402f9f70c954333724b6698be6 Mon Sep 17 00:00:00 2001 From: pyiron-runner Date: Thu, 18 Jan 2024 00:36:43 +0000 Subject: [PATCH 7/7] [dependabot skip] Update env file --- docs/environment.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/environment.yml b/docs/environment.yml index 13d3ebfef..3facc4ff2 100644 --- a/docs/environment.yml +++ b/docs/environment.yml @@ -2,7 +2,10 @@ channels: - conda-forge dependencies: - ipykernel +- myst-parser - nbsphinx +- sphinx-gallery +- sphinx-rtd-theme - coveralls - coverage - bidict =0.22.1 @@ -13,4 +16,3 @@ dependencies: - python-graphviz =0.20.1 - toposort =1.10 - typeguard =4.1.5 -- myst-parser