Skip to content

Commit

Permalink
feat(sessions): add recommended images to info endpoint (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alputer committed Nov 12, 2024
1 parent d36b59b commit 112aee4
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
39 changes: 39 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 can set custom interactive session images or not",
"value": "False"
},
"kubernetes_max_memory_limit": {
"title": "Maximum allowed memory limit for Kubernetes jobs",
"value": "10Gi"
Expand Down Expand Up @@ -617,6 +628,34 @@
},
"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": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"kubernetes_max_memory_limit": {
"properties": {
"title": {
Expand Down
11 changes: 11 additions & 0 deletions reana_server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,17 @@ 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."""

REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS_CUSTOM_ALLOWED = (
REANA_INTERACTIVE_SESSIONS_ENVIRONMENTS.get("custom_allowed", "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
46 changes: 46 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,24 @@ 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: array
items:
type: string
type: object
maximum_kubernetes_jobs_timeout:
properties:
title:
Expand Down Expand Up @@ -221,6 +241,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 can set custom interactive session images or not",
"value": "False"
},
"dask_enabled": {
"title": "Dask workflows allowed in the cluster",
"value": "False"
Expand Down Expand Up @@ -301,6 +332,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="Whether users can set custom interactive session images or not",
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 +419,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

0 comments on commit 112aee4

Please sign in to comment.