This is an automated email from the ASF dual-hosted git repository.
onikolas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 4b9b400cff Allow importing the aws executors with a shorter path
(#39093)
4b9b400cff is described below
commit 4b9b400cff77eed44149b1b28aa70a3532949f61
Author: Niko Oliveira <[email protected]>
AuthorDate: Thu Apr 18 15:26:22 2024 -0700
Allow importing the aws executors with a shorter path (#39093)
* Allow importing the aws executors with a shorter path
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`
---
airflow/providers/amazon/aws/executors/batch/__init__.py | 5 +++++
airflow/providers/amazon/aws/executors/ecs/__init__.py | 5 +++++
tests/providers/amazon/aws/executors/batch/test_batch_executor.py | 5 +++++
tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py | 5 +++++
4 files changed, 20 insertions(+)
diff --git a/airflow/providers/amazon/aws/executors/batch/__init__.py
b/airflow/providers/amazon/aws/executors/batch/__init__.py
index 13a83393a9..07dd9b5fd7 100644
--- a/airflow/providers/amazon/aws/executors/batch/__init__.py
+++ b/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 # Added by precommit hooks
+
+__all__ = ["AwsBatchExecutor"]
+
+from airflow.providers.amazon.aws.executors.batch.batch_executor import
AwsBatchExecutor
diff --git a/airflow/providers/amazon/aws/executors/ecs/__init__.py
b/airflow/providers/amazon/aws/executors/ecs/__init__.py
index 13a83393a9..a8ec64d84b 100644
--- a/airflow/providers/amazon/aws/executors/ecs/__init__.py
+++ b/airflow/providers/amazon/aws/executors/ecs/__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 # Added by precommit hooks
+
+__all__ = ["AwsEcsExecutor"]
+
+from airflow.providers.amazon.aws.executors.ecs.ecs_executor import
AwsEcsExecutor
diff --git a/tests/providers/amazon/aws/executors/batch/test_batch_executor.py
b/tests/providers/amazon/aws/executors/batch/test_batch_executor.py
index e8ad0e4592..8a5773bdca 100644
--- a/tests/providers/amazon/aws/executors/batch/test_batch_executor.py
+++ b/tests/providers/amazon/aws/executors/batch/test_batch_executor.py
@@ -834,3 +834,8 @@ class TestBatchExecutorConfig:
final_run_task_kwargs = executor._submit_job_kwargs(mock_ti_key,
command, "queue", exec_config)
assert final_run_task_kwargs == expected_result
+
+ def test_short_import_path(self):
+ from airflow.providers.amazon.aws.executors.batch import
AwsBatchExecutor as AwsBatchExecutorShortPath
+
+ assert AwsBatchExecutor is AwsBatchExecutorShortPath
diff --git a/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py
b/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py
index 4110483162..fd7bf67726 100644
--- a/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py
+++ b/tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py
@@ -1703,3 +1703,8 @@ class TestEcsExecutorConfig:
final_run_task_kwargs = executor._run_task_kwargs(mock_ti_key,
command, "queue", exec_config)
assert final_run_task_kwargs == expected_result
+
+ def test_short_import_path(self):
+ from airflow.providers.amazon.aws.executors.ecs import AwsEcsExecutor
as AwsEcsExecutorShortPath
+
+ assert AwsEcsExecutor is AwsEcsExecutorShortPath