You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/07/15 13:49:21 UTC
[GitHub] [airflow] mik-laj opened a new pull request #9833: Remove global variable with API auth backend
mik-laj opened a new pull request #9833:
URL: https://github.com/apache/airflow/pull/9833
---
Make sure to mark the boxes below before creating PR: [x]
- [X] Description above provides context of the change
- [X] Unit tests coverage for changes (not needed for documentation changes)
- [x] Target Github ISSUE in description if exists
- [X] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
- [X] Relevant documentation is updated including usage instructions.
- [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
---
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] ephraimbuddy commented on pull request #9833: Remove global variable with API auth backend
Posted by GitBox <gi...@apache.org>.
ephraimbuddy commented on pull request #9833:
URL: https://github.com/apache/airflow/pull/9833#issuecomment-658807474
Nice
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj merged pull request #9833: Remove global variable with API auth backend
Posted by GitBox <gi...@apache.org>.
mik-laj merged pull request #9833:
URL: https://github.com/apache/airflow/pull/9833
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj commented on a change in pull request #9833: Remove global variable with API auth backend
Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9833:
URL: https://github.com/apache/airflow/pull/9833#discussion_r455074068
##########
File path: airflow/www/api/experimental/endpoints.py
##########
@@ -35,7 +36,17 @@
log = logging.getLogger(__name__)
-requires_authentication = airflow.api.API_AUTH.api_auth.requires_authentication
Review comment:
This is a nightmare because `airflow.api.API_AUTH.api_auth` variable is empty by default. We can't load this module without calling another method beforehand.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj commented on a change in pull request #9833: Remove global variable with API auth backend
Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9833:
URL: https://github.com/apache/airflow/pull/9833#discussion_r455074068
##########
File path: airflow/www/api/experimental/endpoints.py
##########
@@ -35,7 +36,17 @@
log = logging.getLogger(__name__)
-requires_authentication = airflow.api.API_AUTH.api_auth.requires_authentication
Review comment:
This is a nightmare because `airflow.api.API_AUTH.api_auth` variable is empty by default. We can't load this module without calling `load_auth` method beforehand.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] mik-laj commented on a change in pull request #9833: Remove global variable with API auth backend
Posted by GitBox <gi...@apache.org>.
mik-laj commented on a change in pull request #9833:
URL: https://github.com/apache/airflow/pull/9833#discussion_r455066496
##########
File path: airflow/models/pool.py
##########
@@ -98,19 +100,28 @@ def slots_stats(session: Session = None) -> Dict[str, PoolStats]:
).all()
# calculate queued and running metrics
+ count: int
for (pool_name, state, count) in state_count_by_pool:
- pool = pools.get(pool_name)
- if not pool:
+ stats_dict: Optional[PoolStats] = pools.get(pool_name)
+ if not stats_dict:
continue
- pool[state] = count
+ # TypedDict key must be a string literal, so we use if-statements to set value
+ if state == "running":
Review comment:
Sorry about that. mypy exploded
```
airflow/models/pool.py:105: error: TypedDict key must be a string literal;
expected one of ('total', 'running', 'queued')
pool[state] = count
^
airflow/models/pool.py:111: error: TypedDict "PoolStats" has no key 'open'
stats["open"] = -1
^
airflow/models/pool.py:113: error: TypedDict "PoolStats" has no key 'open'
stats["open"] = stats["total"] - stats[State.RUNNING] ...
^
airflow/models/pool.py:113: error: TypedDict key must be a string literal;
expected one of ('total', 'running', 'queued')
... stats["open"] = stats["total"] - stats[State.RUNNING] - stat...
^
airflow/jobs/scheduler_job.py:1754: error: TypedDict "PoolStats" has no key
'open'
... Stats.gauge(f'pool.open_slots.{pool_name}', slot_stats["open"])
^
airflow/jobs/scheduler_job.py:1755: error: TypedDict key must be a string
literal; expected one of ('total', 'running', 'queued')
...tats.gauge(f'pool.queued_slots.{pool_name}', slot_stats[State.QUEUED])
^
airflow/jobs/scheduler_job.py:1756: error: TypedDict key must be a string
literal; expected one of ('total', 'running', 'queued')
...ts.gauge(f'pool.running_slots.{pool_name}', slot_stats[State.RUNNING])
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org