-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
Implement API generator and use it on Connection #18934
Conversation
Connexion seems to be an abandonded project, so we might want to migrate off to some thing else instead of putting more time in to using it? |
I'd quite agree. |
Sadly not -- (at least last time I looked) FastAPI is the inverse of what we want when it comes to the schema -- FastAPI creates the OpenAPI schema from the views/models etc, where as we want to specify the schema up front and the implement it |
https://github.com/p1c2u/openapi-core is on my list to look at, but it's still a fairly small project so I wouldn't feel happy with Airflow using it unless we also got one of us to have co-maintainer on the project. |
Oh yeah, forgot about that !! :( |
Connexion seems to have found some new life recently: spec-first/connexion#1429 But this PR (and the idea of turning the API implementation into structured classes) isn't really that related to Connexion or whatever OpenAPI tool we use; it was mentioned because the implementation hit some restrictions in Connexion and had to avoid some encapsulation to make things work. But this actually has a "nice" side effect that makes our logic encapsulation decoupled to the OpenAPI part, and we wouldn't need to change the extracted classes when we migrate to another OpenAPI implementation. (What will require the class to change is if we switch away from Marshmallow, e.g. use FaskAPI.) |
@Ruwann and I have recently joined as maintainers on Connexion, specifically because it is the only mature API-first Python framework. Let us know if we can help out. |
Any thoughts on the general approach taken here? Again, the abstraction implemented here is not really affected by what OpenAPI implementation we use. |
👍 I like the approach. |
616dade
to
053d45c
Compare
053d45c
to
1c1f7c5
Compare
Should be ready. |
""" | ||
|
||
resource_name: str # Name of the resource for display in error messages etc. | ||
instance_index: List[str] # List keys to uniquely select an instance. |
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.
instance_index: List[str] # List keys to uniquely select an instance. | |
instance_indices: List[str] # List keys to uniquely select an instance. |
Wondering if it should be plural?
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.
This is not a list of indices, but describing an index (in the database sense) to select a unique instance out for comparison (another name I briefly considered was primary_key
). But the name is indeed difficult to understand, maybe I'll change it to something like unique_instance_fields
. Suggestions are definitely much welcomed.
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 prefer the unique_instance_fields
resource_name: str # Name of the resource for display in error messages etc. | ||
instance_index: List[str] # List keys to uniquely select an instance. | ||
|
||
# A list of two-tuples mapping a field's internal name to external (as seen by the user). |
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.
Dictionary, right?
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.
Right, I changed the implementation but forgot to update the comment.
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest main or amend the last commit of the PR, and push it with --force-with-lease. |
Let's hear from others before merge. |
New release with flask2 support -> https://github.com/zalando/connexion/releases/tag/2.10.0 |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
See #15072, cc @ephraimbuddy
It turns out Connexion performs argument introspection to decide what arguments to pass to an endpoint (a bit like pytest fixtures), so we can't actually make the functions too generic. For example, we must have a parameter named
connection_id
in various Connection endpoints, but that's obvious specific to Connection and cannot be refactored out. So this two-layer approach is the best I can come up with for now.I'm not actually convinced myself if this is a good idea (it feels like a ton of architecture that makes code more difficult to understand), but at least now we have something to think about.