You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "o-nikolas (via GitHub)" <gi...@apache.org> on 2024/04/17 17:56:37 UTC
[PR] Allow importing the aws executors with a shorter path [airflow]
o-nikolas opened a new pull request, #39093:
URL: https://github.com/apache/airflow/pull/39093
Import the aws executors in the `__init__.py` module of their respective directories so that they can be imported with a shorter and more natural looking module path.
For example, this modules path:
`airflow.providers.amazon.aws.executors.batch.batch_executor.AwsBatchExecutor`
Becomes:
`airflow.providers.amazon.aws.executors.batch.AwsBatchExecutor`
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! 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.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+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 a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas merged PR #39093:
URL: https://github.com/apache/airflow/pull/39093
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1571330656
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations # Added by precommit hooks
+
+# from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+from airflow.providers.amazon.aws.executors.batch import batch_executor
+
+# precommit hooks (rust as of the time of commit) throws F401 - "Module imported but unused"
+# One of the solutions it suggests is using a "redundant alias". This is used below instead of doing a #no-qa
+# type ignore of the issue.
+AwsBatchExecutor = batch_executor.AwsBatchExecutor
Review Comment:
```suggestion
from __future__ import annotations
__all__ = ["AwsBatchExecutor"]
from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
```
`__all__` will make pre-commit and IDEs happy without hacks
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1569264003
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations
+
+from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+
+AwsBatchExecutor = AwsBatchExecutor
Review Comment:
I wonder if it's worth a comment?
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1569247978
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations
Review Comment:
Precommit scripts auto added this
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "jedcunningham (via GitHub)" <gi...@apache.org>.
jedcunningham commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1569263339
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations
+
+from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+
+AwsBatchExecutor = AwsBatchExecutor
Review Comment:
Very interesting, thanks would have been scratching my head on that one without this comment.
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1571448627
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations # Added by precommit hooks
+
+# from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+from airflow.providers.amazon.aws.executors.batch import batch_executor
+
+# precommit hooks (rust as of the time of commit) throws F401 - "Module imported but unused"
+# One of the solutions it suggests is using a "redundant alias". This is used below instead of doing a #no-qa
+# type ignore of the issue.
+AwsBatchExecutor = batch_executor.AwsBatchExecutor
Review Comment:
Moved to using __all__
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations # Added by precommit hooks
+
+# from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+from airflow.providers.amazon.aws.executors.batch import batch_executor
+
+# precommit hooks (rust as of the time of commit) throws F401 - "Module imported but unused"
+# One of the solutions it suggests is using a "redundant alias". This is used below instead of doing a #no-qa
+# type ignore of the issue.
+AwsBatchExecutor = batch_executor.AwsBatchExecutor
Review Comment:
Moved to using `__all__`
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1569269444
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations
+
+from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+
+AwsBatchExecutor = AwsBatchExecutor
Review Comment:
Sure, yeah, that's fair. I'll some comments to the code itself.
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1569305684
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations
+
+from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+
+AwsBatchExecutor = AwsBatchExecutor
Review Comment:
Done! Resolving this thread
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1569249463
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,8 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations
+
+from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+
+AwsBatchExecutor = AwsBatchExecutor
Review Comment:
Precommit static tests also required that the import be used and suggested using a "redundant alias", so I went with that approach rather than adding a #no-qa type ignore.
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #39093:
URL: https://github.com/apache/airflow/pull/39093#issuecomment-2065229063
Just an idea, maybe move it into the [package root](https://github.com/apache/airflow/blob/3d76fb4bf25e5b7d3d30e0d64867b5999b77f0b0/airflow/providers/amazon/aws/__init__.py) and make it lazy-loaded thought PEP-562, e.g. the same way as if does into the:
- [airflow.__init__.py](https://github.com/apache/airflow/blob/3d76fb4bf25e5b7d3d30e0d64867b5999b77f0b0/airflow/__init__.py)
- [airflow.models__init__.py](https://github.com/apache/airflow/blob/3d76fb4bf25e5b7d3d30e0d64867b5999b77f0b0/airflow/models/__init__.py)
--
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] Allow importing the aws executors with a shorter path [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39093:
URL: https://github.com/apache/airflow/pull/39093#discussion_r1571359065
##########
airflow/providers/amazon/aws/executors/batch/__init__.py:
##########
@@ -14,3 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from __future__ import annotations # Added by precommit hooks
+
+# from airflow.providers.amazon.aws.executors.batch.batch_executor import AwsBatchExecutor
+from airflow.providers.amazon.aws.executors.batch import batch_executor
+
+# precommit hooks (rust as of the time of commit) throws F401 - "Module imported but unused"
+# One of the solutions it suggests is using a "redundant alias". This is used below instead of doing a #no-qa
+# type ignore of the issue.
+AwsBatchExecutor = batch_executor.AwsBatchExecutor
Review Comment:
To me using `__all__` is just as much of a hack, since we wouldn't specify that anyway. I'm not sure one is better than the other.
--
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