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 3 commits into
base: main
Choose a base branch
from
Open

Refactor endpoints #20

wants to merge 3 commits 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

Copy link
Collaborator

Choose a reason for hiding this comment

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

I renamed it to livez.



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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it? Judging by the documentation, you are supposed to use uvicorn sciwyrm.main:app. Plus, this way, you can use uvicorn sciwyrm.main:app --reload which auto reloads the app when files are changed.

@jl-wynen jl-wynen force-pushed the refactor_endpoints branch from 2ced623 to 4522331 Compare May 23, 2025 11:36
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