Skip to content

Commit

Permalink
Allow importing the aws executors with a shorter path (apache#39093)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
o-nikolas authored and utkarsharma2 committed Apr 22, 2024
1 parent e3cf887 commit 70a3659
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions airflow/providers/amazon/aws/executors/batch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions airflow/providers/amazon/aws/executors/ecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -834,3 +834,8 @@ def test_submit_job_kwargs_exec_config_overrides(
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
5 changes: 5 additions & 0 deletions tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,3 +1703,8 @@ def test_run_task_kwargs_exec_config_overrides(
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

0 comments on commit 70a3659

Please sign in to comment.