fps_lab 0.9.7__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.
- fps_lab-0.9.7/COPYING.md +59 -0
- fps_lab-0.9.7/PKG-INFO +30 -0
- fps_lab-0.9.7/README.md +3 -0
- fps_lab-0.9.7/pyproject.toml +45 -0
- fps_lab-0.9.7/src/fps_lab/__init__.py +6 -0
- fps_lab-0.9.7/src/fps_lab/main.py +25 -0
- fps_lab-0.9.7/src/fps_lab/py.typed +0 -0
- fps_lab-0.9.7/src/fps_lab/routes.py +222 -0
- fps_lab-0.9.7/src/fps_lab/static/favicon.ico +0 -0
fps_lab-0.9.7/COPYING.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Licensing terms
|
|
2
|
+
|
|
3
|
+
This project is licensed under the terms of the Modified BSD License
|
|
4
|
+
(also known as New or Revised or 3-Clause BSD), as follows:
|
|
5
|
+
|
|
6
|
+
- Copyright (c) 2021-, Jupyter Development Team
|
|
7
|
+
|
|
8
|
+
All rights reserved.
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without
|
|
11
|
+
modification, are permitted provided that the following conditions are met:
|
|
12
|
+
|
|
13
|
+
Redistributions of source code must retain the above copyright notice, this
|
|
14
|
+
list of conditions and the following disclaimer.
|
|
15
|
+
|
|
16
|
+
Redistributions in binary form must reproduce the above copyright notice, this
|
|
17
|
+
list of conditions and the following disclaimer in the documentation and/or
|
|
18
|
+
other materials provided with the distribution.
|
|
19
|
+
|
|
20
|
+
Neither the name of the Jupyter Development Team nor the names of its
|
|
21
|
+
contributors may be used to endorse or promote products derived from this
|
|
22
|
+
software without specific prior written permission.
|
|
23
|
+
|
|
24
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
25
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
26
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
27
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
28
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
29
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
30
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
31
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
32
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34
|
+
|
|
35
|
+
## About the Jupyter Development Team
|
|
36
|
+
|
|
37
|
+
The Jupyter Development Team is the set of all contributors to the Jupyter project.
|
|
38
|
+
This includes all of the Jupyter subprojects.
|
|
39
|
+
|
|
40
|
+
The core team that coordinates development on GitHub can be found here:
|
|
41
|
+
https://github.com/jupyter/.
|
|
42
|
+
|
|
43
|
+
## Our Copyright Policy
|
|
44
|
+
|
|
45
|
+
Jupyter uses a shared copyright model. Each contributor maintains copyright
|
|
46
|
+
over their contributions to Jupyter. But, it is important to note that these
|
|
47
|
+
contributions are typically only changes to the repositories. Thus, the Jupyter
|
|
48
|
+
source code, in its entirety is not the copyright of any single person or
|
|
49
|
+
institution. Instead, it is the collective copyright of the entire Jupyter
|
|
50
|
+
Development Team. If individual contributors want to maintain a record of what
|
|
51
|
+
changes/contributions they have specific copyright on, they should indicate
|
|
52
|
+
their copyright in the commit message of the change, when they commit the
|
|
53
|
+
change to one of the Jupyter repositories.
|
|
54
|
+
|
|
55
|
+
With this in mind, the following banner should be used in any source code file
|
|
56
|
+
to indicate the copyright and license terms:
|
|
57
|
+
|
|
58
|
+
# Copyright (c) Jupyter Development Team.
|
|
59
|
+
# Distributed under the terms of the Modified BSD License.
|
fps_lab-0.9.7/PKG-INFO
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fps_lab
|
|
3
|
+
Version: 0.9.7
|
|
4
|
+
Summary: An FPS plugin for the JupyterLab/Notebook API
|
|
5
|
+
Keywords: jupyter,server,fastapi,plugins
|
|
6
|
+
Author: Jupyter Development Team
|
|
7
|
+
Author-email: Jupyter Development Team <jupyter@googlegroups.com>
|
|
8
|
+
License-Expression: BSD-3-Clause
|
|
9
|
+
License-File: COPYING.md
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
21
|
+
Requires-Dist: babel
|
|
22
|
+
Requires-Dist: json5
|
|
23
|
+
Requires-Dist: jupyverse-api>=0.12.2,<0.13.0
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Project-URL: Homepage, https://jupyter.org
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# fps-lab
|
|
29
|
+
|
|
30
|
+
An FPS plugin for the JupyterLab/Notebook API.
|
fps_lab-0.9.7/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fps_lab"
|
|
7
|
+
version = "0.9.7"
|
|
8
|
+
description = "An FPS plugin for the JupyterLab/Notebook API"
|
|
9
|
+
keywords = ["jupyter", "server", "fastapi", "plugins"]
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 5 - Production/Stable",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"License :: OSI Approved :: BSD License",
|
|
15
|
+
"Programming Language :: Python",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
22
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"babel",
|
|
26
|
+
"json5",
|
|
27
|
+
"jupyverse-api >=0.12.2,<0.13.0",
|
|
28
|
+
]
|
|
29
|
+
license = "BSD-3-Clause"
|
|
30
|
+
license-files = ["COPYING.md"]
|
|
31
|
+
|
|
32
|
+
[[project.authors]]
|
|
33
|
+
name = "Jupyter Development Team"
|
|
34
|
+
email = "jupyter@googlegroups.com"
|
|
35
|
+
|
|
36
|
+
[project.readme]
|
|
37
|
+
file = "README.md"
|
|
38
|
+
content-type = "text/markdown"
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://jupyter.org"
|
|
42
|
+
|
|
43
|
+
[project.entry-points]
|
|
44
|
+
"fps.modules" = {lab = "fps_lab.main:LabModule"}
|
|
45
|
+
"jupyverse.modules" = {lab = "fps_lab.main:LabModule"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from anyio import Event, create_task_group
|
|
2
|
+
from fps import Module
|
|
3
|
+
from jupyverse_api.app import App
|
|
4
|
+
from jupyverse_api.auth import Auth
|
|
5
|
+
from jupyverse_api.frontend import FrontendConfig
|
|
6
|
+
from jupyverse_api.jupyterlab import JupyterLabConfig
|
|
7
|
+
from jupyverse_api.lab import Lab
|
|
8
|
+
|
|
9
|
+
from .routes import _Lab
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class LabModule(Module):
|
|
13
|
+
async def prepare(self) -> None:
|
|
14
|
+
app = await self.get(App)
|
|
15
|
+
auth = await self.get(Auth) # type: ignore[type-abstract]
|
|
16
|
+
frontend_config = await self.get(FrontendConfig)
|
|
17
|
+
jupyterlab_config = await self.get(JupyterLabConfig)
|
|
18
|
+
|
|
19
|
+
async with create_task_group() as tg:
|
|
20
|
+
lab = _Lab(app, auth, frontend_config, jupyterlab_config, self.exit_app, tg)
|
|
21
|
+
self.put(lab, Lab)
|
|
22
|
+
self.done()
|
|
23
|
+
shutdown = Event()
|
|
24
|
+
self.add_teardown_callback(shutdown.set)
|
|
25
|
+
await shutdown.wait()
|
|
File without changes
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from glob import glob
|
|
5
|
+
from http import HTTPStatus
|
|
6
|
+
from importlib.metadata import entry_points
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import json5 # type: ignore
|
|
10
|
+
from anyio import sleep
|
|
11
|
+
from anyio.abc import TaskGroup
|
|
12
|
+
from babel import Locale
|
|
13
|
+
from fastapi import Response, status
|
|
14
|
+
from fastapi.responses import FileResponse, RedirectResponse
|
|
15
|
+
from jupyverse_api.app import App
|
|
16
|
+
from jupyverse_api.auth import Auth, User
|
|
17
|
+
from jupyverse_api.frontend import FrontendConfig
|
|
18
|
+
from jupyverse_api.jupyterlab import JupyterLabConfig
|
|
19
|
+
from jupyverse_api.lab import Lab
|
|
20
|
+
from starlette.requests import Request
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _Lab(Lab):
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
app: App,
|
|
27
|
+
auth: Auth,
|
|
28
|
+
frontend_config: FrontendConfig,
|
|
29
|
+
jupyterlab_config: JupyterLabConfig | None,
|
|
30
|
+
exit_app: Callable[[], None],
|
|
31
|
+
task_group: TaskGroup,
|
|
32
|
+
) -> None:
|
|
33
|
+
super().__init__(app, auth, jupyterlab_config)
|
|
34
|
+
|
|
35
|
+
self.frontend_config = frontend_config
|
|
36
|
+
self.locale = "en"
|
|
37
|
+
self._exit_app = exit_app
|
|
38
|
+
self._task_group = task_group
|
|
39
|
+
|
|
40
|
+
async def get_root(
|
|
41
|
+
self,
|
|
42
|
+
response: Response,
|
|
43
|
+
user: User,
|
|
44
|
+
):
|
|
45
|
+
# auto redirect
|
|
46
|
+
response.status_code = status.HTTP_302_FOUND
|
|
47
|
+
response.headers["Location"] = self.frontend_config.base_url + self.redirect_after_root
|
|
48
|
+
|
|
49
|
+
async def get_favicon(self):
|
|
50
|
+
return FileResponse(Path(__file__).parent / "static" / "favicon.ico")
|
|
51
|
+
|
|
52
|
+
async def get_mathjax(self, rest_of_path):
|
|
53
|
+
return RedirectResponse(
|
|
54
|
+
"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/" + rest_of_path
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
async def get_listings(self, user: User):
|
|
58
|
+
return {
|
|
59
|
+
"blocked_extensions_uris": [],
|
|
60
|
+
"allowed_extensions_uris": [],
|
|
61
|
+
"blocked_extensions": [],
|
|
62
|
+
"allowed_extensions": [],
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async def get_extensions(self, user: User):
|
|
66
|
+
return self.federated_extensions
|
|
67
|
+
|
|
68
|
+
async def get_translations_(
|
|
69
|
+
self,
|
|
70
|
+
user: User,
|
|
71
|
+
):
|
|
72
|
+
return RedirectResponse(f"{self.frontend_config.base_url}lab/api/translations")
|
|
73
|
+
|
|
74
|
+
async def get_translations(self, user: User):
|
|
75
|
+
locale = Locale.parse("en")
|
|
76
|
+
display_name = (locale.get_display_name(self.locale) or "").capitalize()
|
|
77
|
+
native_name = (locale.get_display_name() or "").capitalize()
|
|
78
|
+
data = {
|
|
79
|
+
"en": {
|
|
80
|
+
"displayName": display_name,
|
|
81
|
+
"nativeName": native_name,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
for ep in entry_points(group="jupyterlab.languagepack"):
|
|
85
|
+
locale = Locale.parse(ep.name)
|
|
86
|
+
data[ep.name] = {
|
|
87
|
+
"displayName": display_name,
|
|
88
|
+
"nativeName": native_name,
|
|
89
|
+
}
|
|
90
|
+
return {"data": data, "message": ""}
|
|
91
|
+
|
|
92
|
+
async def get_translation(
|
|
93
|
+
self,
|
|
94
|
+
language,
|
|
95
|
+
user: User,
|
|
96
|
+
):
|
|
97
|
+
if language == "en":
|
|
98
|
+
self.locale = language
|
|
99
|
+
return {}
|
|
100
|
+
|
|
101
|
+
for ep in entry_points(group="jupyterlab.languagepack"):
|
|
102
|
+
if ep.name == language:
|
|
103
|
+
break
|
|
104
|
+
else:
|
|
105
|
+
return {"data": {}, "message": f"Language pack '{language}' not installed!"}
|
|
106
|
+
self.locale = language
|
|
107
|
+
package = ep.load()
|
|
108
|
+
data = {}
|
|
109
|
+
for path in (Path(package.__file__).parent / "locale" / language / "LC_MESSAGES").glob(
|
|
110
|
+
"*.json"
|
|
111
|
+
):
|
|
112
|
+
with open(path) as f:
|
|
113
|
+
data.update({path.stem: json.load(f)})
|
|
114
|
+
return {"data": data, "message": ""}
|
|
115
|
+
|
|
116
|
+
async def get_setting(
|
|
117
|
+
self,
|
|
118
|
+
name0,
|
|
119
|
+
name1,
|
|
120
|
+
name2,
|
|
121
|
+
user: User,
|
|
122
|
+
):
|
|
123
|
+
with open(self.jlab_dir / "static" / "package.json") as f:
|
|
124
|
+
package = json.load(f)
|
|
125
|
+
if name0 in ["@jupyterlab", "@notebook"]:
|
|
126
|
+
schemas_parent = self.jlab_dir
|
|
127
|
+
else:
|
|
128
|
+
schemas_parent = self.extensions_dir / name0 / name1
|
|
129
|
+
with open(schemas_parent / "schemas" / name0 / name1 / f"{name2}.json") as f:
|
|
130
|
+
schema = json.load(f)
|
|
131
|
+
key = f"{name1}:{name2}"
|
|
132
|
+
setting = {
|
|
133
|
+
"id": f"@jupyterlab/{key}",
|
|
134
|
+
"schema": schema,
|
|
135
|
+
"version": package["version"],
|
|
136
|
+
"raw": "{}",
|
|
137
|
+
"settings": {},
|
|
138
|
+
"last_modified": None,
|
|
139
|
+
"created": None,
|
|
140
|
+
}
|
|
141
|
+
if user:
|
|
142
|
+
user_settings = json.loads(user.settings)
|
|
143
|
+
if key in user_settings:
|
|
144
|
+
setting.update(user_settings[key])
|
|
145
|
+
setting["settings"] = json5.loads(user_settings[key]["raw"])
|
|
146
|
+
return setting
|
|
147
|
+
|
|
148
|
+
async def change_setting(
|
|
149
|
+
self,
|
|
150
|
+
request: Request,
|
|
151
|
+
name0,
|
|
152
|
+
name1,
|
|
153
|
+
user: User,
|
|
154
|
+
user_update,
|
|
155
|
+
):
|
|
156
|
+
settings = json.loads(user.settings)
|
|
157
|
+
settings[f"{name0}:{name1}"] = await request.json()
|
|
158
|
+
await user_update({"settings": json.dumps(settings)})
|
|
159
|
+
return Response(status_code=HTTPStatus.NO_CONTENT.value)
|
|
160
|
+
|
|
161
|
+
async def shutdown(self, user: User):
|
|
162
|
+
async def exit_app():
|
|
163
|
+
await sleep(0.1)
|
|
164
|
+
self._exit_app()
|
|
165
|
+
|
|
166
|
+
self._task_group.start_soon(exit_app)
|
|
167
|
+
|
|
168
|
+
async def get_settings(self, user: User):
|
|
169
|
+
if user:
|
|
170
|
+
user_settings = json.loads(user.settings)
|
|
171
|
+
else:
|
|
172
|
+
user_settings = {}
|
|
173
|
+
settings = []
|
|
174
|
+
schemas = [self.jlab_dir / "schemas"]
|
|
175
|
+
if self.labextensions_dir.is_dir():
|
|
176
|
+
for d1 in self.labextensions_dir.iterdir():
|
|
177
|
+
if (d1 / "schemas").exists():
|
|
178
|
+
schemas.append(d1 / "schemas")
|
|
179
|
+
for d2 in d1.iterdir():
|
|
180
|
+
if (d2 / "schemas").exists():
|
|
181
|
+
schemas.append(d2 / "schemas")
|
|
182
|
+
for s in schemas:
|
|
183
|
+
for d1 in s.iterdir():
|
|
184
|
+
for d2 in d1.iterdir():
|
|
185
|
+
package = json.loads((d2 / "package.json.orig").read_text())
|
|
186
|
+
for path in [p for p in d2.iterdir() if p.suffix == ".json"]:
|
|
187
|
+
schema = json.loads(path.read_text())
|
|
188
|
+
key = f"{path.parent.name}:{path.stem}"
|
|
189
|
+
setting = {
|
|
190
|
+
"id": f"{d1.name}/{key}",
|
|
191
|
+
"schema": schema,
|
|
192
|
+
"version": package["version"],
|
|
193
|
+
"raw": "{}",
|
|
194
|
+
"settings": {},
|
|
195
|
+
"warning": None,
|
|
196
|
+
"last_modified": None,
|
|
197
|
+
"created": None,
|
|
198
|
+
}
|
|
199
|
+
if key in user_settings:
|
|
200
|
+
setting.update(user_settings[key])
|
|
201
|
+
setting["settings"] = json5.loads(user_settings[key]["raw"])
|
|
202
|
+
settings.append(setting)
|
|
203
|
+
return {"settings": settings}
|
|
204
|
+
|
|
205
|
+
def get_federated_extensions(self, extensions_dir: Path) -> tuple[list, list]:
|
|
206
|
+
federated_extensions = []
|
|
207
|
+
disabled_extensions = []
|
|
208
|
+
|
|
209
|
+
for path in glob(os.path.join(extensions_dir, "**", "package.json"), recursive=True):
|
|
210
|
+
with open(path) as f:
|
|
211
|
+
package = json.load(f)
|
|
212
|
+
if "jupyterlab" not in package:
|
|
213
|
+
continue
|
|
214
|
+
extension = package["jupyterlab"]["_build"]
|
|
215
|
+
extension["name"] = package["name"]
|
|
216
|
+
extension["description"] = package.get("description", "")
|
|
217
|
+
federated_extensions.append(extension)
|
|
218
|
+
|
|
219
|
+
for ext in package["jupyterlab"].get("disabledExtensions", []):
|
|
220
|
+
disabled_extensions.append(ext)
|
|
221
|
+
|
|
222
|
+
return federated_extensions, disabled_extensions
|
|
Binary file
|