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

feat(sessions): add recommended images to info endpoint #688

Merged
merged 1 commit into from
Nov 12, 2024
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
36 changes: 36 additions & 0 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,17 @@
"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"
]
},
"interactive_sessions_custom_image_allowed": {
"title": "Whether users are allowed to spawn custom interactive session images",
"value": "False"
},
"kubernetes_max_memory_limit": {
"title": "Maximum allowed memory limit for Kubernetes jobs",
"value": "10Gi"
Expand Down Expand Up @@ -617,6 +628,31 @@
},
"type": "object"
},
"interactive_session_recommended_jupyter_images": {
"properties": {
"title": {
"type": "string"
},
"value": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"interactive_sessions_custom_image_allowed": {
"properties": {
"title": {
"type": "string"
},
"value": {
"type": "string"
}
},
"type": "object"
},
"kubernetes_max_memory_limit": {
"properties": {
"title": {
Expand Down
15 changes: 15 additions & 0 deletions reana_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,21 @@ 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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also expose to the users in the info output whether the server allows to specify custom Jupyter images by users? See the interactive_sessions.environments.jupyter.allow_custom Helm value.

os.getenv("REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS", "{}")
)
"""Allowed and recommended environments to be used for interactive sessions."""

REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS_CUSTOM_ALLOWED = (
str(
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS.get("jupyter", {}).get(
"allow_custom", "false"
)
).lower()
== "true"
)
"""Whether users can set custom interactive session images or not."""

# Kubernetes jobs timeout
# ==================
REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT = os.getenv("REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT")
Expand Down
44 changes: 44 additions & 0 deletions reana_server/rest/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT,
REANA_KUBERNETES_JOBS_MAX_USER_TIMEOUT_LIMIT,
REANA_INTERACTIVE_SESSION_MAX_INACTIVITY_PERIOD,
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS,
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS_CUSTOM_ALLOWED,
DASK_ENABLED,
DASK_AUTOSCALER_ENABLED,
REANA_DASK_CLUSTER_DEFAULT_NUMBER_OF_WORKERS,
Expand Down Expand Up @@ -108,6 +110,22 @@ 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
interactive_sessions_custom_image_allowed:
properties:
title:
type: string
value:
type: string
type: object
maximum_kubernetes_jobs_timeout:
properties:
title:
Expand Down Expand Up @@ -221,6 +239,17 @@ 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',
]
},
"interactive_sessions_custom_image_allowed": {
"title": "Whether users are allowed to spawn custom interactive session images",
"value": "False"
},
"dask_enabled": {
"title": "Dask workflows allowed in the cluster",
"value": "False"
Expand Down Expand Up @@ -301,6 +330,19 @@ 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_sessions_custom_image_allowed=dict(
title="Users can set custom interactive session images",
value=REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS_CUSTOM_ALLOWED,
),
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),
Expand Down Expand Up @@ -375,6 +417,8 @@ class InfoSchema(Schema):
StringNullableInfoValue
)
kubernetes_max_memory_limit = fields.Nested(StringInfoValue)
interactive_session_recommended_jupyter_images = fields.Nested(ListStringInfoValue)
interactive_sessions_custom_image_allowed = fields.Nested(StringInfoValue)
dask_enabled = fields.Nested(StringInfoValue)
if DASK_ENABLED:
dask_autoscaler_enabled = fields.Nested(StringInfoValue)
Expand Down
Loading