sl-shared-assets 1.0.0rc5__tar.gz → 1.0.0rc7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sl-shared-assets might be problematic. Click here for more details.

Files changed (29) hide show
  1. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/PKG-INFO +1 -1
  2. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/pyproject.toml +1 -1
  3. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/data_classes.py +78 -41
  4. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/data_classes.pyi +24 -5
  5. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/.gitignore +0 -0
  6. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/LICENSE +0 -0
  7. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/README.md +0 -0
  8. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/docs/Makefile +0 -0
  9. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/docs/make.bat +0 -0
  10. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/docs/source/api.rst +0 -0
  11. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/docs/source/conf.py +0 -0
  12. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/docs/source/index.rst +0 -0
  13. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/docs/source/welcome.rst +0 -0
  14. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/envs/slsa_dev_lin.yml +0 -0
  15. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/envs/slsa_dev_lin_spec.txt +0 -0
  16. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/__init__.py +0 -0
  17. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/__init__.pyi +0 -0
  18. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/cli.py +0 -0
  19. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/cli.pyi +0 -0
  20. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/packaging_tools.py +0 -0
  21. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/packaging_tools.pyi +0 -0
  22. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/py.typed +0 -0
  23. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/server.py +0 -0
  24. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/server.pyi +0 -0
  25. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/suite2p.py +0 -0
  26. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/suite2p.pyi +0 -0
  27. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/transfer_tools.py +0 -0
  28. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/src/sl_shared_assets/transfer_tools.pyi +0 -0
  29. {sl_shared_assets-1.0.0rc5 → sl_shared_assets-1.0.0rc7}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sl-shared-assets
3
- Version: 1.0.0rc5
3
+ Version: 1.0.0rc7
4
4
  Summary: Stores assets shared between multiple Sun (NeuroAI) lab data pipelines.
5
5
  Project-URL: Homepage, https://github.com/Sun-Lab-NBB/sl-shared-assets
6
6
  Project-URL: Documentation, https://sl-shared-assets-api-docs.netlify.app/
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
8
8
  # Project metdata section. Provides the genral ID information about the project.
9
9
  [project]
10
10
  name = "sl-shared-assets"
11
- version = "1.0.0rc5"
11
+ version = "1.0.0rc7"
12
12
  description = "Stores assets shared between multiple Sun (NeuroAI) lab data pipelines."
13
13
  readme = "README.md"
14
14
  license = { file = "LICENSE" }
@@ -87,7 +87,7 @@ class ProjectConfiguration(YamlConfig):
87
87
  local_root_directory: str | Path = Path("/media/Data/Experiments")
88
88
  """The absolute path to the root directory where all projects are stored on the local host-machine (VRPC). Note,
89
89
  overwriting the value of this field is pointless, as it is automatically set each time the class is instantiated."""
90
- local_server_directory: str | Path = Path("/media/cbsuwsun/storage/sun_data")
90
+ local_server_directory: str | Path = Path("/home/cybermouse/server/storage/sun_data")
91
91
  """The absolute path to the locally-mapped (via SMB protocol) root BioHPC server machine directory where to store
92
92
  all projects."""
93
93
  local_nas_directory: str | Path = Path("/home/cybermouse/nas/rawdata")
@@ -205,12 +205,9 @@ class ProjectConfiguration(YamlConfig):
205
205
  with open(path_file, "w") as f:
206
206
  f.write(str(root_path))
207
207
 
208
- # Otherwise, uses the root path and the project name to resolve the path to the project configuration
209
- # directory and load the project configuration data.
210
- else:
211
- # Reads the root path from the file
212
- with open(path_file, "r") as f:
213
- root_path = Path(f.read().strip())
208
+ # Once the location of the path storage file is resolved, reads the root path from the file
209
+ with open(path_file, "r") as f:
210
+ root_path = Path(f.read().strip())
214
211
 
215
212
  # Uses the root experiment directory path to generate the path to the target project's configuration file.
216
213
  configuration_path = root_path.joinpath(project_name, "configuration", "project_configuration.yaml")
@@ -459,8 +456,8 @@ class RawData:
459
456
 
460
457
  This service method is used by the SessionData class to convert all paths in this class to be relative to the
461
458
  new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
462
- (another root). Since this is the only subclass used by both the VRPC and the BioHPC server, this method is
463
- only implemented for this class.
459
+ (another root). This method is only implemented for subclasses intended to be used both locally and on the
460
+ BioHPC server.
464
461
 
465
462
  Args:
466
463
  new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
