Skip to content

Commit

Permalink
fix: put back docstrings for launching sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Jul 8, 2024
1 parent d01d07e commit da490fb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
5 changes: 4 additions & 1 deletion renku_notebooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from .api.notebooks import (
check_docker_image,
launch_notebook,
renku_2_launch_notebook_helper,
patch_server,
server_logs,
server_options,
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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",
Expand Down
56 changes: 56 additions & 0 deletions renku_notebooks/api/notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit da490fb

Please sign in to comment.