fps_notebook 0.9.5__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_notebook-0.9.5/COPYING.md +59 -0
- fps_notebook-0.9.5/PKG-INFO +29 -0
- fps_notebook-0.9.5/README.md +3 -0
- fps_notebook-0.9.5/pyproject.toml +44 -0
- fps_notebook-0.9.5/src/fps_notebook/__init__.py +6 -0
- fps_notebook-0.9.5/src/fps_notebook/main.py +24 -0
- fps_notebook-0.9.5/src/fps_notebook/py.typed +0 -0
- fps_notebook-0.9.5/src/fps_notebook/routes.py +207 -0
|
@@ -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.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fps_notebook
|
|
3
|
+
Version: 0.9.5
|
|
4
|
+
Summary: An FPS plugin for the 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: notebook-frontend>=7.4.2,<8.0.0
|
|
22
|
+
Requires-Dist: jupyverse-api>=0.12.0,<0.13.0
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Project-URL: Homepage, https://jupyter.org
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# fps-notebook
|
|
28
|
+
|
|
29
|
+
An FPS plugin for the Notebook API.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fps_notebook"
|
|
7
|
+
version = "0.9.5"
|
|
8
|
+
description = "An FPS plugin for the 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
|
+
"notebook-frontend >=7.4.2,<8.0.0",
|
|
26
|
+
"jupyverse-api >=0.12.0,<0.13.0",
|
|
27
|
+
]
|
|
28
|
+
license = "BSD-3-Clause"
|
|
29
|
+
license-files = ["COPYING.md"]
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Jupyter Development Team"
|
|
33
|
+
email = "jupyter@googlegroups.com"
|
|
34
|
+
|
|
35
|
+
[project.readme]
|
|
36
|
+
file = "README.md"
|
|
37
|
+
content-type = "text/markdown"
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://jupyter.org"
|
|
41
|
+
|
|
42
|
+
[project.entry-points]
|
|
43
|
+
"fps.modules" = {notebook = "fps_notebook.main:NotebookModule"}
|
|
44
|
+
"jupyverse.modules" = {notebook = "fps_notebook.main:NotebookModule"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import structlog
|
|
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
|
+
from jupyverse_api.notebook import Notebook
|
|
9
|
+
|
|
10
|
+
from .routes import _Notebook
|
|
11
|
+
|
|
12
|
+
logger = structlog.get_logger()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class NotebookModule(Module):
|
|
16
|
+
async def prepare(self) -> None:
|
|
17
|
+
self.put(None, JupyterLabConfig)
|
|
18
|
+
app = await self.get(App)
|
|
19
|
+
auth = await self.get(Auth) # type: ignore[type-abstract]
|
|
20
|
+
frontend_config = await self.get(FrontendConfig)
|
|
21
|
+
lab = await self.get(Lab) # type: ignore[type-abstract]
|
|
22
|
+
|
|
23
|
+
notebook = _Notebook(app, auth, frontend_config, lab)
|
|
24
|
+
self.put(notebook, Notebook)
|
|
File without changes
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import notebook_frontend
|
|
5
|
+
from fastapi.staticfiles import StaticFiles
|
|
6
|
+
from jupyverse_api.app import App
|
|
7
|
+
from jupyverse_api.auth import Auth, User
|
|
8
|
+
from jupyverse_api.frontend import FrontendConfig
|
|
9
|
+
from jupyverse_api.lab import Lab
|
|
10
|
+
from jupyverse_api.notebook import Notebook
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class _Notebook(Notebook):
|
|
14
|
+
def __init__(self, app: App, auth: Auth, frontend_config: FrontendConfig, lab: Lab) -> None:
|
|
15
|
+
super().__init__(app, auth, lab)
|
|
16
|
+
self.frontend_config = frontend_config
|
|
17
|
+
self.lab = lab
|
|
18
|
+
lab.redirect_after_root = "tree"
|
|
19
|
+
|
|
20
|
+
extensions_dir = lab.prefix_dir / "share" / "jupyter" / "labextensions"
|
|
21
|
+
self.federated_extensions, self.disabled_extensions = lab.get_federated_extensions(
|
|
22
|
+
extensions_dir
|
|
23
|
+
)
|
|
24
|
+
self.notebook_dir = Path(notebook_frontend.__file__).parent
|
|
25
|
+
|
|
26
|
+
self.mount(
|
|
27
|
+
"/static/notebook",
|
|
28
|
+
StaticFiles(directory=self.notebook_dir / "static"),
|
|
29
|
+
name="static",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
async def get_tree(
|
|
33
|
+
self,
|
|
34
|
+
user: User,
|
|
35
|
+
):
|
|
36
|
+
return get_index(
|
|
37
|
+
self.lab,
|
|
38
|
+
self.notebook_dir,
|
|
39
|
+
self.federated_extensions,
|
|
40
|
+
self.disabled_extensions,
|
|
41
|
+
"Tree",
|
|
42
|
+
"tree",
|
|
43
|
+
self.frontend_config.collaborative,
|
|
44
|
+
self.frontend_config.base_url,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
async def get_notebook(
|
|
48
|
+
self,
|
|
49
|
+
path,
|
|
50
|
+
user: User,
|
|
51
|
+
):
|
|
52
|
+
return get_index(
|
|
53
|
+
self.lab,
|
|
54
|
+
self.notebook_dir,
|
|
55
|
+
self.federated_extensions,
|
|
56
|
+
self.disabled_extensions,
|
|
57
|
+
path,
|
|
58
|
+
"notebooks",
|
|
59
|
+
self.frontend_config.collaborative,
|
|
60
|
+
self.frontend_config.base_url,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
async def edit_file(
|
|
64
|
+
self,
|
|
65
|
+
path,
|
|
66
|
+
user: User,
|
|
67
|
+
):
|
|
68
|
+
return get_index(
|
|
69
|
+
self.lab,
|
|
70
|
+
self.notebook_dir,
|
|
71
|
+
self.federated_extensions,
|
|
72
|
+
self.disabled_extensions,
|
|
73
|
+
path,
|
|
74
|
+
"edit",
|
|
75
|
+
self.frontend_config.collaborative,
|
|
76
|
+
self.frontend_config.base_url,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
async def get_console(
|
|
80
|
+
self,
|
|
81
|
+
path,
|
|
82
|
+
user: User,
|
|
83
|
+
):
|
|
84
|
+
return get_index(
|
|
85
|
+
self.lab,
|
|
86
|
+
self.notebook_dir,
|
|
87
|
+
self.federated_extensions,
|
|
88
|
+
self.disabled_extensions,
|
|
89
|
+
path,
|
|
90
|
+
"consoles",
|
|
91
|
+
self.frontend_config.collaborative,
|
|
92
|
+
self.frontend_config.base_url,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
async def get_terminal(
|
|
96
|
+
self,
|
|
97
|
+
name: str,
|
|
98
|
+
user: User,
|
|
99
|
+
):
|
|
100
|
+
return get_index(
|
|
101
|
+
self.lab,
|
|
102
|
+
self.notebook_dir,
|
|
103
|
+
self.federated_extensions,
|
|
104
|
+
self.disabled_extensions,
|
|
105
|
+
name,
|
|
106
|
+
"terminals",
|
|
107
|
+
self.frontend_config.collaborative,
|
|
108
|
+
self.frontend_config.base_url,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
INDEX_HTML = """\
|
|
113
|
+
<!doctype html>
|
|
114
|
+
<html>
|
|
115
|
+
<head>
|
|
116
|
+
<meta charset="utf-8"/>
|
|
117
|
+
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
|
118
|
+
<title>Home</title>
|
|
119
|
+
<link rel="icon" type="image/x-icon" href="/static/favicons/favicon.ico" class="favicon"/>
|
|
120
|
+
<link rel="stylesheet" href="/custom/custom.css"/>
|
|
121
|
+
<script defer="defer" src="FULL_STATIC_URL/main.MAIN_ID.js?v=MAIN_ID"></script>
|
|
122
|
+
</head>
|
|
123
|
+
<body class="jp-ThemedContainer">
|
|
124
|
+
<script id="jupyter-config-data" type="application/json">
|
|
125
|
+
PAGE_CONFIG
|
|
126
|
+
</script>
|
|
127
|
+
<script>
|
|
128
|
+
/* Remove token from URL. */
|
|
129
|
+
(function() {
|
|
130
|
+
var parsedUrl = new URL(window.location.href);
|
|
131
|
+
if (parsedUrl.searchParams.get('token')) {
|
|
132
|
+
parsedUrl.searchParams.delete('token');
|
|
133
|
+
window.history.replaceState({}, '', parsedUrl.href);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
)();
|
|
137
|
+
</script>
|
|
138
|
+
</body>
|
|
139
|
+
</html>
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def get_index(
|
|
144
|
+
lab,
|
|
145
|
+
notebook_dir,
|
|
146
|
+
federated_extensions,
|
|
147
|
+
disabled_extensions,
|
|
148
|
+
doc_name,
|
|
149
|
+
notebook_page,
|
|
150
|
+
collaborative,
|
|
151
|
+
base_url="/",
|
|
152
|
+
):
|
|
153
|
+
full_static_url = f"{base_url}static/notebook"
|
|
154
|
+
for path in (notebook_dir / "static").glob("main.*.js"):
|
|
155
|
+
main_id = path.name.split(".")[1]
|
|
156
|
+
break
|
|
157
|
+
page_config = {
|
|
158
|
+
"appName": "Notebook",
|
|
159
|
+
"appNamespace": "notebook",
|
|
160
|
+
"appSettingsDir": (lab.prefix_dir / "share" / "jupyter" / "lab" / "settings").as_posix(),
|
|
161
|
+
"appUrl": "/lab",
|
|
162
|
+
"appVersion": notebook_frontend.__version__,
|
|
163
|
+
"baseUrl": base_url,
|
|
164
|
+
"cacheFiles": True,
|
|
165
|
+
"collaborative": collaborative,
|
|
166
|
+
"disabledExtensions": disabled_extensions,
|
|
167
|
+
"extraLabextensionsPath": [],
|
|
168
|
+
"federated_extensions": federated_extensions,
|
|
169
|
+
"frontendUrl": "/notebook/",
|
|
170
|
+
"fullAppUrl": f"{base_url}lab",
|
|
171
|
+
"fullLabextensionsUrl": f"{base_url}lab/extensions",
|
|
172
|
+
"fullLicensesUrl": f"{base_url}lab/api/licenses",
|
|
173
|
+
"fullListingsUrl": f"{base_url}lab/api/listings",
|
|
174
|
+
"fullMathjaxUrl": f"{base_url}static/notebook/components/MathJax/MathJax.js",
|
|
175
|
+
"fullSettingsUrl": f"{base_url}lab/api/settings",
|
|
176
|
+
"fullStaticUrl": f"{base_url}static/notebook",
|
|
177
|
+
"fullThemesUrl": f"{base_url}lab/api/themes",
|
|
178
|
+
"fullTranslationsApiUrl": f"{base_url}lab/api/translations",
|
|
179
|
+
"fullTreeUrl": f"{base_url}lab/tree",
|
|
180
|
+
"fullWorkspacesApiUrl": f"{base_url}lab/api/workspaces",
|
|
181
|
+
"labextensionsPath": [(lab.prefix_dir / "share" / "jupyter" / "labextensions").as_posix()],
|
|
182
|
+
"labextensionsUrl": "/lab/extensions",
|
|
183
|
+
"licensesUrl": "/lab/api/licenses",
|
|
184
|
+
"listingsUrl": "/lab/api/listings",
|
|
185
|
+
"mathjaxConfig": "TeX-AMS-MML_HTMLorMML-full,Safe",
|
|
186
|
+
"notebookLogo": False,
|
|
187
|
+
"notebookPage": notebook_page,
|
|
188
|
+
"schemasDir": (lab.prefix_dir / "share" / "jupyter" / "lab" / "schemas").as_posix(),
|
|
189
|
+
"settingsUrl": "/lab/api/settings",
|
|
190
|
+
"staticDir": (notebook_dir / "static").as_posix(),
|
|
191
|
+
"templatesDir": (notebook_dir / "templates").as_posix(),
|
|
192
|
+
"terminalsAvailable": True,
|
|
193
|
+
"themesDir": (lab.prefix_dir / "share" / "jupyter" / "lab" / "themes").as_posix(),
|
|
194
|
+
"themesUrl": "/lab/api/themes",
|
|
195
|
+
"translationsApiUrl": "/lab/api/translations",
|
|
196
|
+
"treeUrl": "/lab/tree",
|
|
197
|
+
"workspacesApiUrl": "/lab/api/workspaces",
|
|
198
|
+
"wsUrl": "",
|
|
199
|
+
}
|
|
200
|
+
index = (
|
|
201
|
+
INDEX_HTML.replace("PAGE_CONFIG", json.dumps(page_config))
|
|
202
|
+
.replace("MAIN_ID", main_id)
|
|
203
|
+
.replace("DOC_NAME", doc_name)
|
|
204
|
+
.replace("BASE_URL", base_url)
|
|
205
|
+
.replace("FULL_STATIC_URL", full_static_url)
|
|
206
|
+
)
|
|
207
|
+
return index
|