@@ -494,15 +491,20 @@ class ProcessedData:
494
491
  """Stores the paths to the directories and files that make up the 'processed_data' session directory.
495
492
 
496
493
  The processed_data directory stores the processed session data, which is generated by running various processing
497
- pipelines on the BioHPC server. These pipelines use raw data to generate processed data, and the processed data is
498
- usually only stored on the BioHPC server. Processed data represents an intermediate step between raw data and the
499
- dataset used in the data analysis.
494
+ pipelines. These pipelines use raw data to generate processed data, which represents an intermediate step between
495
+ raw data and the dataset used in the data analysis.
496
+
497
+ Notes:
498
+ The paths from this section are typically used only on the BioHPC server. This is because most data processing
499
+ in the lab is performed using the processing server's resources. On the server, processed data is stored on
500
+ the fast volume, in contrast to raw data, which is stored on the slow volume. However, to support local testing,
501
+ the class resolves the paths in this section both locally and globally (on the server).
502
+
500
503
  """
501
504
 
502
505
  processed_data_path: str | Path
503
506
  """Stores the path to the root processed_data directory of the session. This directory stores the processed data
504
- as it is generated by various pipelines running on the BioHPC server. This directory is only stored on the BioHPC
505
- server and is not intended to be used directly for data analysis."""
507
+ as it is generated by various data processing pipelines."""
506
508
  camera_data_path: str | Path
507
509
  """Stores the output of the DeepLabCut pose estimation pipeline."""
508
510
  mesoscope_data_path: str | Path
@@ -556,6 +558,29 @@ class ProcessedData:
556
558
  ensure_directory_exists(Path(self.deeplabcut_root_path))
557
559
  ensure_directory_exists(Path(self.suite2p_configuration_path))
558
560
 
561
+ def switch_root(self, new_root: Path) -> None:
562
+ """Changes the root of the managed processed_data directory to the provided root path.
563
+
564
+ This service method is used by the SessionData class to convert all paths in this class to be relative to the
565
+ new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
566
+ (another root). This method is only implemented for subclasses intended to be used both locally and on the
567
+ BioHPC server.
568
+
569
+ Args:
570
+ new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
571
+ root session directory: pc_root/project/animal/session.
572
+ """
573
+ # Gets current root from the processed_data_path.
574
+ old_root = Path(self.processed_data_path).parents[2]
575
+
576
+ # Updates all paths by replacing old_root with new_root
577
+ self.processed_data_path = new_root.joinpath(Path(self.processed_data_path).relative_to(old_root))
578
+ self.camera_data_path = new_root.joinpath(Path(self.camera_data_path).relative_to(old_root))
579
+ self.mesoscope_data_path = new_root.joinpath(Path(self.mesoscope_data_path).relative_to(old_root))
580
+ self.behavior_data_path = new_root.joinpath(Path(self.behavior_data_path).relative_to(old_root))
581
+ self.deeplabcut_root_path = new_root.joinpath(Path(self.deeplabcut_root_path).relative_to(old_root))
582
+ self.suite2p_configuration_path = new_root.joinpath(Path(self.suite2p_configuration_path).relative_to(old_root))
583
+
559
584
 
560
585
  @dataclass()
561
586
  class PersistentData:
@@ -735,7 +760,7 @@ class SessionData(YamlConfig):
735
760
  """Stores the name (timestamp-based ID) of the managed session."""
736
761
  session_type: str
737
762
  """Stores the type of the session. Primarily, this determines how to read the session_descriptor.yaml file. Has
738
- to be set to one of the three supported types: 'Lick training', 'Run training' or 'Experiment'.
763
+ to be set to one of the four supported types: 'Lick training', 'Run training', 'Window checking' or 'Experiment'.
739
764
  """
740
765
  experiment_name: str | None
741
766
  """Stores the name of the experiment configuration file. If the session_type field is set to 'Experiment', this
@@ -747,8 +772,9 @@ class SessionData(YamlConfig):
747
772
  class initialization location (VRPC or BioHPC server), the class automatically resolves the root directory path to
748
773
  either the VRPC project directory or the BioHPC cluster storage volume."""
749
774
  processed_data: ProcessedData
750
- """Stores the paths to various directories used to store processed session data. This is automatically
751
- resolved to the fast BioHPC volume (workdir) in all cases, as processed data should only exist on the server."""
775
+ """Stores the paths to various directories used to store processed session data. Note, when this section is
776
+ resolved for VRPC, it uses the same local session directory as the raw_data folder. When this is resolved for the
777
+ BioHPC server, it uses the 'fast' volume path."""
752
778
  persistent_data: PersistentData
753
779
  """Stores the paths to various files and directories kept on VRPC and ScanImagePC after the session data is
