datalab-kernel 0.1.0__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.
Files changed (36) hide show
  1. datalab_kernel-0.1.0/LICENSE +29 -0
  2. datalab_kernel-0.1.0/PKG-INFO +186 -0
  3. datalab_kernel-0.1.0/README.md +138 -0
  4. datalab_kernel-0.1.0/datalab_kernel/__init__.py +45 -0
  5. datalab_kernel-0.1.0/datalab_kernel/__main__.py +38 -0
  6. datalab_kernel-0.1.0/datalab_kernel/backends/__init__.py +33 -0
  7. datalab_kernel-0.1.0/datalab_kernel/backends/standalone.py +273 -0
  8. datalab_kernel-0.1.0/datalab_kernel/backends/webapi.py +608 -0
  9. datalab_kernel-0.1.0/datalab_kernel/install.py +163 -0
  10. datalab_kernel-0.1.0/datalab_kernel/kernel.py +116 -0
  11. datalab_kernel-0.1.0/datalab_kernel/plotter.py +202 -0
  12. datalab_kernel-0.1.0/datalab_kernel/serialization_npz.py +214 -0
  13. datalab_kernel-0.1.0/datalab_kernel/tests/__init__.py +13 -0
  14. datalab_kernel-0.1.0/datalab_kernel/tests/conftest.py +417 -0
  15. datalab_kernel-0.1.0/datalab_kernel/tests/contract/__init__.py +1 -0
  16. datalab_kernel-0.1.0/datalab_kernel/tests/contract/test_api.py +211 -0
  17. datalab_kernel-0.1.0/datalab_kernel/tests/data.py +76 -0
  18. datalab_kernel-0.1.0/datalab_kernel/tests/integration/__init__.py +9 -0
  19. datalab_kernel-0.1.0/datalab_kernel/tests/integration/test_live_backend.py +398 -0
  20. datalab_kernel-0.1.0/datalab_kernel/tests/test_webapi_backend.py +368 -0
  21. datalab_kernel-0.1.0/datalab_kernel/tests/unit/__init__.py +1 -0
  22. datalab_kernel-0.1.0/datalab_kernel/tests/unit/test_install.py +48 -0
  23. datalab_kernel-0.1.0/datalab_kernel/tests/unit/test_kernel.py +130 -0
  24. datalab_kernel-0.1.0/datalab_kernel/tests/unit/test_objects.py +235 -0
  25. datalab_kernel-0.1.0/datalab_kernel/tests/unit/test_persistence.py +191 -0
  26. datalab_kernel-0.1.0/datalab_kernel/tests/unit/test_plotter.py +163 -0
  27. datalab_kernel-0.1.0/datalab_kernel/tests/unit/test_workspace.py +254 -0
  28. datalab_kernel-0.1.0/datalab_kernel/workspace.py +463 -0
  29. datalab_kernel-0.1.0/datalab_kernel.egg-info/PKG-INFO +186 -0
  30. datalab_kernel-0.1.0/datalab_kernel.egg-info/SOURCES.txt +34 -0
  31. datalab_kernel-0.1.0/datalab_kernel.egg-info/dependency_links.txt +1 -0
  32. datalab_kernel-0.1.0/datalab_kernel.egg-info/entry_points.txt +2 -0
  33. datalab_kernel-0.1.0/datalab_kernel.egg-info/requires.txt +25 -0
  34. datalab_kernel-0.1.0/datalab_kernel.egg-info/top_level.txt +1 -0
  35. datalab_kernel-0.1.0/pyproject.toml +105 -0
  36. datalab_kernel-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, DataLab Platform Developers.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: datalab-kernel
