From da490fbef9060debda9f91ae560b92758f118d61 Mon Sep 17 00:00:00 2001 From: Tasko Olevski Date: Tue, 9 Jul 2024 01:13:32 +0200 Subject: [PATCH] fix: put back docstrings for launching sessions --- renku_notebooks/__init__.py | 5 ++- renku_notebooks/api/notebooks.py | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/renku_notebooks/__init__.py b/renku_notebooks/__init__.py index 3c5db4c3..ef568bac 100644 --- a/renku_notebooks/__init__.py +++ b/renku_notebooks/__init__.py @@ -26,6 +26,7 @@ from .api.notebooks import ( check_docker_image, launch_notebook, + renku_2_launch_notebook_helper, patch_server, server_logs, server_options, @@ -38,7 +39,7 @@ from .api.schemas.logs import ServerLogs from .api.schemas.servers_get import NotebookResponse, ServersGetRequest, ServersGetResponse from .api.schemas.servers_patch import PatchServerRequest -from .api.schemas.servers_post import LaunchNotebookRequest +from .api.schemas.servers_post import LaunchNotebookRequest, Renku2LaunchNotebookRequest from .api.schemas.version import VersionResponse from .config import config as config from .errors.utils import handle_exception @@ -130,6 +131,7 @@ def register_swagger(app): ) # Register schemas spec.components.schema("LaunchNotebookRequest", schema=LaunchNotebookRequest) + spec.components.schema("Renku2LaunchNotebookRequest", schema=Renku2LaunchNotebookRequest) spec.components.schema("NotebookResponse", schema=NotebookResponse) spec.components.schema("PatchServerRequest", schema=PatchServerRequest) spec.components.schema("ServersGetRequest", schema=ServersGetRequest) @@ -148,6 +150,7 @@ def register_swagger(app): spec.path(view=server_options) spec.path(view=server_logs) spec.path(view=check_docker_image) + spec.path(view=renku_2_launch_notebook_helper) # Register security scheme security_scheme = { "type": "openIdConnect", diff --git a/renku_notebooks/api/notebooks.py b/renku_notebooks/api/notebooks.py index 07d5754f..20b0d0b7 100644 --- a/renku_notebooks/api/notebooks.py +++ b/renku_notebooks/api/notebooks.py @@ -194,6 +194,34 @@ def launch_notebook( server_options=None, user_secrets=None, ): + """Launch a Jupyter server. + + --- + post: + description: Start a server. + requestBody: + content: + application/json: + schema: LaunchNotebookRequest + responses: + 200: + description: The server exists and is already running. + content: + application/json: + schema: NotebookResponse + 201: + description: The requested server has been created. + content: + application/json: + schema: NotebookResponse + 404: + description: The server could not be launched. + content: + application/json: + schema: ErrorResponse + tags: + - servers + """ server_name = renku_1_make_server_name(user.safe_username, namespace, project, branch, commit_sha) gl_project = user.get_renku_project(f"{namespace}/{project}") gl_project_path = gl_project.path @@ -244,6 +272,34 @@ def renku_2_launch_notebook_helper( launcher_id: str | None = None, # Renku 2 repositories: list[dict[str, str]] | None = None, # Renku 2 ): + """Launch a Jupyter server using the new API. + + --- + post: + description: Start a server. + requestBody: + content: + application/json: + schema: Renku2LaunchNotebookRequest + responses: + 200: + description: The server exists and is already running. + content: + application/json: + schema: NotebookResponse + 201: + description: The requested server has been created. + content: + application/json: + schema: NotebookResponse + 404: + description: The server could not be launched. + content: + application/json: + schema: ErrorResponse + tags: + - servers + """ server_name = renku_2_make_server_name( safe_username=user.safe_username, project_id=project_id, launcher_id=launcher_id )