Skip to content

Refactor endpoints #20

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Refactor endpoints #20

wants to merge 1 commit into from

Conversation

nitrosx
Copy link
Member

@nitrosx nitrosx commented Mar 11, 2025

This PR adds the alive endpoint which is useful when deploying with an orchestration tool like kubernetes and docker and renamed the notebook/templates to just templates

@nitrosx nitrosx requested a review from jl-wynen March 11, 2025 09:42
@nitrosx nitrosx changed the title Reafactor endpoints Refactor endpoints Mar 11, 2025
Comment on lines +32 to +37
@app.get("/alive", response_description="The service is alive")
async def list_templates(
config: Annotated[AppConfig, Depends(app_config)]
) -> bool:
"""Return a list of available notebook templates."""
return True
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@app.get("/alive", response_description="The service is alive")
async def list_templates(
config: Annotated[AppConfig, Depends(app_config)]
) -> bool:
"""Return a list of available notebook templates."""
return True
@app.get("/alive", response_description="The service is alive")
async def is_alive() -> bool:
"""Return True to indicate that the service is running."""
return True

Copy link
Contributor

Choose a reason for hiding this comment

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

How about using the more conventional name live(z) and returning the string ok



if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this good for? I don't like that it has a fixed address and port. Doesn't this just lead to conflicts?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is the typical way to run it standalone in dev, but yes making the port configurable would be a nice addition

request: Request,
templates: Annotated[Jinja2Templates, Depends(get_templates)],
spec: notebook.NotebookSpecWithConfig = Depends(_inject_app_config), # noqa: B008
) -> Response:

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change

@@ -44,12 +60,13 @@ def _inject_app_config(
raise RequestValidationError(errors) from None


@app.post("/notebook", response_model=dict, response_description="Rendered notebook")
async def format_notebook(
@app.post("/notebook", response_model=dict, response_description="Rendered notebook with json input")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@app.post("/notebook", response_model=dict, response_description="Rendered notebook with json input")
@app.post("/notebook", response_model=dict, response_description="Rendered notebook from json input")

It doesn't return the json intput.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants