sl-shared-assets 3.1.3__py3-none-any.whl → 4.0.1__py3-none-any.whl

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.

@@ -11,6 +11,7 @@ from .tools import (
11
11
  ProjectManifest,
12
12
  resolve_p53_marker,
13
13
  transfer_directory,
14
+ generate_project_manifest,
14
15
  calculate_directory_checksum,
15
16
  )
16
17
  from .server import Job, Server, JupyterJob, ServerCredentials
@@ -30,6 +31,7 @@ from .data_classes import (
30
31
  ExperimentState,
31
32
  ExperimentTrial,
32
33
  MesoscopeCameras,
34
+ TrackerFileNames,
33
35
  ProcessingTracker,
34
36
  AcquisitionSystems,
35
37
  MesoscopePositions,
@@ -42,6 +44,8 @@ from .data_classes import (
42
44
  MesoscopeSystemConfiguration,
43
45
  MesoscopeExperimentDescriptor,
44
46
  MesoscopeExperimentConfiguration,
47
+ generate_manager_id,
48
+ get_processing_tracker,
45
49
  get_system_configuration_data,
46
50
  set_system_configuration_file,
47
51
  )
@@ -86,9 +90,13 @@ __all__ = [
86
90
  "SessionTypes",
87
91
  "AcquisitionSystems",
88
92
  "WindowCheckingDescriptor",
93
+ "get_processing_tracker",
94
+ "generate_manager_id",
95
+ "TrackerFileNames",
89
96
  # Tools package
90
97
  "ProjectManifest",
91
98
  "resolve_p53_marker",
92
99
  "transfer_directory",
93
100
  "calculate_directory_checksum",
101
+ "generate_project_manifest",
94
102
  ]
@@ -2,6 +2,7 @@ from .tools import (
2
2
  ProjectManifest as ProjectManifest,
3
3
  resolve_p53_marker as resolve_p53_marker,
4
4
  transfer_directory as transfer_directory,
5
+ generate_project_manifest as generate_project_manifest,
5
6
  calculate_directory_checksum as calculate_directory_checksum,
6
7
  )
7
8
  from .server import (
@@ -26,6 +27,7 @@ from .data_classes import (
26
27
  ExperimentState as ExperimentState,
27
28
  ExperimentTrial as ExperimentTrial,
28
29
  MesoscopeCameras as MesoscopeCameras,
30
+ TrackerFileNames as TrackerFileNames,
29
31
  ProcessingTracker as ProcessingTracker,
30
32
  AcquisitionSystems as AcquisitionSystems,
31
33
  MesoscopePositions as MesoscopePositions,
@@ -38,6 +40,8 @@ from .data_classes import (
38
40
  MesoscopeSystemConfiguration as MesoscopeSystemConfiguration,
39
41
  MesoscopeExperimentDescriptor as MesoscopeExperimentDescriptor,
40
42
  MesoscopeExperimentConfiguration as MesoscopeExperimentConfiguration,
43
+ generate_manager_id as generate_manager_id,
44
+ get_processing_tracker as get_processing_tracker,
41
45
  get_system_configuration_data as get_system_configuration_data,
42
46
  set_system_configuration_file as set_system_configuration_file,
43
47
  )
@@ -76,8 +80,12 @@ __all__ = [
76
80
  "SessionTypes",
77
81
  "AcquisitionSystems",
78
82
  "WindowCheckingDescriptor",
83
+ "get_processing_tracker",
84
+ "generate_manager_id",
85
+ "TrackerFileNames",
79
86
  "ProjectManifest",
80
87
  "resolve_p53_marker",
81
88
  "transfer_directory",
82
89
  "calculate_directory_checksum",
90
+ "generate_project_manifest",
83
91
  ]
sl_shared_assets/cli.py CHANGED
@@ -7,7 +7,7 @@ from ataraxis_base_utilities import LogLevel, console, ensure_directory_exists
7
7
 
8
8
  from .tools import ascend_tyche_data, resolve_p53_marker, verify_session_checksum, generate_project_manifest
9
9
  from .server import Server, JupyterJob, generate_server_credentials
10
- from .data_classes import SessionData, ProcessingTracker
10
+ from .data_classes import SessionData, TrackerFileNames, get_processing_tracker
11
11
 
12
12
 
13
13
  @click.command()
@@ -18,6 +18,19 @@ from .data_classes import SessionData, ProcessingTracker
18
18
  required=True,
19
19
  help="The absolute path to the session directory whose raw data needs to be verified for potential corruption.",
20
20
  )
21
+ @click.option(
22
+ "-id",
23
+ "--manager_id",
24
+ type=int,
25
+ required=True,
26
+ default=0,
27
+ show_default=True,
28
+ help=(
29
+ "The xxHash-64 hash value that represents the unique identifier for the process that manages this runtime. "
30
+ "This is primarily used when calling this CLI on remote compute servers to ensure that only a single process "
31
+ "can execute the CLI at a time."
32
+ ),
33
+ )
21
34
  @click.option(
22
35
  "-c",
23
36
  "--create_processed_directories",
@@ -54,7 +67,11 @@ from .data_classes import SessionData, ProcessingTracker
54
67
  ),
55
68
  )
56
69
  def verify_session_integrity(
57
- session_path: Path, create_processed_directories: bool, processed_data_root: Path | None, update_manifest: bool
70
+ session_path: Path,
71
+ manager_id: int,
72
+ create_processed_directories: bool,
73
+ processed_data_root: Path | None,
74
+ update_manifest: bool,
58
75
  ) -> None:
59
76
  """Checks the integrity of the target session's raw data (contents of the raw_data directory).
60
77
 
@@ -73,14 +90,15 @@ def verify_session_integrity(
73
90
 
74
91
  # Runs the verification process
75
92
  verify_session_checksum(
76
- session,
93
+ session_path=session,
94
+ manager_id=manager_id,
77
95
  create_processed_data_directory=create_processed_directories,
78
96
  processed_data_root=processed_data_root,
79
97
  update_manifest=update_manifest,
80
98
  )
81
99
 
82
100
  # Checks the outcome of the verification process
83
- tracker = ProcessingTracker(file_path=session_data.raw_data.integrity_verification_tracker_path)
101
+ tracker = get_processing_tracker(root=session_data.raw_data.raw_data_path, file_name=TrackerFileNames.INTEGRITY)
84
102
  if tracker.is_complete:
85
103
  # noinspection PyTypeChecker
86
104
  console.echo(message=f"Session {session.stem} raw data integrity: Verified.", level=LogLevel.SUCCESS)
@@ -448,11 +466,7 @@ def start_jupyter_server(
448
466
  is_flag=True,
449
467
  show_default=True,
450
468
  default=False,
451
- help=(
452
- "Determines whether the command should create or remove the dataset integration marker. Do not enable this "
453
- "flag unless you know what you are doing. It is only safe to enable this flag if the session is not currently "
454
- "being integrated into any datasets."
455
- ),
469
+ help="Determines whether the command should create or remove the dataset integration marker.",
456
470
  )
457
471
  @click.option(
458
472
  "-um",
sl_shared_assets/cli.pyi CHANGED
@@ -13,11 +13,16 @@ from .server import (
13
13
  )
14
14
  from .data_classes import (
15
15
  SessionData as SessionData,
16
- ProcessingTracker as ProcessingTracker,
16
+ TrackerFileNames as TrackerFileNames,
17
+ get_processing_tracker as get_processing_tracker,
17
18
  )
18
19
 
19
20
  def verify_session_integrity(
20
- session_path: Path, create_processed_directories: bool, processed_data_root: Path | None, update_manifest: bool
21
+ session_path: Path,
22
+ manager_id: int,
23
+ create_processed_directories: bool,
24
+ processed_data_root: Path | None,
25
+ update_manifest: bool,
21
26
  ) -> None:
22
27
  """Checks the integrity of the target session's raw data (contents of the raw_data directory).
23
28
 
@@ -12,7 +12,16 @@ from .runtime_data import (
12
12
  WindowCheckingDescriptor,
13
13
  MesoscopeExperimentDescriptor,
14
14
  )
15
- from .session_data import RawData, SessionData, SessionTypes, ProcessedData, ProcessingTracker
15
+ from .session_data import (
16
+ RawData,
17
+ SessionData,
18
+ SessionTypes,
19
+ ProcessedData,
20
+ TrackerFileNames,
21
+ ProcessingTracker,
22
+ generate_manager_id,
23
+ get_processing_tracker,
24
+ )
16
25
  from .surgery_data import (
17
26
  DrugData,
18
27
  ImplantData,
@@ -65,4 +74,7 @@ __all__ = [
65
74
  "AcquisitionSystems",
66
75
  "SessionTypes",
67
76
  "WindowCheckingDescriptor",
77
+ "get_processing_tracker",
78
+ "generate_manager_id",
79
+ "TrackerFileNames",
68
80
  ]
@@ -12,7 +12,10 @@ from .session_data import (
12
12
  SessionData as SessionData,
13
13
  SessionTypes as SessionTypes,
14
14
  ProcessedData as ProcessedData,
15
+ TrackerFileNames as TrackerFileNames,
15
16
  ProcessingTracker as ProcessingTracker,
17
+ generate_manager_id as generate_manager_id,
18
+ get_processing_tracker as get_processing_tracker,
16
19
  )
17
20
  from .surgery_data import (
18
21
  DrugData as DrugData,
@@ -66,4 +69,7 @@ __all__ = [
66
69
  "AcquisitionSystems",
67
70
  "SessionTypes",
68
71
  "WindowCheckingDescriptor",
72
+ "get_processing_tracker",
73
+ "generate_manager_id",
74
+ "TrackerFileNames",
69
75
  ]
@@ -560,7 +560,7 @@ def get_system_configuration_data() -> MesoscopeSystemConfiguration:
560
560
  app_dir = Path(appdirs.user_data_dir(appname="sun_lab_data", appauthor="sun_lab"))
561
561
  path_file = app_dir.joinpath("configuration_path.txt")
562
562
 
563
- # If the cache file or the Sun lab data directory do not exist, aborts with an error
563
+ # If the cache file or the Sun lab data directory does not exist, aborts with an error
564
564
  if not path_file.exists():
565
565
  message = (
566
566
  "Unable to resolve the path to the local system configuration file, as local machine does not have the "
@@ -87,9 +87,6 @@ class LickTrainingDescriptor(YamlConfig):
87
87
  """The ID of the experimenter running the session."""
88
88
  mouse_weight_g: float
89
89
  """The weight of the animal, in grams, at the beginning of the session."""
90
- dispensed_water_volume_ml: float
91
- """Stores the total water volume, in milliliters, dispensed during runtime. This excludes the water volume
92
- dispensed during the paused (idle) state."""
93
90
  minimum_reward_delay_s: int
94
91
  """Stores the minimum delay, in seconds, that can separate the delivery of two consecutive water rewards."""
95
92
  maximum_reward_delay_s: int
@@ -102,17 +99,23 @@ class LickTrainingDescriptor(YamlConfig):
102
99
  """Stores the maximum number of consecutive rewards that can be delivered without the animal consuming them. If
103
100
  the animal receives this many rewards without licking (consuming) them, reward delivery is paused until the animal
104
101
  consumes the rewards."""
102
+ dispensed_water_volume_ml: float = 0.0
103
+ """Stores the total water volume, in milliliters, dispensed during runtime. This excludes the water volume
104
+ dispensed during the paused (idle) state."""
105
105
  pause_dispensed_water_volume_ml: float = 0.0
106
106
  """Stores the total water volume, in milliliters, dispensed during the paused (idle) state."""
107
- experimenter_notes: str = "Replace this with your notes."
108
- """This field is not set during runtime. It is expected that each experimenter replaces this field with their
109
- notes made during runtime."""
110
107
  experimenter_given_water_volume_ml: float = 0.0
111
108
  """The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
112
109
  """
110
+ preferred_session_water_volume_ml: float = 0.0
111
+ """The volume of water, in milliliters, the animal should be receiving during the session runtime if its
112
+ performance matches experimenter-specified threshold."""
113
113
  incomplete: bool = False
114
114
  """If this field is set to True, the session is marked as 'incomplete' and automatically excluded from all further
115
115
  Sun lab automated processing and analysis."""
116
+ experimenter_notes: str = "Replace this with your notes."
117
+ """This field is not set during runtime. It is expected that each experimenter replaces this field with their
118
+ notes made during runtime."""
116
119
 
117
120
 
118
121
  @dataclass()
@@ -123,8 +126,6 @@ class RunTrainingDescriptor(YamlConfig):
123
126
  """The ID of the experimenter running the session."""
124
127
  mouse_weight_g: float
125
128
  """The weight of the animal, in grams, at the beginning of the session."""
126
- dispensed_water_volume_ml: float
127
- """Stores the total water volume, in milliliters, dispensed during runtime."""
128
129
  final_run_speed_threshold_cm_s: float
129
130
  """Stores the final running speed threshold, in centimeters per second, that was active at the end of training."""
130
131
  final_run_duration_threshold_s: float
@@ -154,17 +155,23 @@ class RunTrainingDescriptor(YamlConfig):
154
155
  """Stores the maximum time, in seconds, the animal can dip below the running speed threshold to still receive the
155
156
  reward. This allows animals that 'run' by taking a series of large steps, briefly dipping below speed threshold at
156
157
  the end of each step, to still get water rewards."""
158
+ dispensed_water_volume_ml: float = 0.0
159
+ """Stores the total water volume, in milliliters, dispensed during runtime. This excludes the water volume
160
+ dispensed during the paused (idle) state."""
157
161
  pause_dispensed_water_volume_ml: float = 0.0
158
162
  """Stores the total water volume, in milliliters, dispensed during the paused (idle) state."""
159
- experimenter_notes: str = "Replace this with your notes."
160
- """This field is not set during runtime. It is expected that each experimenter will replace this field with their
161
- notes made during runtime."""
162
163
  experimenter_given_water_volume_ml: float = 0.0
163
164
  """The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
164
165
  """
166
+ preferred_session_water_volume_ml: float = 0.0
167
+ """The volume of water, in milliliters, the animal should be receiving during the session runtime if its
168
+ performance matches experimenter-specified threshold."""
165
169
  incomplete: bool = False
166
170
  """If this field is set to True, the session is marked as 'incomplete' and automatically excluded from all further
167
171
  Sun lab automated processing and analysis."""
172
+ experimenter_notes: str = "Replace this with your notes."
173
+ """This field is not set during runtime. It is expected that each experimenter will replace this field with their
174
+ notes made during runtime."""
168
175
 
169
176
 
170
177
  @dataclass()
@@ -175,23 +182,27 @@ class MesoscopeExperimentDescriptor(YamlConfig):
175
182
  """The ID of the experimenter running the session."""
176
183
  mouse_weight_g: float
177
184
  """The weight of the animal, in grams, at the beginning of the session."""
178
- dispensed_water_volume_ml: float
179
- """Stores the total water volume, in milliliters, dispensed during runtime."""
180
185
  maximum_unconsumed_rewards: int = 1
181
186
  """Stores the maximum number of consecutive rewards that can be delivered without the animal consuming them. If
182
187
  the animal receives this many rewards without licking (consuming) them, reward delivery is paused until the animal
183
188
  consumes the rewards."""
184
- experimenter_notes: str = "Replace this with your notes."
185
- """This field is not set during runtime. It is expected that each experimenter will replace this field with their
186
- notes made during runtime."""
189
+ dispensed_water_volume_ml: float = 0.0
190
+ """Stores the total water volume, in milliliters, dispensed during runtime. This excludes the water volume
191
+ dispensed during the paused (idle) state."""
187
192
  pause_dispensed_water_volume_ml: float = 0.0
188
193
  """Stores the total water volume, in milliliters, dispensed during the paused (idle) state."""
189
194
  experimenter_given_water_volume_ml: float = 0.0
190
195
  """The additional volume of water, in milliliters, administered by the experimenter to the animal after the session.
191
196
  """
197
+ preferred_session_water_volume_ml: float = 0.0
198
+ """The volume of water, in milliliters, the animal should be receiving during the session runtime if its
199
+ performance matches experimenter-specified threshold."""
192
200
  incomplete: bool = False
193
201
  """If this field is set to True, the session is marked as 'incomplete' and automatically excluded from all further
194
202
  Sun lab automated processing and analysis."""
203
+ experimenter_notes: str = "Replace this with your notes."
204
+ """This field is not set during runtime. It is expected that each experimenter will replace this field with their
205
+ notes made during runtime."""
195
206
 
196
207
 
197
208
  @dataclass()
@@ -206,14 +217,14 @@ class WindowCheckingDescriptor(YamlConfig):
206
217
 
207
218
  experimenter: str
208
219
  """The ID of the experimenter running the session."""
209
- experimenter_notes: str = "Replace this with your notes."
210
- """The notes on the quality of the cranial window and animal's suitability for the target project."""
211
220
  surgery_quality: int = 0
212
221
  """The quality of the cranial window and surgical intervention on a scale from 0 (non-usable) to
213
222
  3 (high-tier publication grade) inclusive."""
214
223
  incomplete: bool = True
215
224
  """Window checking sessions are always considered 'incomplete', as they do not contain the full range of
216
225
  information collected as part of a 'standard' behavior training or experiment session."""
226
+ experimenter_notes: str = "Replace this with your notes."
227
+ """The notes on the quality of the cranial window and animal's suitability for the target project."""
217
228
 
218
229
 
219
230
  @dataclass()
@@ -49,16 +49,17 @@ class LickTrainingDescriptor(YamlConfig):
49
49
 
50
50
  experimenter: str
51
51
  mouse_weight_g: float
52
- dispensed_water_volume_ml: float
53
52
  minimum_reward_delay_s: int
54
53
  maximum_reward_delay_s: int
55
54
  maximum_water_volume_ml: float
56
55
  maximum_training_time_m: int
57
56
  maximum_unconsumed_rewards: int = ...
57
+ dispensed_water_volume_ml: float = ...
58
58
  pause_dispensed_water_volume_ml: float = ...
59
- experimenter_notes: str = ...
60
59
  experimenter_given_water_volume_ml: float = ...
60
+ preferred_session_water_volume_ml: float = ...
61
61
  incomplete: bool = ...
62
+ experimenter_notes: str = ...
62
63
 
63
64
  @dataclass()
64
65
  class RunTrainingDescriptor(YamlConfig):
@@ -66,7 +67,6 @@ class RunTrainingDescriptor(YamlConfig):
66
67
 
67
68
  experimenter: str
68
69
  mouse_weight_g: float
69
- dispensed_water_volume_ml: float
70
70
  final_run_speed_threshold_cm_s: float
71
71
  final_run_duration_threshold_s: float
72
72
  initial_run_speed_threshold_cm_s: float
@@ -78,10 +78,12 @@ class RunTrainingDescriptor(YamlConfig):
78
78
  maximum_training_time_m: int
79
79
  maximum_unconsumed_rewards: int = ...
80
80
  maximum_idle_time_s: float = ...
81
+ dispensed_water_volume_ml: float = ...
81
82
  pause_dispensed_water_volume_ml: float = ...
82
- experimenter_notes: str = ...
83
83
  experimenter_given_water_volume_ml: float = ...
84
+ preferred_session_water_volume_ml: float = ...
84
85
  incomplete: bool = ...
86
+ experimenter_notes: str = ...
85
87
 
86
88
  @dataclass()
87
89
  class MesoscopeExperimentDescriptor(YamlConfig):
@@ -89,12 +91,13 @@ class MesoscopeExperimentDescriptor(YamlConfig):
89
91
 
90
92
  experimenter: str
91
93
  mouse_weight_g: float
92
- dispensed_water_volume_ml: float
93
94
  maximum_unconsumed_rewards: int = ...
94
- experimenter_notes: str = ...
95
+ dispensed_water_volume_ml: float = ...
95
96
  pause_dispensed_water_volume_ml: float = ...
96
97
  experimenter_given_water_volume_ml: float = ...
98
+ preferred_session_water_volume_ml: float = ...
97
99
  incomplete: bool = ...
100
+ experimenter_notes: str = ...
98
101
 
99
102
  @dataclass()
100
103
  class WindowCheckingDescriptor(YamlConfig):
@@ -107,9 +110,9 @@ class WindowCheckingDescriptor(YamlConfig):
107
110
  """
108
111
 
109
112
  experimenter: str
110
- experimenter_notes: str = ...
111
113
  surgery_quality: int = ...
112
114
  incomplete: bool = ...
115
+ experimenter_notes: str = ...
113
116
 
114
117
  @dataclass()
115
118
  class ZaberPositions(YamlConfig):