Skip to content
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

DM-44230: Add Slack error reporting #5

Merged
merged 9 commits into from
May 7, 2024
Merged

Conversation

jonathansick
Copy link
Member

@jonathansick jonathansick commented May 6, 2024

The POST /fastapi-bootcamp/error-demo endpoint specifically raises these errors for demonstration.

I also added a GET /fastapi-bootcamp/dependency-demo endpoint that explores writing custom dependencies. I'm not sure of the terminology, but I'm calling one type "functional dependencies" and the other "class-based" dependencies / "stateful" dependencies. Suggestions are welcome on this terminology!

jonathansick added a commit to lsst-sqre/phalanx that referenced this pull request May 6, 2024
@jonathansick jonathansick force-pushed the tickets/DM-44230 branch 2 times, most recently from 25f29ae to ee2204e Compare May 6, 2024 21:13
@jonathansick jonathansick marked this pull request as ready for review May 6, 2024 21:18
@jonathansick jonathansick requested a review from rra May 6, 2024 21:19
Copy link
Member

@rra rra left a comment

Choose a reason for hiding this comment

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

Overall, looks great. Thank you for adding this! Just a few minor points about wording and maybe a more complex dependency problem.

src/fastapibootcamp/handlers/external.py Outdated Show resolved Hide resolved
src/fastapibootcamp/handlers/external.py Outdated Show resolved Hide resolved
src/fastapibootcamp/handlers/external.py Outdated Show resolved Hide resolved
src/fastapibootcamp/handlers/external.py Outdated Show resolved Hide resolved
src/fastapibootcamp/handlers/external.py Outdated Show resolved Hide resolved
The `POST /fastapi-bootcamp/error-demo` endpoint specifically raises
these errors for demonstration.
It's not really needed here.
@jonathansick jonathansick force-pushed the tickets/DM-44230 branch 3 times, most recently from 48f71ca to 8bcee83 Compare May 7, 2024 19:03
@jonathansick
Copy link
Member Author

@rra Thanks for all the suggestions. I also ended up using that pagination dependency on the endpoint for getting a collection of observers, GET /fastapi-bootcamp/astroplan/observers. I think it works well. It's getting close to the launch date but I'd be interested in your thoughts on that too.

Copy link
Member

@rra rra left a comment

Choose a reason for hiding this comment

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

This looks great. Thank you! I only noticed a couple of minor things that may have been intentional.

Comment on lines 69 to 73
page : int, optional
The page number, by default 1.
limit : int, optional
The number of items to return per page, by default 10.
order : SortOrder, optional
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit: I think the type information in the docstring can be dropped.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, I was going fast and Copilot auto-filled this 😓

@@ -10,7 +10,9 @@
from astropy.coordinates import AltAz, Angle, SkyCoord
from astropy.time import Time

__all__ = ["Observer", "TargetObservability"]
from fastapibootcamp.dependencies.pagination import Pagination
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit: Do you want to use a relative import here? I usually do and it looked like you were elsewhere, although I didn't know if there was a reason to avoid it here.

This lesson explores custom FastAPI dependencies. We cover the two
styles.

For a functional dependency, we're adding a pagination dependency that
adds query strings parameters for a user to control pagination.

For a class-based singleton dependency, we have a simple example that
initializes a semi-random string to show how that value is persistent
across requests.
This doesn't actually compatible with mypy/FastAPI yet.
This uses the same Pagination dependency we developed for the initial
lessons.
Rather than breaking out the Pagination in the service and storage layer
requests, we'll continue to pass it through. This slightly breaks the
rules because now the same model is used both internally and for the
API, but it is a pragmatic judgment call.
@jonathansick jonathansick merged commit 161bed4 into main May 7, 2024
3 checks passed
@jonathansick jonathansick deleted the tickets/DM-44230 branch May 7, 2024 22:00
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.

2 participants