From d5f1c87ce13ad600cc1d4b8dcbb67a9cab4bae99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20=20LAURENT?= <francois.laurent@pasteur.fr>
Date: Fri, 1 Dec 2023 11:37:20 +0100
Subject: [PATCH] Save larva_dataset file along with model files

---
 Manifest.toml                       |  6 +++---
 src/taggingbackends/data/dataset.py | 17 +++++++++++++++--
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/Manifest.toml b/Manifest.toml
index 08542ee..41892f5 100644
--- a/Manifest.toml
+++ b/Manifest.toml
@@ -312,11 +312,11 @@ version = "1.9.2"
 
 [[deps.PlanarLarvae]]
 deps = ["DelimitedFiles", "HDF5", "JSON3", "LinearAlgebra", "MAT", "Meshes", "OrderedCollections", "Random", "SHA", "StaticArrays", "Statistics", "StatsBase", "StructTypes"]
-git-tree-sha1 = "3672831638c71be6e111ffde3376580d0d2bfaf5"
-repo-rev = "3bffeb68ab85f82c048bcb5aea3d19048e211ef9"
+git-tree-sha1 = "6b2dc28d56bcef101672cbf2bb784bbd5d88d579"
+repo-rev = "main"
 repo-url = "https://gitlab.pasteur.fr/nyx/PlanarLarvae.jl"
 uuid = "c2615984-ef14-4d40-b148-916c85b43307"
-version = "0.14.0"
+version = "0.15.0"
 
 [[deps.PrecompileTools]]
 deps = ["Preferences"]
diff --git a/src/taggingbackends/data/dataset.py b/src/taggingbackends/data/dataset.py
index 0700b0a..008a7af 100644
--- a/src/taggingbackends/data/dataset.py
+++ b/src/taggingbackends/data/dataset.py
@@ -26,16 +26,29 @@ class LarvaDataset:
             self.weight_classes = isinstance(balancing_strategy, str) and (balancing_strategy.lower() == 'auto')
         else:
             self.class_weights = class_weights
+        self._path = None
 
     """
     *h5py.File*: *larva_dataset hdf5* file handler.
     """
     @property
     def full_set(self):
-        if isinstance(self._full_set, (str, pathlib.Path)):
-            self._full_set = h5py.File(str(self._full_set), "r")
+        if not isinstance(self._full_set, h5py.File):
+            self._full_set = h5py.File(str(self.path), "r")
         return self._full_set
     """
+    *pathlib.Path*: file path.
+    """
+    @property
+    def path(self):
+        if self._path is None:
+            if isinstance(self._full_set, (str, pathlib.Path)):
+                self.path = self._full_set
+        return self._path
+    @path.setter
+    def path(self, p):
+        self._path = p if isinstance(p, pathlib.Path) else pathlib.Path(p)
+    """
     *list* of *bytes*: Set of distinct labels.
 
     If the hdf5 file does not feature a top-level `labels` element that lists
-- 
GitLab