-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add FastAPI routes for tours #11089
Add FastAPI routes for tours #11089
Conversation
Pydantic models (currently added to tours) require explicit specification of model fields. Having an "id" field as required seems right from a design standpoint. However, if there is a reason for an "id" value to be included in the galaxy_ui tour but not in the other tours, this field can be made optional: `id: Optional[str] = None`
- Do not call tour_loader() twice - Do not return a value from a function that modifies the value of its argument in place - Rename function to reflect what it does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great!
Field not used. See code review discussion here: galaxyproject#11089 (comment)
Address comments in code review Model is revised due to change in Tour model spec: - Id field is no longer part of the yaml file spec; - However, an id is generated and added to the tour data returned as a list - As a result, in a list, a tour item must have an id, whereas in tour details, a tour item must not have an id. I've factored out "core tour" data into its own model to solve this.
c4549d9
to
75ed305
Compare
732cab1
to
f1274c2
Compare
The latest commit addresses this comment in the code review. However, this turned out to be a good excuse to get rid of the concrete ToursRegistry class in the api module and replace it with an interface. This follows this comment; @jmchilton - does this look like the approach you were describing? |
Note about naming the abstract class: I struggled with the naming; with |
I love the abc approach. In terms of naming stuff my suggestion would be to...
At that point I would even consider renaming |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I like your approach of using an ABC for the ToursRegistry :)
@jmchilton thank you for the detailed suggestions - I think this makes the tours interface much cleaner. The factory function does not have a return type annotation - that's intentional; it's related to mypy not handling EDIT: no need for a separate issue, here's the gist. The previous commit caused a mypy error which was due to mypy not handling virtual subsclasses. References: This is (again!) ready for review. |
lib/galaxy/tours/__init__.py
Outdated
from ._schema import TourCore # noqa | ||
from ._schema import TourStep # noqa | ||
from ._schema import TourDetails # noqa | ||
from ._schema import TourList # noqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of #noqa
please use __all___
at the end of the file.
__all__ = ("build_tours_registry", "Tour", ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing! Thanks for the deep dive into this.
Ref #10889
@mvdbeek, @davelopez: please take a look - here's my first attempt.
Note: A pydantic
TourList
model (as opposed toList[Tour]
) was necessary for correct serialization inweb/framework/decorators.py
. Even though we can modify this logic to recognize a list of pydantic models, such a list cannot be serialized using the[model].json()
method.