-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
[DRAFT] Switch to Connexion 3 framework #39055
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,6 +148,8 @@ jobs: | |
env: | ||
HATCH_ENV: "test" | ||
working-directory: ./clients/python | ||
- name: Compile www assets | ||
run: breeze compile-www-assets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Generic comment: the tests seem to pass all thests on Python 3.9 + but the Pytest tests do not exit - likely some cleanup needs to happen there. For now switching to DEfault Python only but needs to be fixed before merge. |
||
- name: "Install Airflow in editable mode with fab for webserver tests" | ||
run: pip install -e ".[fab]" | ||
- name: "Install Python client" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,7 @@ def get_connection(*, connection_id: str, session: Session = NEW_SESSION) -> API | |
@provide_session | ||
def get_connections( | ||
*, | ||
limit: int, | ||
limit: int | None = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RobbeSneyders -> we found that the new Connexion 3 implements more validation and responds with error where no default values are provided for parameters that are no defined as optional (but they are provided by decorators - see above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't immediately think of a change that could trigger this. I tried to reproduce it with a minimal example, but it works as expected: def insert(**kwargs):
def decorator(f):
async def wrapped_function():
return await f(**kwargs)
return wrapped_function
return decorator
@insert(name="Igor")
async def post_greeting(name: str):
return f"Hello {name}", 200 paths:
/greeting:
post:
operationId: hello.post_greeting
parameters:
- name: name
in: query
schema:
type: string Do you have a stack trace by any chance? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to reduce the complexity of this PR, could such simple bulk changes separated-out to s different PR and merged beforehand? Or would this influence/break the old Connexion setup? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could do that, yes @jscheffl eventually, yes but I would like to avoid "polluting" current code without knowing how we are proceeding with the whole PR. For me this is more of POC for comments and deciding what's next rather than something we want to actively start merging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RobbeSneyders: yes: Example stack trace here (from https://github.com/apache/airflow/actions/runs/8581603105/job/23518857077 for example).
|
||
offset: int = 0, | ||
order_by: str = "id", | ||
session: Session = NEW_SESSION, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ def validate_istimezone(value: datetime) -> None: | |
raise BadRequest("Invalid datetime format", detail="Naive datetime is disallowed") | ||
|
||
|
||
def format_datetime(value: str) -> datetime: | ||
def format_datetime(value: str | None) -> datetime | None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We needdd to convert the decorators to handle None as default value - see https://github.com/apache/airflow/pull/39055/files#r1566990719 |
||
""" | ||
Format datetime objects. | ||
|
||
|
@@ -50,6 +50,8 @@ def format_datetime(value: str) -> datetime: | |
|
||
This should only be used within connection views because it raises 400 | ||
""" | ||
if value is None: | ||
return None | ||
value = value.strip() | ||
if value[-1] != "Z": | ||
value = value.replace(" ", "+") | ||
|
@@ -59,7 +61,7 @@ def format_datetime(value: str) -> datetime: | |
raise BadRequest("Incorrect datetime argument", detail=str(err)) | ||
|
||
|
||
def check_limit(value: int) -> int: | ||
def check_limit(value: int | None) -> int: | ||
""" | ||
Check the limit does not exceed configured value. | ||
|
||
|
@@ -68,7 +70,8 @@ def check_limit(value: int) -> int: | |
""" | ||
max_val = conf.getint("api", "maximum_page_limit") # user configured max page limit | ||
fallback = conf.getint("api", "fallback_page_limit") | ||
|
||
if value is None: | ||
return fallback | ||
if value > max_val: | ||
log.warning( | ||
"The limit param value %s passed in API exceeds the configured maximum page limit %s", | ||
|
@@ -99,8 +102,9 @@ def format_parameters_decorator(func: T) -> T: | |
@wraps(func) | ||
def wrapped_function(*args, **kwargs): | ||
for key, formatter in params_formatters.items(): | ||
if key in kwargs: | ||
kwargs[key] = formatter(kwargs[key]) | ||
value = formatter(kwargs.get(key)) | ||
if value: | ||
kwargs[key] = value | ||
return func(*args, **kwargs) | ||
|
||
return cast(T, wrapped_function) | ||
|
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.
We need to have assets compiled here to test Python client. Right now the API uses UI from Swagger that expects Javascript to be compiled in order to make API calls.