Skip to content

Commit 908aca2

Browse files
committed
feat(sessions): add recommended images to info endpoint (#688)
1 parent d36b59b commit 908aca2

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

docs/openapi.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,17 @@
465465
"title": "Default workspace",
466466
"value": "/usr/share"
467467
},
468+
"interactive_session_recommended_jupyter_images": {
469+
"title": "Recommended Jupyter images for interactive sessions",
470+
"value": [
471+
"docker.io/jupyter/scipy-notebook:notebook-6.4.5",
472+
"docker.io/jupyter/scipy-notebook:notebook-9.4.5"
473+
]
474+
},
475+
"interactive_sessions_custom_image_allowed": {
476+
"title": "Whether users are allowed to spawn custom interactive session images",
477+
"value": "False"
478+
},
468479
"kubernetes_max_memory_limit": {
469480
"title": "Maximum allowed memory limit for Kubernetes jobs",
470481
"value": "10Gi"
@@ -617,6 +628,31 @@
617628
},
618629
"type": "object"
619630
},
631+
"interactive_session_recommended_jupyter_images": {
632+
"properties": {
633+
"title": {
634+
"type": "string"
635+
},
636+
"value": {
637+
"items": {
638+
"type": "string"
639+
},
640+
"type": "array"
641+
}
642+
},
643+
"type": "object"
644+
},
645+
"interactive_sessions_custom_image_allowed": {
646+
"properties": {
647+
"title": {
648+
"type": "string"
649+
},
650+
"value": {
651+
"type": "string"
652+
}
653+
},
654+
"type": "object"
655+
},
620656
"kubernetes_max_memory_limit": {
621657
"properties": {
622658
"title": {

reana_server/config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,21 @@ def _get_rate_limit(env_variable: str, default: str) -> str:
428428
)
429429
"""Maximum allowed period (in days) for interactive session inactivity before automatic closure."""
430430

431+
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS = json.loads(
432+
os.getenv("REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS", "{}")
433+
)
434+
"""Allowed and recommended environments to be used for interactive sessions."""
435+
436+
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS_CUSTOM_ALLOWED = (
437+
str(
438+
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS.get("jupyter", {}).get(
439+
"allow_custom", "false"
440+
)
441+
).lower()
442+
== "true"
443+
)
444+
"""Whether users can set custom interactive session images or not."""
445+
431446
# Kubernetes jobs timeout
432447
# ==================
433448
REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT = os.getenv("REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT")

reana_server/rest/info.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT,
2525
REANA_KUBERNETES_JOBS_MAX_USER_TIMEOUT_LIMIT,
2626
REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD,
27+
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS,
28+
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS_CUSTOM_ALLOWED,
2729
DASK_ENABLED,
2830
DASK_AUTOSCALER_ENABLED,
2931
REANA_DASK_CLUSTER_DEFAULT_NUMBER_OF_WORKERS,
@@ -108,6 +110,22 @@ def info(user, **kwargs): # noqa
108110
type: string
109111
x-nullable: true
110112
type: object
113+
interactive_session_recommended_jupyter_images:
114+
properties:
115+
title:
116+
type: string
117+
value:
118+
type: array
119+
items:
120+
type: string
121+
type: object
122+
interactive_sessions_custom_image_allowed:
123+
properties:
124+
title:
125+
type: string
126+
value:
127+
type: string
128+
type: object
111129
maximum_kubernetes_jobs_timeout:
112130
properties:
113131
title:
@@ -221,6 +239,17 @@ def info(user, **kwargs): # noqa
221239
"title": "Maximum timeout for Kubernetes jobs",
222240
"value": "1209600"
223241
},
242+
"interactive_session_recommended_jupyter_images": {
243+
"title": "Recommended Jupyter images for interactive sessions",
244+
"value": [
245+
'docker.io/jupyter/scipy-notebook:notebook-6.4.5',
246+
'docker.io/jupyter/scipy-notebook:notebook-9.4.5',
247+
]
248+
},
249+
"interactive_sessions_custom_image_allowed": {
250+
"title": "Whether users are allowed to spawn custom interactive session images",
251+
"value": "False"
252+
},
224253
"dask_enabled": {
225254
"title": "Dask workflows allowed in the cluster",
226255
"value": "False"
@@ -301,6 +330,19 @@ def info(user, **kwargs): # noqa
301330
title="Maximum inactivity period in days before automatic closure of interactive sessions",
302331
value=REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD,
303332
),
333+
interactive_sessions_custom_image_allowed=dict(
334+
title="Users can set custom interactive session images",
335+
value=REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS_CUSTOM_ALLOWED,
336+
),
337+
interactive_session_recommended_jupyter_images=dict(
338+
title="Recommended Jupyter images for interactive sessions",
339+
value=[
340+
item["image"]
341+
for item in REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS["jupyter"][
342+
"recommended"
343+
]
344+
],
345+
),
304346
dask_enabled=dict(
305347
title="Dask workflows allowed in the cluster",
306348
value=bool(DASK_ENABLED),
@@ -375,6 +417,8 @@ class InfoSchema(Schema):
375417
StringNullableInfoValue
376418
)
377419
kubernetes_max_memory_limit = fields.Nested(StringInfoValue)
420+
interactive_session_recommended_jupyter_images = fields.Nested(ListStringInfoValue)
421+
interactive_sessions_custom_image_allowed = fields.Nested(StringInfoValue)
378422
dask_enabled = fields.Nested(StringInfoValue)
379423
if DASK_ENABLED:
380424
dask_autoscaler_enabled = fields.Nested(StringInfoValue)

0 commit comments

Comments
 (0)