You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Prab-27 (via GitHub)" <gi...@apache.org> on 2026/07/08 17:19:50 UTC
[PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Prab-27 opened a new pull request, #69627:
URL: https://github.com/apache/airflow/pull/69627
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull request.
Write a good git commit message following this guide: http://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the documentation.
For user-facing UI changes, please attach before/after screenshots (or a short
screen recording) so reviewers can assess the visual impact.
Feel free to ping (in general) for the review if you do not see reaction for a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR, please
change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
-->
- [ ] Yes (please specify the tool below)
<!--
Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
---
* Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
* For fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "aaron-y-chen (via GitHub)" <gi...@apache.org>.
aaron-y-chen commented on code in PR #69627:
URL: https://github.com/apache/airflow/pull/69627#discussion_r3742697613
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -207,35 +207,44 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr, _check_flag_and_exit_if_server_response_error(value))
- def execute_list(self, *, path, data_model, offset=0, limit=50, params=None):
- if limit <= 0:
+ def execute_list(self, *, path, data_model, offset=0, limit=None, params=None):
+ page_size = 50
+ if params:
+ limit = params.pop("limit", limit)
+ offset = params.pop("offset", offset)
+ if limit is not None and limit <= 0:
raise ValueError(f"limit must be a positive integer, got {limit}")
- shared_params = {"limit": limit, **(params or {})}
-
def safe_validate(content: bytes) -> BaseModel:
try:
return data_model.model_validate_json(content) # type: ignore[union-attr]
except ValidationError:
raw = fill_missing_fields(json.loads(content), data_model)
return data_model.model_validate(raw) # type: ignore[union-attr]
- self.response = self.client.get(path, params={**shared_params, "offset": offset})
+ first_size = page_size if limit is None else min(limit, page_size)
+ shared_params = {"limit": first_size, "offset": offset, **(params or {})}
+ self.response = self.client.get(path, params=shared_params)
first_pass = safe_validate(self.response.content)
total_entries = first_pass.total_entries # type: ignore[attr-defined]
- if total_entries < limit:
+ if first_size < page_size:
return first_pass
found_key = None
for key, value in first_pass.model_dump().items():
if key != "total_entries" and isinstance(value, list):
found_key = key
break
entry_list = getattr(first_pass, found_key)
- offset = offset + limit
+ if limit:
+ total_entries = min(limit, total_entries) + offset
Review Comment:
What if `total_entries = 200`, `offset = 150`, and `limit = 100`?
According to this line, `total_entries` would become `250`. Is that expected?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "Prab-27 (via GitHub)" <gi...@apache.org>.
Prab-27 commented on PR #69627:
URL: https://github.com/apache/airflow/pull/69627#issuecomment-5220485378
@pierrejeambrun Would you please take a look when you have some time ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun commented on code in PR #69627:
URL: https://github.com/apache/airflow/pull/69627#discussion_r3795376310
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -207,35 +207,44 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr, _check_flag_and_exit_if_server_response_error(value))
- def execute_list(self, *, path, data_model, offset=0, limit=50, params=None):
- if limit <= 0:
+ def execute_list(self, *, path, data_model, offset=0, limit=None, params=None):
+ page_size = 50
+ if params:
+ limit = params.pop("limit", limit)
+ offset = params.pop("offset", offset)
+ if limit is not None and limit <= 0:
raise ValueError(f"limit must be a positive integer, got {limit}")
- shared_params = {"limit": limit, **(params or {})}
-
def safe_validate(content: bytes) -> BaseModel:
try:
return data_model.model_validate_json(content) # type: ignore[union-attr]
except ValidationError:
raw = fill_missing_fields(json.loads(content), data_model)
return data_model.model_validate(raw) # type: ignore[union-attr]
Review Comment:
I'm not sure to get this. Similarly to what the API is doing, (limit is the page size basically)
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -207,35 +207,44 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr, _check_flag_and_exit_if_server_response_error(value))
- def execute_list(self, *, path, data_model, offset=0, limit=50, params=None):
- if limit <= 0:
+ def execute_list(self, *, path, data_model, offset=0, limit=None, params=None):
+ page_size = 50
+ if params:
+ limit = params.pop("limit", limit)
+ offset = params.pop("offset", offset)
+ if limit is not None and limit <= 0:
raise ValueError(f"limit must be a positive integer, got {limit}")
- shared_params = {"limit": limit, **(params or {})}
-
def safe_validate(content: bytes) -> BaseModel:
try:
return data_model.model_validate_json(content) # type: ignore[union-attr]
except ValidationError:
raw = fill_missing_fields(json.loads(content), data_model)
return data_model.model_validate(raw) # type: ignore[union-attr]
- self.response = self.client.get(path, params={**shared_params, "offset": offset})
+ first_size = page_size if limit is None else min(limit, page_size)
+ shared_params = {"limit": first_size, "offset": offset, **(params or {})}
+ self.response = self.client.get(path, params=shared_params)
first_pass = safe_validate(self.response.content)
total_entries = first_pass.total_entries # type: ignore[attr-defined]
- if total_entries < limit:
+ if first_size < page_size:
return first_pass
found_key = None
for key, value in first_pass.model_dump().items():
if key != "total_entries" and isinstance(value, list):
found_key = key
break
entry_list = getattr(first_pass, found_key)
- offset = offset + limit
+ if limit:
+ total_entries = min(limit, total_entries) + offset
Review Comment:
Indeed, that seems weird.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "Prab-27 (via GitHub)" <gi...@apache.org>.
Prab-27 commented on PR #69627:
URL: https://github.com/apache/airflow/pull/69627#issuecomment-4917423573
Once I'lI test again with other test cases then will finalize this PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "henry3260 (via GitHub)" <gi...@apache.org>.
henry3260 commented on code in PR #69627:
URL: https://github.com/apache/airflow/pull/69627#discussion_r3796590893
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -207,35 +207,44 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr, _check_flag_and_exit_if_server_response_error(value))
- def execute_list(self, *, path, data_model, offset=0, limit=50, params=None):
- if limit <= 0:
+ def execute_list(self, *, path, data_model, offset=0, limit=None, params=None):
+ page_size = 50
+ if params:
+ limit = params.pop("limit", limit)
+ offset = params.pop("offset", offset)
+ if limit is not None and limit <= 0:
raise ValueError(f"limit must be a positive integer, got {limit}")
- shared_params = {"limit": limit, **(params or {})}
-
def safe_validate(content: bytes) -> BaseModel:
try:
return data_model.model_validate_json(content) # type: ignore[union-attr]
except ValidationError:
raw = fill_missing_fields(json.loads(content), data_model)
return data_model.model_validate(raw) # type: ignore[union-attr]
- self.response = self.client.get(path, params={**shared_params, "offset": offset})
+ first_size = page_size if limit is None else min(limit, page_size)
+ shared_params = {"limit": first_size, "offset": offset, **(params or {})}
+ self.response = self.client.get(path, params=shared_params)
first_pass = safe_validate(self.response.content)
total_entries = first_pass.total_entries # type: ignore[attr-defined]
- if total_entries < limit:
+ if first_size < page_size:
return first_pass
found_key = None
for key, value in first_pass.model_dump().items():
if key != "total_entries" and isinstance(value, list):
found_key = key
break
entry_list = getattr(first_pass, found_key)
- offset = offset + limit
+ if limit:
+ total_entries = min(limit, total_entries) + offset
Review Comment:
agree, IIUC we should implement like this
```
total_entries = first_pass.total_entries
stop = min(offset + limit, total_entries) if limit else total_entries
...
while offset < stop:
...
obj = data_model(**{found_key: entry_list, "total_entries": total_entries})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "henry3260 (via GitHub)" <gi...@apache.org>.
henry3260 commented on code in PR #69627:
URL: https://github.com/apache/airflow/pull/69627#discussion_r3796572999
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -207,35 +207,44 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr, _check_flag_and_exit_if_server_response_error(value))
- def execute_list(self, *, path, data_model, offset=0, limit=50, params=None):
- if limit <= 0:
+ def execute_list(self, *, path, data_model, offset=0, limit=None, params=None):
+ page_size = 50
+ if params:
+ limit = params.pop("limit", limit)
+ offset = params.pop("offset", offset)
+ if limit is not None and limit <= 0:
raise ValueError(f"limit must be a positive integer, got {limit}")
- shared_params = {"limit": limit, **(params or {})}
-
def safe_validate(content: bytes) -> BaseModel:
try:
return data_model.model_validate_json(content) # type: ignore[union-attr]
except ValidationError:
raw = fill_missing_fields(json.loads(content), data_model)
return data_model.model_validate(raw) # type: ignore[union-attr]
Review Comment:
> I'm not sure to get this. Similarly to what the API is doing, (limit is the page size basically)
agree, IIUC we should implement like this
```
total_entries = first_pass.total_entries
stop = min(offset + limit, total_entries) if limit else total_entries
...
while offset < stop:
...
obj = data_model(**{found_key: entry_list, "total_entries": total_entries})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "henry3260 (via GitHub)" <gi...@apache.org>.
henry3260 commented on code in PR #69627:
URL: https://github.com/apache/airflow/pull/69627#discussion_r3796572999
##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -207,35 +207,44 @@ def __init_subclass__(cls, **kwargs):
if callable(value):
setattr(cls, attr, _check_flag_and_exit_if_server_response_error(value))
- def execute_list(self, *, path, data_model, offset=0, limit=50, params=None):
- if limit <= 0:
+ def execute_list(self, *, path, data_model, offset=0, limit=None, params=None):
+ page_size = 50
+ if params:
+ limit = params.pop("limit", limit)
+ offset = params.pop("offset", offset)
+ if limit is not None and limit <= 0:
raise ValueError(f"limit must be a positive integer, got {limit}")
- shared_params = {"limit": limit, **(params or {})}
-
def safe_validate(content: bytes) -> BaseModel:
try:
return data_model.model_validate_json(content) # type: ignore[union-attr]
except ValidationError:
raw = fill_missing_fields(json.loads(content), data_model)
return data_model.model_validate(raw) # type: ignore[union-attr]
Review Comment:
> I'm not sure to get this. Similarly to what the API is doing, (limit is the page size basically)
agree, IIUC we should implement like this
```
total_entries = first_pass.total_entries
stop = min(offset + limit, total_entries) if limit else total_entries
...
while offset < stop:
...
obj = data_model(**{found_key: entry_list, "total_entries": total_entries})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 commented on PR #69627:
URL: https://github.com/apache/airflow/pull/69627#issuecomment-6436788220
Closing as #68616 already fixed it in a different way
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] airflowctl-Fix params value in `execute_list()` method [airflow]
Posted by "shahar1 (via GitHub)" <gi...@apache.org>.
shahar1 closed pull request #69627: airflowctl-Fix params value in `execute_list()` method
URL: https://github.com/apache/airflow/pull/69627
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org