754
780
  transferred to long-term storage destinations."""
@@ -806,16 +832,11 @@ class SessionData(YamlConfig):
806
832
  biohpc_root = Path(project_configuration.local_server_directory)
807
833
  nas_root = Path(project_configuration.local_nas_directory)
808
834
 
809
- # Also extracts the path to fast (working) directory on the BioHPC server. This is used to configure the
810
- # paths for data processing, which happens on the server.
811
- biohpc_workdir = Path(project_configuration.remote_working_directory)
812
-
813
835
  # Extracts the name of the project stored inside the project configuration file.
814
836
  project_name = project_configuration.project_name
815
837
 
816
838
  # Constructs the session directory path and generates the directory
817
839
  session_path = vrpc_root.joinpath(project_name, animal_id, session_name)
818
- remote_session_path = biohpc_workdir.joinpath(project_name, animal_id, session_name)
819
840
 
820
841
  # Handles potential session name conflicts
821
842
  counter = 0
@@ -823,7 +844,6 @@ class SessionData(YamlConfig):
823
844
  counter += 1
824
845
  new_session_name = f"{session_name}_{counter}"
825
846
  session_path = vrpc_root.joinpath(project_name, animal_id, new_session_name)
826
- remote_session_path = biohpc_workdir.joinpath(project_name, animal_id, new_session_name)
827
847
 
828
848
  # If a conflict is detected and resolved, warns the user about the resolved conflict.
829
849
  if counter > 0:
@@ -854,14 +874,12 @@ class SessionData(YamlConfig):
854
874
  raw_data.make_dirs() # Generates the local directory tree
855
875
 
856
876
  processed_data = ProcessedData(
857
- processed_data_path=remote_session_path.joinpath("processed_data"),
858
- camera_data_path=remote_session_path.joinpath("processed_data", "camera_data"),
859
- mesoscope_data_path=remote_session_path.joinpath("processed_data", "mesoscope_data"),
860
- behavior_data_path=remote_session_path.joinpath("processed_data", "behavior_data"),
861
- deeplabcut_root_path=biohpc_workdir.joinpath(project_name, "deeplabcut"),
862
- suite2p_configuration_path=biohpc_workdir.joinpath(
863
- project_name, "configuration", "suite2p_configuration.yaml"
864
- ),
877
+ processed_data_path=session_path.joinpath("processed_data"),
878
+ camera_data_path=session_path.joinpath("processed_data", "camera_data"),
879
+ mesoscope_data_path=session_path.joinpath("processed_data", "mesoscope_data"),
880
+ behavior_data_path=session_path.joinpath("processed_data", "behavior_data"),
881
+ deeplabcut_root_path=vrpc_root.joinpath(project_name, "deeplabcut"),
882
+ suite2p_configuration_path=vrpc_root.joinpath(project_name, "configuration", "suite2p_configuration.yaml"),
865
883
  )
866
884
 
867
885
  vrpc_persistent_path = vrpc_root.joinpath(project_name, animal_id, "persistent_data")
@@ -968,17 +986,32 @@ class SessionData(YamlConfig):
968
986
  # Loads class data from .yaml
969
987
  instance: SessionData = cls.from_yaml(file_path=session_path) # type: ignore
970
988
 
971
- # Depending on whether the class is initialized on the VRPC or BioHPC server, resolves the local (raw_data)
972
- # directory path. With the way this class is used, if on_server is False, the class is already
973
- # well-configured. This is because the class is always created on the VRPC and, when it leaves VRPC, it is
974
- # never used on VRPC again. Therefore, additional processing is ONLY done when on_server is True.
975
- if on_server:
976
- # Reconfigures the raw_data section to use the root provided as part of the session_path.
977
- instance.raw_data.switch_root(new_root=session_path)
989
+ # The method assumes that the 'donor' .yaml file is always stored inside the raw_data directory of the session
990
+ # to be processed. Since the directory itself might have moved (between or even within the same PC) relative to
991
+ # where it was when the SessionData snapshot was generated, reconfigures the paths to all raw_data files using
992
+ # the root from above.
993
+ instance.raw_data.switch_root(new_root=session_path)
994
+
995
+ # Resolves the paths to the processed_data directories. The resolution strategy depends on whether the method is
996
+ # called on the VRPC (locally) or the BioHPC server (remotely).
997
+ if not on_server:
998
+ # Local runtimes use the same root session directory for both raw_data and processed_data. This stems from
999
+ # the assumption that most local machines in the lab only use NVME (fast) volumes and, therefore, do not
1000
+ # need to separate 'storage' and 'working' data.
1001
+ instance.processed_data.switch_root(new_root=session_path)
1002
+
1003
+ else:
1004
+ # The BioHPC server stores raw_data on slow volume and processed_data on fast (NVME) volume. Therefore, to
1005
+ # configure processed_data paths, the method first needs to load the fast volume root path from the
1006
+ # project_configuration.yaml file stored in the raw_data folder.
1007
+ project_configuration: ProjectConfiguration = ProjectConfiguration.load(
1008
+ project_name=instance.project_name,
1009
+ configuration_path=Path(instance.raw_data.project_configuration_path),
1010
+ )
1011
+ instance.processed_data.switch_root(new_root=Path(project_configuration.remote_working_directory))
978
1012
 
979
- # Processed Data section is always configured to use the BioHPC server root. Calls its' make_dirs() method
980
- # to setup directories
981
- instance.processed_data.make_dirs()
1013
+ # Generates processed_data directories
1014
+ instance.processed_data.make_dirs()
982
1015
 
983
1016
  # Returns the initialized SessionData instance to caller
984
1017
  return instance
@@ -1331,6 +1364,10 @@ class ProcedureData:
1331
1364
  """Stores surgeon's notes taken during the surgery."""
