Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align path format for windows. #243

Merged
merged 17 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/auth/fps_auth/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from uuid import uuid4

import pytest # type: ignore
from fps_auth.config import AuthConfig, get_auth_config

from .config import AuthConfig, get_auth_config


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion plugins/contents/fps_contents/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def read_content(path: Union[str, Path], get_content: bool, as_json: bool
return Content(
**{
"name": path.name,
"path": str(path),
"path": path.as_posix(),
"last_modified": get_file_modification_time(path),
"created": get_file_creation_time(path),
"content": content,
Expand Down
24 changes: 18 additions & 6 deletions plugins/jupyterlab/fps_jupyterlab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

router = APIRouter()
prefix_dir, federated_extensions = init_router(router, "lab")
jupyterlab_dir = Path(jupyterlab.__file__).parent.parent
jupyterlab_dir = Path(jupyterlab.__file__).parents[1]

config = get_jlab_config()
if config.dev_mode:
Expand All @@ -40,16 +40,28 @@ async def get_lab(
lab_config=Depends(get_lab_config),
):
return HTMLResponse(
get_index("default", lab_config.collaborative, config.dev_mode, frontend_config.base_url)
get_index(
"default",
lab_config.collaborative,
config.dev_mode,
frontend_config.base_url,
)
)


@router.get("/lab/tree/{path:path}")
async def load_workspace(
path, frontend_config=Depends(get_frontend_config), lab_config=Depends(get_lab_config)
path,
frontend_config=Depends(get_frontend_config),
lab_config=Depends(get_lab_config),
):
return HTMLResponse(
get_index("default", lab_config.collaborative, config.dev_mode, frontend_config.base_url)
get_index(
"default",
lab_config.collaborative,
config.dev_mode,
frontend_config.base_url,
)
)


Expand Down Expand Up @@ -164,9 +176,9 @@ def get_index(workspace, collaborative, dev_mode, base_url="/"):
"quitButton": True,
"settingsUrl": "/lab/api/settings",
"store_id": 0,
"schemasDir": str(prefix_dir / "share" / "jupyter" / "lab" / "schemas"),
"schemasDir": (prefix_dir / "share" / "jupyter" / "lab" / "schemas").as_posix(),
"terminalsAvailable": True,
"themesDir": str(prefix_dir / "share" / "jupyter" / "lab" / "themes"),
"themesDir": (prefix_dir / "share" / "jupyter" / "lab" / "themes").as_posix(),
"themesUrl": "/lab/api/themes",
"token": "4e2804532de366abc81e32ab0c6bf68a73716fafbdbb2098",
"translationsApiUrl": "/lab/api/translations",
Expand Down
2 changes: 1 addition & 1 deletion plugins/kernels/fps_kernels/kernel_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def connect(self, startup_timeout: float = float("inf")) -> None:
await self._wait_for_ready(startup_timeout)
self.listen_channels()

def connect_channels(self, connection_cfg: cfg_t = None):
def connect_channels(self, connection_cfg: Optional[cfg_t] = None):
connection_cfg = connection_cfg or self.connection_cfg
self.shell_channel = connect_channel("shell", connection_cfg)
self.control_channel = connect_channel("control", connection_cfg)
Expand Down
16 changes: 10 additions & 6 deletions plugins/kernels/fps_kernels/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ async def get_kernelspec(


@router.get("/api/kernels")
async def get_kernels(user: User = Depends(current_user(permissions={"kernels": ["read"]}))):
async def get_kernels(
user: User = Depends(current_user(permissions={"kernels": ["read"]})),
):
results = []
for kernel_id, kernel in kernels.items():
results.append(
Expand Down Expand Up @@ -102,7 +104,9 @@ async def rename_session(


@router.get("/api/sessions")
async def get_sessions(user: User = Depends(current_user(permissions={"sessions": ["read"]}))):
async def get_sessions(
user: User = Depends(current_user(permissions={"sessions": ["read"]})),
):
for session in sessions.values():
kernel_id = session["kernel"]["id"]
kernel_server = kernels[kernel_id]["server"]
Expand All @@ -123,9 +127,9 @@ async def create_session(
create_session = await request.json()
kernel_name = create_session["kernel"]["name"]
kernel_server = KernelServer(
kernelspec_path=str(
kernelspec_path=(
prefix_dir / "share" / "jupyter" / "kernels" / kernel_name / "kernel.json"
),
).as_posix(),
davidbrochart marked this conversation as resolved.
Show resolved Hide resolved
)
kernel_id = str(uuid.uuid4())
kernels[kernel_id] = {"name": kernel_name, "server": kernel_server, "driver": None}
Expand Down Expand Up @@ -181,9 +185,9 @@ async def execute_cell(
cell["outputs"] = []

kernel = kernels[kernel_id]
kernelspec_path = str(
kernelspec_path = (
prefix_dir / "share" / "jupyter" / "kernels" / kernel["name"] / "kernel.json"
)
).as_posix()
if not kernel["driver"]:
kernel["driver"] = driver = KernelDriver(
kernelspec_path=kernelspec_path,
Expand Down
2 changes: 1 addition & 1 deletion plugins/lab/fps_lab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

prefix_dir = Path(sys.prefix)
if jlab_dev_mode:
jlab_dir = Path(jupyterlab.__file__).parent.parent / "dev_mode"
jlab_dir = Path(jupyterlab.__file__).parents[1] / "dev_mode"
else:
jlab_dir = prefix_dir / "share" / "jupyter" / "lab"

Expand Down
5 changes: 3 additions & 2 deletions plugins/lab/fps_lab/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from glob import glob
from pathlib import Path
from typing import List, Tuple

Expand All @@ -8,9 +7,11 @@ def get_federated_extensions(extensions_dir: Path) -> Tuple[List, List]:
federated_extensions = []
disabledExtensions = []

for path in glob(str(extensions_dir / "**" / "package.json"), recursive=True):
for path in extensions_dir.rglob("**/package.json"):
with open(path) as f:
package = json.load(f)
if "jupyterlab" not in package:
continue
name = package["name"]
extension = package["jupyterlab"]["_build"]
extension["name"] = name
Expand Down
12 changes: 6 additions & 6 deletions plugins/retrolab/fps_retrolab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_index(doc_name, retro_page, collaborative, base_url="/"):
page_config = {
"appName": "RetroLab",
"appNamespace": "retro",
"appSettingsDir": str(prefix_dir / "share" / "jupyter" / "lab" / "settings"),
"appSettingsDir": (prefix_dir / "share" / "jupyter" / "lab" / "settings").as_posix(),
"appUrl": "/lab",
"appVersion": retrolab.__version__,
"baseUrl": base_url,
Expand All @@ -117,19 +117,19 @@ def get_index(doc_name, retro_page, collaborative, base_url="/"):
"fullTranslationsApiUrl": f"{base_url}lab/api/translations",
"fullTreeUrl": f"{base_url}lab/tree",
"fullWorkspacesApiUrl": f"{base_url}lab/api/workspaces",
"labextensionsPath": [str(prefix_dir / "share" / "jupyter" / "labextensions")],
"labextensionsPath": [(prefix_dir / "share" / "jupyter" / "labextensions").as_posix()],
"labextensionsUrl": "/lab/extensions",
"licensesUrl": "/lab/api/licenses",
"listingsUrl": "/lab/api/listings",
"mathjaxConfig": "TeX-AMS-MML_HTMLorMML-full,Safe",
"retroLogo": False,
"retroPage": retro_page,
"schemasDir": str(prefix_dir / "share" / "jupyter" / "lab" / "schemas"),
"schemasDir": (prefix_dir / "share" / "jupyter" / "lab" / "schemas").as_posix(),
"settingsUrl": "/lab/api/settings",
"staticDir": str(retrolab_dir / "static"),
"templatesDir": str(retrolab_dir / "templates"),
"staticDir": (retrolab_dir / "static").as_posix(),
"templatesDir": (retrolab_dir / "templates").as_posix(),
"terminalsAvailable": True,
"themesDir": str(prefix_dir / "share" / "jupyter" / "lab" / "themes"),
"themesDir": (prefix_dir / "share" / "jupyter" / "lab" / "themes").as_posix(),
"themesUrl": "/lab/api/themes",
"translationsApiUrl": "/lab/api/translations",
"treeUrl": "/lab/tree",
Expand Down
2 changes: 1 addition & 1 deletion plugins/yjs/fps_yjs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_room(self, path: str) -> YRoom:
# it is a stored document (e.g. a notebook)
file_format, file_type, file_path = path.split(":", 2)
p = Path(file_path)
updates_file_path = str(p.parent / f".{file_type}:{p.name}.y")
updates_file_path = (p.parent / f".{file_type}:{p.name}.y").as_posix()
ystore = JupyterSQLiteYStore(path=updates_file_path) # FIXME: pass in config
self.rooms[path] = DocumentRoom(file_type, ystore)
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@pytest.fixture()
def cwd():
return Path(__file__).parent.parent
return Path(__file__).parents[1]


def get_open_port():
Expand Down
6 changes: 3 additions & 3 deletions tests/test_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_tree(client, tmp_path):
size=size,
mimetype="text/plain",
name=fname,
path=str(dname / fname),
path=(dname / fname).as_posix(),
format=None,
)
)
Expand All @@ -38,7 +38,7 @@ def test_tree(client, tmp_path):
size=None,
mimetype=None,
name=sub_dname,
path=str(dname / sub_dname),
path=(dname / sub_dname).as_posix(),
format="json",
)
)
Expand All @@ -48,7 +48,7 @@ def test_tree(client, tmp_path):
size=None,
mimetype=None,
name="",
path=str(dname),
path=dname.as_posix(),
format="json",
)
response = client.get("/api/contents", params={"content": 1})
Expand Down