diff --git a/src/robofish/evaluate/app.py b/src/robofish/evaluate/app.py index 0b1cd97864eb01eaf8c5c2e38382ba62969270c7..b000a3b2d5d2c433bf050f63723ebdc6dc05115f 100644 --- a/src/robofish/evaluate/app.py +++ b/src/robofish/evaluate/app.py @@ -30,6 +30,19 @@ def evaluate(args=None): nargs="+", help="The paths to io/hdf5 files. Multiple paths can be given which will be shown in different colors", ) + parser.add_argument( + "--names", + type=str, + nargs="+", + help="Names, that should be used in the graphs instead of the pahts", + default=None, + ) + parser.add_argument( + "--save_folder", + type=str, + help="Output folder for saving resulting graphics", + default=None, + ) if args is None: args = parser.parse_args() diff --git a/src/robofish/io/file.py b/src/robofish/io/file.py index e120d57688a0d2d8f13ab1b9bad8118c1f920a25..272de3817530ec7ce8cafac1350a5ca3380ccbb5 100644 --- a/src/robofish/io/file.py +++ b/src/robofish/io/file.py @@ -71,7 +71,8 @@ class File(h5py.File): self._tf_path = Path(temp_dir.name) / self._name self.load(path, strict_validate) - if path is None: + if path is None or not Path(path).exists(): + # Initialize new file assert world_size_cm is not None and format_version is not None @@ -99,9 +100,11 @@ class File(h5py.File): path: path to a io file as a string or path object strict_validate: optional boolean, if the file should be strictly validated, when loaded from a path. The default is False. """ + if path is not None: + self._f_path = Path(path) + if path is not None and Path(path).exists(): logging.info(f"Opening File {path}") - self._f_path = Path(path) shutil.copyfile(self._f_path, self._tf_path) super().__init__(self._tf_path, "r+") self.validate(strict_validate) @@ -149,7 +152,6 @@ class File(h5py.File): calendar_time_points: Iterable = None, default: bool = False, ): - print(frequency_hz, monotonic_time_points_us) if frequency_hz is not None and monotonic_time_points_us is not None: logging.exception("Specify either frequency_hz or timestamps, not both.") diff --git a/tests/robofish/io/test_file.py b/tests/robofish/io/test_file.py index 03e6aa22e4a719b11bc113dd5b2176438fa1b1d3..3cb5d023681937c8d9334a6017de294820e2a128 100644 --- a/tests/robofish/io/test_file.py +++ b/tests/robofish/io/test_file.py @@ -15,6 +15,7 @@ def full_path(path): valid_file_path = full_path("../../resources/valid.hdf5") created_by_test_path = full_path("../../resources/created_by_test.hdf5") +created_by_test_path_2 = full_path("../../resources/created_by_test_2.hdf5") def test_constructor(): @@ -23,6 +24,15 @@ def test_constructor(): sf.validate() +def test_new_file_w_path(): + sf = robofish.io.File( + created_by_test_path_2, world_size_cm=[100, 100], frequency_hz=25 + ) + sf.create_entity("fish") + sf.save() + sf.validate() + + def test_missing_attribute(): sf = robofish.io.File(world_size_cm=[10, 10]) sf.attrs.pop("world_size_cm") @@ -164,6 +174,7 @@ def test_validate_created_file_after_reloading(): def test_z_cleanup(): """ This cleans up after all tests and removes all test artifacts """ created_by_test_path.unlink() + created_by_test_path_2.unlink() if __name__ == "__main__":