1332
1365
  post_op_notes: str
1333
1366
  """Stores surgeon's notes taken during the post-surgery recovery period."""
1367
+ surgery_quality: int = 0
1368
+ """Stores the quality of the surgical intervention as a numeric level. 0 indicates unusable (bad) result, 1
1369
+ indicates usable result that is not good enough to be included in a publication, 2 indicates publication-grade
1370
+ result."""
1334
1371
 
1335
1372
 
1336
1373
  @dataclass
@@ -163,8 +163,8 @@ class RawData:
163
163
 
164
164
  This service method is used by the SessionData class to convert all paths in this class to be relative to the
165
165
  new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
166
- (another root). Since this is the only subclass used by both the VRPC and the BioHPC server, this method is
167
- only implemented for this class.
166
+ (another root). This method is only implemented for subclasses intended to be used both locally and on the
167
+ BioHPC server.
168
168
 
169
169
  Args:
170
170
  new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
@@ -176,9 +176,15 @@ class ProcessedData:
176
176
  """Stores the paths to the directories and files that make up the 'processed_data' session directory.
177
177
 
178
178
  The processed_data directory stores the processed session data, which is generated by running various processing
179
- pipelines on the BioHPC server. These pipelines use raw data to generate processed data, and the processed data is
180
- usually only stored on the BioHPC server. Processed data represents an intermediate step between raw data and the
181
- dataset used in the data analysis.
179
+ pipelines. These pipelines use raw data to generate processed data, which represents an intermediate step between
180
+ raw data and the dataset used in the data analysis.
181
+
182
+ Notes:
183
+ The paths from this section are typically used only on the BioHPC server. This is because most data processing
184
+ in the lab is performed using the processing server's resources. On the server, processed data is stored on
185
+ the fast volume, in contrast to raw data, which is stored on the slow volume. However, to support local testing,
186
+ the class resolves the paths in this section both locally and globally (on the server).
187
+
182
188
  """
183
189
 
184
190
  processed_data_path: str | Path
@@ -203,6 +209,18 @@ class ProcessedData:
203
209
  This method is used by the BioHPC server to generate the processed_data directory as part of the sl-forgery
204
210
  library runtime.
205
211
  """
212
+ def switch_root(self, new_root: Path) -> None:
213
+ """Changes the root of the managed processed_data directory to the provided root path.
214
+
215
+ This service method is used by the SessionData class to convert all paths in this class to be relative to the
216
+ new root. This is used to adjust the SessionData instance to work for the VRPC (one root) or the BioHPC server
217
+ (another root). This method is only implemented for subclasses intended to be used both locally and on the
218
+ BioHPC server.
219
+
220
+ Args:
221
+ new_root: The new root directory to use for all paths inside the instance. This has to be the path to the
222
+ root session directory: pc_root/project/animal/session.
223
+ """
206
224
 
207
225
  @dataclass()
208
226
  class PersistentData:
@@ -586,6 +604,7 @@ class ProcedureData:
586
604
  protocol: str
587
605
  surgery_notes: str
588
606
  post_op_notes: str
607
+ surgery_quality: int = ...
589
608
 
590
609
  @dataclass
591
610
  class ImplantData: