sl-shared-assets 1.0.0rc18__py3-none-any.whl → 1.0.0rc20__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.

Files changed (27) hide show
  1. sl_shared_assets/__init__.pyi +71 -0
  2. sl_shared_assets/cli.pyi +28 -0
  3. sl_shared_assets/data_classes/__init__.pyi +61 -0
  4. sl_shared_assets/data_classes/configuration_data.pyi +37 -0
  5. sl_shared_assets/data_classes/runtime_data.py +12 -0
  6. sl_shared_assets/data_classes/runtime_data.pyi +148 -0
  7. sl_shared_assets/data_classes/session_data.py +12 -9
  8. sl_shared_assets/data_classes/session_data.pyi +544 -0
  9. sl_shared_assets/data_classes/surgery_data.pyi +89 -0
  10. sl_shared_assets/server/__init__.pyi +8 -0
  11. sl_shared_assets/server/job.pyi +94 -0
  12. sl_shared_assets/server/server.pyi +95 -0
  13. sl_shared_assets/suite2p/__init__.pyi +4 -0
  14. sl_shared_assets/suite2p/multi_day.py +7 -8
  15. sl_shared_assets/suite2p/multi_day.pyi +104 -0
  16. sl_shared_assets/suite2p/single_day.py +5 -4
  17. sl_shared_assets/suite2p/single_day.pyi +220 -0
  18. sl_shared_assets/tools/__init__.pyi +5 -0
  19. sl_shared_assets/tools/ascension_tools.pyi +68 -0
  20. sl_shared_assets/tools/packaging_tools.pyi +52 -0
  21. sl_shared_assets/tools/transfer_tools.pyi +53 -0
  22. {sl_shared_assets-1.0.0rc18.dist-info → sl_shared_assets-1.0.0rc20.dist-info}/METADATA +1 -1
  23. sl_shared_assets-1.0.0rc20.dist-info/RECORD +40 -0
  24. sl_shared_assets-1.0.0rc18.dist-info/RECORD +0 -23
  25. {sl_shared_assets-1.0.0rc18.dist-info → sl_shared_assets-1.0.0rc20.dist-info}/WHEEL +0 -0
  26. {sl_shared_assets-1.0.0rc18.dist-info → sl_shared_assets-1.0.0rc20.dist-info}/entry_points.txt +0 -0
  27. {sl_shared_assets-1.0.0rc18.dist-info → sl_shared_assets-1.0.0rc20.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,68 @@
1
+ from pathlib import Path
2
+
3
+ from ..data_classes import (
4
+ SessionData as SessionData,
5
+ ProjectConfiguration as ProjectConfiguration,
6
+ )
7
+ from .transfer_tools import transfer_directory as transfer_directory
8
+ from .packaging_tools import calculate_directory_checksum as calculate_directory_checksum
9
+
10
+ def _generate_session_name(acquisition_path: Path) -> str:
11
+ """Generates a session name using the last modification time of a zstack.mat or MotionEstimator.me file.
12
+
13
+ This worker function uses one of the motion estimation files stored in each Tyche 'acquisition' subfolder to
14
+ generate a modern Sun lab timestamp-based session name. This is used to translate the original Tyche session naming
15
+ pattern into the pattern used by all modern Sun lab projects and pipelines.
16
+
17
+ Args:
18
+ acquisition_path: The absolute path to the target acquisition folder. These folders are found under the 'day'
19
+ folders for each animal, e.g.: Tyche-A7/2022_01_03/1.
20
+
21
+ Returns:
22
+ The modernized session name.
23
+ """
24
+
25
+ def _reorganize_data(session_data: SessionData, source_root: Path) -> bool:
26
+ """Reorganizes and moves the session's data from the source folder in the old Tyche data hierarchy to the raw_data
27
+ folder in the newly created modern hierarchy.
28
+
29
+ This worker function is used to physically rearrange the data from the original Tyche data structure to the
30
+ new data structure. It both moves the existing files to their new destinations and renames certain files to match
31
+ the modern naming convention used in the Sun lab.
32
+
33
+ Args:
34
+ session_data: The initialized SessionData instance managing the 'ascended' (modernized) session data hierarchy.
35
+ source_root: The absolute path to the old Tyche data hierarchy folder that stores session's data.
36
+
37
+ Returns:
38
+ True if the ascension process was successfully completed. False if the process encountered missing data or
39
+ otherwise did not go as expected. When the method returns False, the runtime function requests user intervention
40
+ to finalize the process manually.
41
+ """
42
+
43
+ def ascend_tyche_data(root_directory: Path, output_root_directory: Path, server_root_directory: Path) -> None:
44
+ """Reformats the old Tyche data to use the modern Sun lab layout and metadata files.
45
+
46
+ This function is used to convert old Tyche data to the modern data management standard. This is used to make the
47
+ data compatible with the modern Sun lab data workflows.
48
+
49
+ Notes:
50
+ This function is statically written to work with the raw Tyche dataset featured in the OSM manuscript:
51
+ https://www.nature.com/articles/s41586-024-08548-w. Additionally, it assumes that the dataset has been
52
+ preprocessed with the early Sun lab mesoscope compression pipeline. The function will not work for any other
53
+ project or data hierarchy.
54
+
55
+ As part of its runtime, the function automatically transfers the ascended session data to the BioHPC server.
56
+ Since transferring the data over the network is the bottleneck of this pipeline, it runs in a single-threaded
57
+ mode and is constrained by the communication channel between the local machine and the BioHPC server. Calling
58
+ this function for a large number of sessions will result in a long processing time due to the network data
59
+ transfer.
60
+
61
+ Args:
62
+ root_directory: The directory that stores one or more Tyche animal folders. This can be conceptualized as the
63
+ root directory for the Tyche project.
64
+ output_root_directory: The path to the local directory where to generate the converted Tyche project hierarchy.
65
+ Typically, this is the 'root' directory where all other Sun lab projects are stored.
66
+ server_root_directory: The path to the local filesystem-mounted BioHPC server storage directory. Note, this
67
+ directory hs to be mapped to the local filesystem via the SMB or equivalent protocol.
68
+ """
@@ -0,0 +1,52 @@
1
+ from pathlib import Path
2
+
3
+ def _calculate_file_checksum(base_directory: Path, file_path: Path) -> tuple[str, bytes]:
4
+ """Calculates xxHash3-128 checksum for a single file and its path relative to the base directory.
5
+
6
+ This function is passed to parallel workers used by the calculate_directory_hash() method that iteratively
7
+ calculates the checksum for all files inside a directory. Each call to this function returns the checksum for the
8
+ target file, which includes both the contents of the file and its path relative to the base directory.
9
+
10
+ Args:
11
+ base_directory: The path to the base (root) directory which is being checksummed by the main
12
+ 'calculate_directory_checksum' function.
13
+ file_path: The absolute path to the target file.
14
+
15
+ Returns:
16
+ A tuple with two elements. The first element is the path to the file relative to the base directory. The second
17
+ element is the xxHash3-128 checksum that covers the relative path and the contents of the file.
18
+ """
19
+
20
+ def calculate_directory_checksum(
21
+ directory: Path, num_processes: int | None = None, batch: bool = False, save_checksum: bool = True
22
+ ) -> str:
23
+ """Calculates xxHash3-128 checksum for the input directory, which includes the data of all contained files and
24
+ the directory structure information.
25
+
26
+ This function is used to generate a checksum for the raw_data directory of each experiment or training session.
27
+ Checksums are used to verify the session data integrity during transmission between the PC that acquired the data
28
+ and long-term storage locations, such as the Synology NAS or the BioHPC server. The function can be configured to
29
+ write the generated checksum as a hexadecimal string to the ax_checksum.txt file stored at the highest level of the
30
+ input directory.
31
+
32
+ Note:
33
+ This method uses multiprocessing to efficiently parallelize checksum calculation for multiple files. In
34
+ combination with xxHash3, this achieves a significant speedup over more common checksums, such as MD5 and
35
+ SHA256. Note that xxHash3 is not suitable for security purposes and is only used to ensure data integrity.
36
+
37
+ The method notifies the user about the checksum calculation process via the terminal.
38
+
39
+ The returned checksum accounts for both the contents of each file and the layout of the input directory
40
+ structure.
41
+
42
+ Args:
43
+ directory: The Path to the directory to be checksummed.
44
+ num_processes: The number of CPU processes to use for parallelizing checksum calculation. If set to None, the
45
+ function defaults to using (logical CPU count - 4).
46
+ batch: Determines whether the function is called as part of batch-processing multiple directories. This is used
47
+ to optimize progress reporting to avoid cluttering the terminal.
48
+ save_checksum: Determines whether the checksum should be saved (written to) a .txt file.
49
+
50
+ Returns:
51
+ The xxHash3-128 checksum for the input directory as a hexadecimal string.
52
+ """
@@ -0,0 +1,53 @@
1
+ from pathlib import Path
2
+
3
+ from .packaging_tools import calculate_directory_checksum as calculate_directory_checksum
4
+
5
+ def _transfer_file(source_file: Path, source_directory: Path, destination_directory: Path) -> None:
6
+ """Copies the input file from the source directory to the destination directory while preserving the file metadata.
7
+
8
+ This is a worker method used by the transfer_directory() method to move multiple files in parallel.
9
+
10
+ Notes:
11
+ If the file is found under a hierarchy of subdirectories inside the input source_directory, that hierarchy will
12
+ be preserved in the destination directory.
13
+
14
+ Args:
15
+ source_file: The file to be copied.
16
+ source_directory: The root directory where the file is located.
17
+ destination_directory: The destination directory where to move the file.
18
+ """
19
+
20
+ def transfer_directory(source: Path, destination: Path, num_threads: int = 1, verify_integrity: bool = True) -> None:
21
+ """Copies the contents of the input directory tree from source to destination while preserving the folder
22
+ structure.
23
+
24
+ This function is used to assemble the experimental data from all remote machines used in the acquisition process on
25
+ the VRPC before the data is preprocessed. It is also used to transfer the preprocessed data from the VRPC to the
26
+ SynologyNAS and the Sun lab BioHPC server.
27
+
28
+ Notes:
29
+ This method recreates the moved directory hierarchy on the destination if the hierarchy does not exist. This is
30
+ done before copying the files.
31
+
32
+ The method executes a multithreading copy operation. It does not clean up the source files. That job is handed
33
+ to the specific preprocessing function from the sl_experiment or sl-forgery libraries that calls this function.
34
+
35
+ If the method is configured to verify transferred file integrity, it reruns the xxHash3-128 checksum calculation
36
+ and compares the returned checksum to the one stored in the source directory. The method assumes that all input
37
+ directories contain the 'ax_checksum.txt' file that stores the 'source' directory checksum at the highest level
38
+ of the input directory tree.
39
+
40
+ Args:
41
+ source: The path to the directory that needs to be moved.
42
+ destination: The path to the destination directory where to move the contents of the source directory.
43
+ num_threads: The number of threads to use for parallel file transfer. This number should be set depending on the
44
+ type of transfer (local or remote) and is not guaranteed to provide improved transfer performance. For local
45
+ transfers, setting this number above 1 will likely provide a performance boost. For remote transfers using
46
+ a single TCP / IP socket (such as non-multichannel SMB protocol), the number should be set to 1.
47
+ verify_integrity: Determines whether to perform integrity verification for the transferred files. Note,
48
+ integrity verification is a time-consuming process and generally would not be a concern for most runtimes.
49
+ Therefore, it is often fine to disable this option to optimize method runtime speed.
50
+
51
+ Raises:
52
+ RuntimeError: If the transferred files do not pass the xxHas3-128 checksum integrity verification.
53
+ """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sl-shared-assets
3
- Version: 1.0.0rc18
3
+ Version: 1.0.0rc20
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/
@@ -0,0 +1,40 @@
1
+ sl_shared_assets/__init__.py,sha256=VASYVzsHnaFykp1xdEjOgQdnfuqwokaKIp387zXyFqA,2080
2
+ sl_shared_assets/__init__.pyi,sha256=jCNSKprv3odCQv30EvLrW0mzxwdljZGWyX03mMajBkQ,2163
3
+ sl_shared_assets/cli.py,sha256=a4Ja2gm4ykOac7QmHen14Jhgu6955IUQDZrysp1RpFM,4207
4
+ sl_shared_assets/cli.pyi,sha256=AhD4v9NgVge9zpGA52L42WWLYHXCbyeFXKB9e2v8Xzk,1849
5
+ sl_shared_assets/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ sl_shared_assets/data_classes/__init__.py,sha256=pq-iyd4eyv1CPVcLcQQJBVAm7XCDWuZqxurrLOMW3e0,1702
7
+ sl_shared_assets/data_classes/__init__.pyi,sha256=gnwx-0wTKxOCuq0yNoF25m63byryyzUPeWJWEcK2jMA,1794
8
+ sl_shared_assets/data_classes/configuration_data.py,sha256=zKZ3cE2pZFDRiQ7off8hu2nV9JsBly9Phc5goY4qCH4,4163
9
+ sl_shared_assets/data_classes/configuration_data.pyi,sha256=HeKJWhkVEyAcwDr2dje_Fs2Mfa41CVl38YSh7js9WRE,2024
10
+ sl_shared_assets/data_classes/runtime_data.py,sha256=GupRuTRnbp-ggLiTeEyX9r12VaWqVHpwU7FxOm3MN3M,14909
11
+ sl_shared_assets/data_classes/runtime_data.pyi,sha256=yetdFz29QQyvMmpGTdWGxKSgWAdBZ9zsPM3fluDeDIY,6808
12
+ sl_shared_assets/data_classes/session_data.py,sha256=NyrDGvvD14VnYvGyW0VS4OUHhUWyJHMQ3KfoZo3JaBY,81887
13
+ sl_shared_assets/data_classes/session_data.pyi,sha256=m5B_W4Nh9Ua-qsUOPtM8IvaPG-alnJnHe8KJiAYllr0,30830
14
+ sl_shared_assets/data_classes/surgery_data.py,sha256=Z4QZAZCz0_w7qrGMMzYn-fwwwycw3ki9SPJU0kD5Ap4,7425
15
+ sl_shared_assets/data_classes/surgery_data.pyi,sha256=jLDK1fMli2yF0RkmQcED_iMZq8XIlbIqLysZZGlEJKY,2602
16
+ sl_shared_assets/server/__init__.py,sha256=nyX6-9ACcrQeRQOCNvBVrWSTHGjRPANIG_u0aq7HPTg,426
17
+ sl_shared_assets/server/__init__.pyi,sha256=7o99f8uf6NuBjMZjNAM1FX69Qbu5uBluRSAyaUWbXOU,263
18
+ sl_shared_assets/server/job.py,sha256=M7ZytqhluEV-YQPM9VQV3SqK-F9egQ3UcLc1SLBH4rA,7885
19
+ sl_shared_assets/server/job.pyi,sha256=cxgHMpuwHsJGf_ZcTSSa2tZNzeR_GxqlICOsYGV_oy0,5655
20
+ sl_shared_assets/server/server.py,sha256=NpqWVjvxdtxHZIooBVaKY2jEBDN3dGohBzrFA0TSKIU,9380
21
+ sl_shared_assets/server/server.pyi,sha256=uu-bs5LBuOF-AL7qroYFbGc1aWgBalm-uHUXzZNxheU,4144
22
+ sl_shared_assets/suite2p/__init__.py,sha256=8N2BQNINBkH7JNODmYACHhvUH_uurTuw7w0PW3rVRYM,411
23
+ sl_shared_assets/suite2p/__init__.pyi,sha256=o2R9hcKuCbzzFwjcHdnkLyG03cMBp-Zpn93P-_A4ZFY,224
24
+ sl_shared_assets/suite2p/multi_day.py,sha256=sjteUROBxx2mAziPv42_qMeP5cqofECvd2HE5WqGjvY,13114
25
+ sl_shared_assets/suite2p/multi_day.pyi,sha256=_kxgHqtsxIG__09YVv-YKEdgClOpTdN0o6fTE1CW4Mo,4315
26
+ sl_shared_assets/suite2p/single_day.py,sha256=v0_WAvXTYVB0RjTmNDaX2dWUKjFrtNM1suwIx8IIKBQ,29983
27
+ sl_shared_assets/suite2p/single_day.pyi,sha256=UxieE15msb-MPsqnPQr_3CdbYvYLRYfx70M_yYHl-98,7924
28
+ sl_shared_assets/tools/__init__.py,sha256=UWrNfseGupOrY4OK2PgDEJ-Q3LbSrPLC2pfaLm8wYBA,468
29
+ sl_shared_assets/tools/__init__.pyi,sha256=HwriMRN-9oZRiyvl5VvP8fm5Um3_YWUB4nqnCLMDayo,314
30
+ sl_shared_assets/tools/ascension_tools.py,sha256=y2w72Czpbw9LwgsbdEx_ckzMKTZ78cgKPTIk6vRYmAk,15877
31
+ sl_shared_assets/tools/ascension_tools.pyi,sha256=AE1buiE-rSLGpSPf4TVOtxUu12u-fXL6tL10RQCsrnQ,3973
32
+ sl_shared_assets/tools/packaging_tools.py,sha256=LOKCKvT6UD_cidCONaI4ctWyej5zEwwdhhgwYrj60Kg,6746
33
+ sl_shared_assets/tools/packaging_tools.pyi,sha256=hlAP9AxF7NHtFIPKjj5ehm8Vr9qIn6xDk4VvL0JuAmk,3055
34
+ sl_shared_assets/tools/transfer_tools.py,sha256=J26kwOp_NpPSY0-xu5FTw9udte-rm_mW1FJyaTNoqQI,6606
35
+ sl_shared_assets/tools/transfer_tools.pyi,sha256=FoH7eYZe7guGHfPr0MK5ggO62uXKwD2aJ7h1Bu7PaEE,3294
36
+ sl_shared_assets-1.0.0rc20.dist-info/METADATA,sha256=fgvVyVByniPRILIqCJO_SF5uG8ICEWGlw9oEi3sIke8,47884
37
+ sl_shared_assets-1.0.0rc20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ sl_shared_assets-1.0.0rc20.dist-info/entry_points.txt,sha256=bdnmVAcK3nrKi9QEYeNMrCLFH5LQ4BMBfwbLIgLPtq4,222
39
+ sl_shared_assets-1.0.0rc20.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
40
+ sl_shared_assets-1.0.0rc20.dist-info/RECORD,,
@@ -1,23 +0,0 @@
1
- sl_shared_assets/__init__.py,sha256=VASYVzsHnaFykp1xdEjOgQdnfuqwokaKIp387zXyFqA,2080
2
- sl_shared_assets/cli.py,sha256=a4Ja2gm4ykOac7QmHen14Jhgu6955IUQDZrysp1RpFM,4207
3
- sl_shared_assets/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- sl_shared_assets/data_classes/__init__.py,sha256=pq-iyd4eyv1CPVcLcQQJBVAm7XCDWuZqxurrLOMW3e0,1702
5
- sl_shared_assets/data_classes/configuration_data.py,sha256=zKZ3cE2pZFDRiQ7off8hu2nV9JsBly9Phc5goY4qCH4,4163
6
- sl_shared_assets/data_classes/runtime_data.py,sha256=jSCvZG01gkcSUexFiKITjTJ8ZoF18qRfxiwhyrWW7-I,13964
7
- sl_shared_assets/data_classes/session_data.py,sha256=z5rt099ZOMydefxE65i5-l3brRqfoSfDdRywLsuEYaI,81597
8
- sl_shared_assets/data_classes/surgery_data.py,sha256=Z4QZAZCz0_w7qrGMMzYn-fwwwycw3ki9SPJU0kD5Ap4,7425
9
- sl_shared_assets/server/__init__.py,sha256=nyX6-9ACcrQeRQOCNvBVrWSTHGjRPANIG_u0aq7HPTg,426
10
- sl_shared_assets/server/job.py,sha256=M7ZytqhluEV-YQPM9VQV3SqK-F9egQ3UcLc1SLBH4rA,7885
11
- sl_shared_assets/server/server.py,sha256=NpqWVjvxdtxHZIooBVaKY2jEBDN3dGohBzrFA0TSKIU,9380
12
- sl_shared_assets/suite2p/__init__.py,sha256=8N2BQNINBkH7JNODmYACHhvUH_uurTuw7w0PW3rVRYM,411
13
- sl_shared_assets/suite2p/multi_day.py,sha256=2_AHI91wuxwS07GFJn8S1454uLrQGmt0bS_qBoZsHVc,13102
14
- sl_shared_assets/suite2p/single_day.py,sha256=7dgYN9FnIvxNL0uHo0CtoLng2nRxZJYtV_AfskMt6tE,29961
15
- sl_shared_assets/tools/__init__.py,sha256=UWrNfseGupOrY4OK2PgDEJ-Q3LbSrPLC2pfaLm8wYBA,468
16
- sl_shared_assets/tools/ascension_tools.py,sha256=y2w72Czpbw9LwgsbdEx_ckzMKTZ78cgKPTIk6vRYmAk,15877
17
- sl_shared_assets/tools/packaging_tools.py,sha256=LOKCKvT6UD_cidCONaI4ctWyej5zEwwdhhgwYrj60Kg,6746
18
- sl_shared_assets/tools/transfer_tools.py,sha256=J26kwOp_NpPSY0-xu5FTw9udte-rm_mW1FJyaTNoqQI,6606
19
- sl_shared_assets-1.0.0rc18.dist-info/METADATA,sha256=oLVm883kOA9Mms93kAa0qK8iBybCV5oKW29EWrDLiFg,47884
20
- sl_shared_assets-1.0.0rc18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
- sl_shared_assets-1.0.0rc18.dist-info/entry_points.txt,sha256=bdnmVAcK3nrKi9QEYeNMrCLFH5LQ4BMBfwbLIgLPtq4,222
22
- sl_shared_assets-1.0.0rc18.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
23
- sl_shared_assets-1.0.0rc18.dist-info/RECORD,,