From 035c99d0dfd27ec01dbca195321744f33b229625 Mon Sep 17 00:00:00 2001 From: Alputer Date: Fri, 1 Nov 2024 14:21:36 +0100 Subject: [PATCH] feat(sessions): add recommended images to info endpoint (#688) --- docs/openapi.json | 21 +++++++++++++++++++++ reana_server/config.py | 5 +++++ reana_server/rest/info.py | 27 +++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/docs/openapi.json b/docs/openapi.json index 96ce8eae..2c986ea0 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -457,6 +457,13 @@ "title": "Default workspace", "value": "/usr/share" }, + "interactive_session_recommended_jupyter_images": { + "title": "Recommended jupyter images for interactive sessions", + "value": [ + "docker.io/jupyter/scipy-notebook:notebook-6.4.5", + "docker.io/jupyter/scipy-notebook:notebook-9.4.5" + ] + }, "kubernetes_max_memory_limit": { "title": "Maximum allowed memory limit for Kubernetes jobs", "value": "10Gi" @@ -587,6 +594,20 @@ }, "type": "object" }, + "interactive_session_recommended_jupyter_images": { + "properties": { + "title": { + "type": "string" + }, + "value": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + }, "kubernetes_max_memory_limit": { "properties": { "title": { diff --git a/reana_server/config.py b/reana_server/config.py index b2bbfa62..4ae14090 100644 --- a/reana_server/config.py +++ b/reana_server/config.py @@ -420,6 +420,11 @@ def _get_rate_limit(env_variable: str, default: str) -> str: ) """Maximum allowed period (in days) for interactive session inactivity before automatic closure.""" +REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS = json.loads( + os.getenv("REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS", "{}") +) +"""Allowed and recommended environments to be used for interactive sessions.""" + # Kubernetes jobs timeout # ================== REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT = os.getenv("REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT") diff --git a/reana_server/rest/info.py b/reana_server/rest/info.py index 71cdeb6d..a46be48f 100644 --- a/reana_server/rest/info.py +++ b/reana_server/rest/info.py @@ -24,6 +24,7 @@ REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT, REANA_KUBERNETES_JOBS_MAX_USER_TIMEOUT_LIMIT, REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD, + REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS, DASK_ENABLED, REANA_DASK_CLUSTER_DEFAULT_NUMBER_OF_WORKERS, REANA_DASK_CLUSTER_MAX_MEMORY_LIMIT, @@ -106,6 +107,15 @@ def info(user, **kwargs): # noqa type: string x-nullable: true type: object + interactive_session_recommended_jupyter_images: + properties: + title: + type: string + value: + type: array + items: + type: string + type: object maximum_kubernetes_jobs_timeout: properties: title: @@ -205,6 +215,13 @@ def info(user, **kwargs): # noqa "title": "Maximum timeout for Kubernetes jobs", "value": "1209600" }, + "interactive_session_recommended_jupyter_images": { + "title": "Recommended jupyter images for interactive sessions", + "value": [ + 'docker.io/jupyter/scipy-notebook:notebook-6.4.5', + 'docker.io/jupyter/scipy-notebook:notebook-9.4.5', + ] + }, "dask_enabled": { "title": "Dask workflows allowed in the cluster", "value": "False" @@ -277,6 +294,15 @@ def info(user, **kwargs): # noqa title="Maximum inactivity period in days before automatic closure of interactive sessions", value=REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD, ), + interactive_session_recommended_jupyter_images=dict( + title="Recommended jupyter images for interactive sessions", + value=[ + item["image"] + for item in REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS["jupyter"][ + "recommended" + ] + ], + ), dask_enabled=dict( title="Dask workflows allowed in the cluster", value=bool(DASK_ENABLED), @@ -343,6 +369,7 @@ class InfoSchema(Schema): StringNullableInfoValue ) kubernetes_max_memory_limit = fields.Nested(StringInfoValue) + interactive_session_recommended_jupyter_images = fields.Nested(ListStringInfoValue) dask_enabled = fields.Nested(StringInfoValue) if DASK_ENABLED: dask_cluster_default_number_of_workers = fields.Nested(StringInfoValue)