Skip to content

Commit ea88867

Browse files
committed
squashme: use PurePosixPath for workdir and mount
1 parent 7000553 commit ea88867

7 files changed

Lines changed: 26 additions & 24 deletions

File tree

bases/renku_data_services/data_api/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def register_all_handlers(app: Sanic, config: Config) -> Sanic:
150150
nb_config=config.nb_config,
151151
project_repo=config.project_repo,
152152
session_repo=config.session_repo,
153+
storage_repo=config.storage_v2_repo,
153154
rp_repo=config.rp_repo,
154155
internal_gitlab_authenticator=config.gitlab_authenticator,
155156
)

components/renku_data_services/notebooks/api/amalthea_patches/git_sidecar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def main(server: "UserServer") -> list[dict[str, Any]]:
2222
commit_sha = getattr(server, "commit_sha", None)
2323

2424
volume_mount = {
25-
"mountPath": server.work_dir.absolute().as_posix(),
25+
"mountPath": server.work_dir.as_posix(),
2626
"name": "workspace",
2727
}
2828
if gl_project_path:
@@ -51,7 +51,7 @@ async def main(server: "UserServer") -> list[dict[str, Any]]:
5151
"env": [
5252
{
5353
"name": "GIT_RPC_MOUNT_PATH",
54-
"value": server.work_dir.absolute().as_posix(),
54+
"value": server.work_dir.as_posix(),
5555
},
5656
{
5757
"name": "GIT_RPC_PORT",

components/renku_data_services/notebooks/api/amalthea_patches/init_containers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ async def git_clone_container_v2(server: "UserServer") -> dict[str, Any] | None:
3535
env = [
3636
{
3737
"name": f"{prefix}WORKSPACE_MOUNT_PATH",
38-
"value": server.workspace_mount_path.absolute().as_posix(),
38+
"value": server.workspace_mount_path.as_posix(),
3939
},
4040
{
4141
"name": f"{prefix}MOUNT_PATH",
42-
"value": server.work_dir.absolute().as_posix(),
42+
"value": server.work_dir.as_posix(),
4343
},
4444
{
4545
"name": f"{prefix}LFS_AUTO_FETCH",
@@ -145,7 +145,7 @@ async def git_clone_container_v2(server: "UserServer") -> dict[str, Any] | None:
145145
},
146146
"volumeMounts": [
147147
{
148-
"mountPath": server.workspace_mount_path.absolute().as_posix(),
148+
"mountPath": server.workspace_mount_path.as_posix(),
149149
"name": amalthea_session_work_volume,
150150
},
151151
*etc_cert_volume_mount,
@@ -172,11 +172,11 @@ async def git_clone_container(server: "UserServer") -> dict[str, Any] | None:
172172
env = [
173173
{
174174
"name": f"{prefix}WORKSPACE_MOUNT_PATH",
175-
"value": server.workspace_mount_path.absolute().as_posix(),
175+
"value": server.workspace_mount_path.as_posix(),
176176
},
177177
{
178178
"name": f"{prefix}MOUNT_PATH",
179-
"value": server.work_dir.absolute().as_posix(),
179+
"value": server.work_dir.as_posix(),
180180
},
181181
{
182182
"name": f"{prefix}LFS_AUTO_FETCH",
@@ -282,7 +282,7 @@ async def git_clone_container(server: "UserServer") -> dict[str, Any] | None:
282282
},
283283
"volumeMounts": [
284284
{
285-
"mountPath": server.workspace_mount_path.absolute().as_posix(),
285+
"mountPath": server.workspace_mount_path.as_posix(),
286286
"name": "workspace",
287287
},
288288
*etc_cert_volume_mount,

components/renku_data_services/notebooks/api/amalthea_patches/jupyter_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def env(server: "UserServer") -> list[dict[str, Any]]:
4343
"path": "/statefulset/spec/template/spec/containers/0/env/-",
4444
"value": {
4545
"name": "NOTEBOOK_DIR",
46-
"value": server.work_dir.absolute().as_posix(),
46+
"value": server.work_dir.as_posix(),
4747
},
4848
},
4949
{
@@ -53,7 +53,7 @@ def env(server: "UserServer") -> list[dict[str, Any]]:
5353
# relative to $HOME.
5454
"value": {
5555
"name": "MOUNT_PATH",
56-
"value": server.work_dir.absolute().as_posix(),
56+
"value": server.work_dir.as_posix(),
5757
},
5858
},
5959
{
@@ -223,7 +223,7 @@ def rstudio_env_variables(server: "UserServer") -> list[dict[str, Any]]:
223223
"path": "/statefulset/spec/template/spec/containers/0/volumeMounts/-",
224224
"value": {
225225
"name": secret_name,
226-
"mountPath": mount_location.absolute().as_posix(),
226+
"mountPath": mount_location.as_posix(),
227227
"subPath": mount_location.name,
228228
"readOnly": True,
229229
},

components/renku_data_services/notebooks/api/classes/image.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import re
55
from dataclasses import dataclass, field
66
from enum import Enum
7-
from pathlib import Path
7+
from pathlib import PurePosixPath
88
from typing import Any, Optional, Self, cast
99

1010
import requests
@@ -101,7 +101,7 @@ def get_image_config(self, image: "Image") -> Optional[dict[str, Any]]:
101101
return None
102102
return cast(dict[str, Any], res.json())
103103

104-
def image_workdir(self, image: "Image") -> Optional[Path]:
104+
def image_workdir(self, image: "Image") -> Optional[PurePosixPath]:
105105
"""Query the docker API to get the workdir of an image."""
106106
config = self.get_image_config(image)
107107
if config is None:
@@ -112,7 +112,7 @@ def image_workdir(self, image: "Image") -> Optional[Path]:
112112
workdir = nested_config.get("WorkingDir", "/")
113113
if workdir == "":
114114
workdir = "/"
115-
return Path(workdir)
115+
return PurePosixPath(workdir)
116116

117117
def with_oauth2_token(self, oauth2_token: str) -> "ImageRepoDockerAPI":
118118
"""Return a docker API instance with the token as authentication."""

components/renku_data_services/notebooks/api/classes/server.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from abc import ABC
44
from collections.abc import Sequence
55
from itertools import chain
6-
from pathlib import Path
6+
from pathlib import PurePosixPath
77
from typing import Any
88
from urllib.parse import urljoin, urlparse
99

@@ -44,8 +44,8 @@ def __init__(
4444
user_secrets: K8sUserSecrets | None,
4545
cloudstorage: Sequence[ICloudStorageRequest],
4646
k8s_client: K8sClient,
47-
workspace_mount_path: Path,
48-
work_dir: Path,
47+
workspace_mount_path: PurePosixPath,
48+
work_dir: PurePosixPath,
4949
config: _NotebooksConfig,
5050
internal_gitlab_user: APIUser,
5151
using_default_image: bool = False,
@@ -204,7 +204,7 @@ async def _get_session_manifest(self) -> dict[str, Any]:
204204
"pvc": {
205205
"enabled": True,
206206
"storageClassName": self.config.sessions.storage.pvs_storage_class,
207-
"mountPath": self.workspace_mount_path.absolute().as_posix(),
207+
"mountPath": self.workspace_mount_path.as_posix(),
208208
},
209209
}
210210
else:
@@ -213,7 +213,7 @@ async def _get_session_manifest(self) -> dict[str, Any]:
213213
"size": storage_size,
214214
"pvc": {
215215
"enabled": False,
216-
"mountPath": self.workspace_mount_path.absolute().as_posix(),
216+
"mountPath": self.workspace_mount_path.as_posix(),
217217
},
218218
}
219219
# Authentication
@@ -256,7 +256,7 @@ async def _get_session_manifest(self) -> dict[str, Any]:
256256
"jupyterServer": {
257257
"defaultUrl": self.server_options.default_url,
258258
"image": self.image,
259-
"rootDir": self.work_dir.absolute().as_posix(),
259+
"rootDir": self.work_dir.as_posix(),
260260
"resources": self.server_options.to_k8s_resources(
261261
enforce_cpu_limits=self.config.sessions.enforce_cpu_limits
262262
),
@@ -375,8 +375,8 @@ def __init__(
375375
user_secrets: K8sUserSecrets | None,
376376
cloudstorage: Sequence[ICloudStorageRequest],
377377
k8s_client: K8sClient,
378-
workspace_mount_path: Path,
379-
work_dir: Path,
378+
workspace_mount_path: PurePosixPath,
379+
work_dir: PurePosixPath,
380380
config: _NotebooksConfig,
381381
gitlab_client: NotebooksGitlabClient,
382382
internal_gitlab_user: APIUser,
@@ -502,8 +502,8 @@ def __init__(
502502
user_secrets: K8sUserSecrets | None,
503503
cloudstorage: Sequence[ICloudStorageRequest],
504504
k8s_client: K8sClient,
505-
workspace_mount_path: Path,
506-
work_dir: Path,
505+
workspace_mount_path: PurePosixPath,
506+
work_dir: PurePosixPath,
507507
repositories: list[Repository],
508508
config: _NotebooksConfig,
509509
internal_gitlab_user: APIUser,

components/renku_data_services/notebooks/blueprints.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class NotebooksBP(CustomBlueprint):
9494
nb_config: _NotebooksConfig
9595
git_repo: GitRepositoriesRepository
9696
internal_gitlab_authenticator: base_models.Authenticator
97+
rp_repo: ResourcePoolRepository
9798

9899
def version(self) -> BlueprintFactoryResponse:
99100
"""Return notebook services version."""

0 commit comments

Comments
 (0)