3
+ Version: 0.1.0
4
+ Summary: A standalone Jupyter kernel for DataLab with optional live synchronization
5
+ Author-email: DataLab Platform Developers <p.raybaut@codra.fr>
6
+ License: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/DataLab-Platform/DataLab-Kernel
8
+ Project-URL: Documentation, https://datalab-kernel.readthedocs.io/
9
+ Project-URL: Repository, https://github.com/DataLab-Platform/DataLab-Kernel.git
10
+ Project-URL: Issues, https://github.com/DataLab-Platform/DataLab-Kernel/issues
11
+ Keywords: jupyter,kernel,datalab,scientific,data processing
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Framework :: Jupyter
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: License :: OSI Approved :: BSD License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: ipykernel>=6.0
27
+ Requires-Dist: jupyter-client>=7.0
28
+ Requires-Dist: numpy>=1.22
29
+ Requires-Dist: h5py>=3.0
30
+ Requires-Dist: matplotlib>=3.5
31
+ Requires-Dist: sigima>=1.0
32
+ Provides-Extra: webapi
33
+ Requires-Dist: httpx>=0.25.0; extra == "webapi"
34
+ Provides-Extra: dev
35
+ Requires-Dist: pytest>=7.0; extra == "dev"
36
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
37
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
38
+ Requires-Dist: httpx>=0.25.0; extra == "dev"
39
+ Provides-Extra: doc
40
+ Requires-Dist: sphinx>=7.0; extra == "doc"
41
+ Requires-Dist: pydata-sphinx-theme>=0.14; extra == "doc"
42
+ Requires-Dist: myst-nb>=1.0; extra == "doc"
43
+ Requires-Dist: sphinx-design>=0.5; extra == "doc"
44
+ Requires-Dist: sphinx-copybutton>=0.5; extra == "doc"
45
+ Provides-Extra: datalab
46
+ Requires-Dist: datalab-platform>=1.0; extra == "datalab"
47
+ Dynamic: license-file
48
+
49
+ # DataLab-Kernel
50
+
51
+ **A standalone Jupyter kernel providing seamless, reproducible access to DataLab workspaces, with optional live synchronization to the DataLab GUI.**
52
+
53
+ ---
54
+
55
+ ## Overview
56
+
57
+ **DataLab-Kernel** is a custom Jupyter kernel designed to bridge **DataLab** and the **Jupyter** ecosystem.
58
+
59
+ It enables scientists and engineers to:
60
+
61
+ - run reproducible analyses in Jupyter notebooks,
62
+ - interact transparently with DataLab’s internal workspace when DataLab is running,
63
+ - share notebooks that can be replayed **with or without DataLab**,
64
+ - combine narrative, code, and results without sacrificing interactive visualization.
65
+
66
+ DataLab-Kernel is **not** a replacement for DataLab’s GUI.
67
+ It is a **complementary execution layer** that turns DataLab into a hybrid scientific platform:
68
+ **GUI-driven when needed, notebook-driven when appropriate.**
69
+
70
+ ---
71
+
72
+ ## Key Features
73
+
74
+ - **Single, stable user API**
75
+ - `workspace` for data access and persistence
76
+ - `plotter` for visualization
77
+ - `sigima` for scientific processing
78
+
79
+ - **Two execution modes, one notebook**
80
+ - **Live mode**: automatic synchronization with a running DataLab instance
81
+ - **Standalone mode**: notebook-only execution, fully reproducible
82
+
83
+ - **Reproducibility by design**
84
+ - Analyses can be saved and reloaded using `.h5` files
85
+ - Notebooks run unchanged across environments
86
+
87
+ - **Performance-aware**
88
+ - Optimized data handling when DataLab is attached
89
+ - No unnecessary serialization for large datasets
90
+
91
+ - **Decoupled architecture**
92
+ - Installable independently of DataLab
93
+ - DataLab is a privileged host, not a requirement
94
+
95
+ ---
96
+
97
+ ## Typical Usage
98
+
99
+ ```python
100
+ img = workspace.get("i042")
101
+ filtered = sigima.proc.image.butterworth(img, cut_off=0.2)
102
+ workspace.add("filtered_i042", filtered)
103
+ plotter.plot("filtered_i042")
104
+ ```
105
+
106
+ Depending on the execution context:
107
+
108
+ - the result appears inline in the notebook,
109
+ - and, if DataLab is running, it also appears automatically in the DataLab GUI,
110
+ with views and metadata kept in sync.
111
+
112
+ ---
113
+
114
+ ## Execution Modes
115
+
116
+ ### Live Mode (DataLab-attached)
117
+
118
+ - DataLab launches a Jupyter server and starts `kernel-datalab`.
119
+ - The kernel detects DataLab at runtime.
120
+ - Workspace operations and visualizations are synchronized with the GUI.
121
+
122
+ Two connection methods are supported:
123
+
124
+ - **Web API** (recommended): HTTP/JSON connection using `DATALAB_WORKSPACE_URL` and `DATALAB_WORKSPACE_TOKEN` environment variables
125
+ - **XML-RPC** (legacy): Automatic connection when DataLab is running with remote control enabled
126
+
127
+ ### Standalone Mode (Notebook-only)
128
+
129
+ - The kernel is used like any standard Jupyter kernel.
130
+ - No DataLab installation or GUI is required.
131
+ - Data are managed locally and persisted to `.h5` files.
132
+
133
+ **The same notebook runs unchanged in both modes.**
134
+
135
+ ---
136
+
137
+ ## Installation
138
+
139
+ ### Standalone usage
140
+
141
+ ```bash
142
+ pip install datalab-kernel sigima
143
+ jupyter lab
144
+ ```
145
+
146
+ Then select **DataLab Kernel** from the kernel list.
147
+
148
+ ### With DataLab
149
+
150
+ When installed alongside DataLab, the kernel is automatically available and can be launched directly from the DataLab interface.
151
+
152
+ ---
153
+
154
+ ## Persistence and Sharing
155
+
156
+ Workspace state can be saved and reloaded:
157
+
158
+ ```python
159
+ workspace.save("analysis.h5")
160
+ workspace.load("analysis.h5")
161
+ ```
162
+
163
+ This enables:
164
+
165
+ - sharing notebooks and data with collaborators,
166
+ - replaying analyses without DataLab,
167
+ - resuming workflows inside DataLab by reopening the associated project.
168
+
169
+ ---
170
+
171
+ ## Documentation
172
+
173
+ - **User contract and behavior**: see `plans/specification.md`
174
+ - **Vision and architectural principles**: see `plans/architecture.md`
175
+
176
+ ---
177
+
178
+ ## Project Status
179
+
180
+ DataLab-Kernel is under active design and development.
181
+
182
+ ---
183
+
184
+ ## License
185
+
186
+ This project is released under an open-source license (see `LICENSE` file).
@@ -0,0 +1,138 @@
1
+ # DataLab-Kernel
2
+
3
+ **A standalone Jupyter kernel providing seamless, reproducible access to DataLab workspaces, with optional live synchronization to the DataLab GUI.**
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ **DataLab-Kernel** is a custom Jupyter kernel designed to bridge **DataLab** and the **Jupyter** ecosystem.
10
+
11
+ It enables scientists and engineers to:
12
+
13
+ - run reproducible analyses in Jupyter notebooks,
14
+ - interact transparently with DataLab’s internal workspace when DataLab is running,
15
+ - share notebooks that can be replayed **with or without DataLab**,
16
+ - combine narrative, code, and results without sacrificing interactive visualization.
17
+
18
+ DataLab-Kernel is **not** a replacement for DataLab’s GUI.
19
+ It is a **complementary execution layer** that turns DataLab into a hybrid scientific platform:
20
+ **GUI-driven when needed, notebook-driven when appropriate.**
21
+
22
+ ---
23
+
24
+ ## Key Features
25
+
26
+ - **Single, stable user API**
27
+ - `workspace` for data access and persistence
28
+ - `plotter` for visualization
29
+ - `sigima` for scientific processing
30
+
31
+ - **Two execution modes, one notebook**
32
+ - **Live mode**: automatic synchronization with a running DataLab instance
33
+ - **Standalone mode**: notebook-only execution, fully reproducible
34
+
35
+ - **Reproducibility by design**
36
+ - Analyses can be saved and reloaded using `.h5` files
37
+ - Notebooks run unchanged across environments
38
+
39
+ - **Performance-aware**
40
+ - Optimized data handling when DataLab is attached
41
+ - No unnecessary serialization for large datasets
42
+
43
+ - **Decoupled architecture**
44
+ - Installable independently of DataLab
45
+ - DataLab is a privileged host, not a requirement
46
+
47
+ ---
48
+
49
+ ## Typical Usage
50
+
51
+ ```python
52
+ img = workspace.get("i042")
53
+ filtered = sigima.proc.image.butterworth(img, cut_off=0.2)
54
+ workspace.add("filtered_i042", filtered)
55
+ plotter.plot("filtered_i042")
56
+ ```
57
+
58
+ Depending on the execution context:
59
+
60
+ - the result appears inline in the notebook,
61
+ - and, if DataLab is running, it also appears automatically in the DataLab GUI,
62
+ with views and metadata kept in sync.
63
+
64
+ ---
65
+
66
+ ## Execution Modes
67
+
68
+ ### Live Mode (DataLab-attached)
69
+
70
+ - DataLab launches a Jupyter server and starts `kernel-datalab`.
71
+ - The kernel detects DataLab at runtime.
72
+ - Workspace operations and visualizations are synchronized with the GUI.
73
+
74
+ Two connection methods are supported:
75
+
76
+ - **Web API** (recommended): HTTP/JSON connection using `DATALAB_WORKSPACE_URL` and `DATALAB_WORKSPACE_TOKEN` environment variables
77
+ - **XML-RPC** (legacy): Automatic connection when DataLab is running with remote control enabled
78
+
79
+ ### Standalone Mode (Notebook-only)
80
+
81
+ - The kernel is used like any standard Jupyter kernel.
82
+ - No DataLab installation or GUI is required.
83
+ - Data are managed locally and persisted to `.h5` files.
84
+
85
+ **The same notebook runs unchanged in both modes.**
86
+
87
+ ---
88
+
89
+ ## Installation
90
+
91
+ ### Standalone usage
92
+
93
+ ```bash
94
+ pip install datalab-kernel sigima
95
+ jupyter lab
96
+ ```
97
+
98
+ Then select **DataLab Kernel** from the kernel list.
99
+
100
+ ### With DataLab
101
+
102
+ When installed alongside DataLab, the kernel is automatically available and can be launched directly from the DataLab interface.
103
+
104
+ ---
105
+
106
+ ## Persistence and Sharing
107
+
108
+ Workspace state can be saved and reloaded:
109
+
110
+ ```python
111
+ workspace.save("analysis.h5")
112
+ workspace.load("analysis.h5")
113
+ ```
114
+
115
+ This enables:
116
+
117
+ - sharing notebooks and data with collaborators,
118
+ - replaying analyses without DataLab,
119
+ - resuming workflows inside DataLab by reopening the associated project.
120
+
121
+ ---
122
+
123
+ ## Documentation
124
+
125
+ - **User contract and behavior**: see `plans/specification.md`
126
+ - **Vision and architectural principles**: see `plans/architecture.md`
127
+
128
+ ---
129
+
130
+ ## Project Status
131
+
132
+ DataLab-Kernel is under active design and development.
133
+
134
+ ---
135
+
136
+ ## License
137
+
138
+ This project is released under an open-source license (see `LICENSE` file).
@@ -0,0 +1,45 @@
1
+ # Copyright (c) DataLab Platform Developers, BSD 3-Clause License
2
+ # See LICENSE file for details
3
+
4
+ """
5
+ DataLab Jupyter Kernel
6
+ ======================
7
+
8
+ A standalone Jupyter kernel providing seamless, reproducible access to DataLab
9
+ workspaces, with optional live synchronization to the DataLab GUI.
10
+
11
+ Main components:
12
+ - `workspace`: Data access and persistence API
13
+ - `plotter`: Visualization frontend
14
+ - `sigima`: Scientific processing library (re-exported)
15
+
16
+ Example usage::
17
+
18
+ # In a Jupyter notebook with datalab-kernel
19
+ img = workspace.get("i042")
20
+ filtered = sigima.proc.image.butterworth(img, cut_off=0.2)
21
+ workspace.add("filtered_i042", filtered)
22
+ plotter.plot("filtered_i042")
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ __version__ = "0.1.0"
28
+ __author__ = "DataLab Platform Developers"
29
+
30
+ from datalab_kernel.plotter import Plotter
31
+ from datalab_kernel.workspace import Workspace
32
+
33
+ # Global instances (initialized when kernel starts)
34
+ # pylint: disable=invalid-name
35
+ workspace: Workspace | None = None
36
+ plotter: Plotter | None = None
37
+ # pylint: enable=invalid-name
38
+
39
+ __all__ = [
40
+ "__version__",
41
+ "Workspace",
42
+ "Plotter",
43
+ "workspace",
44
+ "plotter",
45
+ ]
@@ -0,0 +1,38 @@
1
+ # Copyright (c) DataLab Platform Developers, BSD 3-Clause License
2
+ # See LICENSE file for details
3
+
4
+ """
5
+ DataLab Kernel main module.
6
+
7
+ Supports running as:
8
+ python -m datalab_kernel install
9
+ python -m datalab_kernel uninstall
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import sys
15
+
16
+ from datalab_kernel.install import main as install_main
17
+
18
+
19
+ def main() -> None:
20
+ """Main entry point for the datalab_kernel module."""
21
+ if len(sys.argv) > 1 and sys.argv[1] in ("install", "uninstall"):
22
+ # Handle install/uninstall commands
23
+ install_main()
24
+ else:
25
+ # Launch kernel (default behavior when run by Jupyter)
26
+ # Delayed import: only needed when launching as kernel
27
+ from ipykernel.kernelapp import ( # pylint: disable=import-outside-toplevel
28
+ IPKernelApp,
29
+ )
30
+
31
+ # pylint: disable-next=import-outside-toplevel
32
+ from datalab_kernel.kernel import DataLabKernel
33
+
34
+ IPKernelApp.launch_instance(kernel_class=DataLabKernel)
35
+
36
+
37
+ if __name__ == "__main__":
38
+ main()
@@ -0,0 +1,33 @@
1
+ # Copyright (c) DataLab Platform Developers, BSD 3-Clause License
2
+ # See LICENSE file for details
3
+
4
+ """
5
+ Workspace Backends
6
+ ==================
7
+
8
+ Backend implementations for the DataLab Kernel workspace.
9
+
10
+ Available backends:
11
+
12
+ - :class:`StandaloneBackend`: Local memory storage with HDF5 persistence
13
+ - :class:`WebApiBackend`: HTTP/JSON + NPZ synchronization with DataLab
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ __all__ = [
19
+ "StandaloneBackend",
20
+ "WebApiBackend",
21
+ "WorkspaceBackend",
22
+ ]
23
+
24
+ # Re-export base class from workspace module for convenience
25
+ # Import backends
26
+ from datalab_kernel.backends.standalone import StandaloneBackend
27
+ from datalab_kernel.workspace import WorkspaceBackend
28
+
29
+ try:
30
+ from datalab_kernel.backends.webapi import WebApiBackend
31
+ except ImportError:
32
+ # httpx not installed, WebApiBackend not available
33
+ WebApiBackend = None # type: ignore