Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AWS ECS task run execution mode #1507

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

CarlosGitto
Copy link

Description

This PR introduces an AWS ECS operator that allows Cosmos to run dbt tasks in AWS ECS, pulling images from Amazon ECR. This ensures that dbt executions are consistent with the existing Airflow DAGs running in ECS.

Similar to the Azure Container Instance execution mode, this enhancement provides an ECS-native execution mode for Cosmos users.

What changes?

  • New AwsEcsOperator classes (inheriting from AbstractDbtBaseOperator) - Based on the original EcsRunTaskOperator
  • Tests
  • Adjusted documentation

Related Issue(s)

resolves #1355

Breaking Change?

No, just an added feature

Checklist

  • I have made corresponding changes to the documentation (if required)
  • I have added tests that prove my fix is effective or that my feature works

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Feb 4, 2025
Copy link

netlify bot commented Feb 4, 2025

Deploy Preview for sunny-pastelito-5ecb04 ready!

Name Link
🔨 Latest commit 5b6baf6
🔍 Latest deploy log https://app.netlify.com/sites/sunny-pastelito-5ecb04/deploys/67a28f4749f55d0008832066
😎 Deploy Preview https://deploy-preview-1507--sunny-pastelito-5ecb04.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dosubot dosubot bot added the area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc label Feb 4, 2025
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

Attention: Patch coverage is 85.50725% with 10 lines in your changes missing coverage. Please review.

Project coverage is 96.88%. Comparing base (e11e5ae) to head (5b6baf6).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
cosmos/__init__.py 20.00% 8 Missing ⚠️
cosmos/operators/aws_ecs.py 96.55% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1507      +/-   ##
==========================================
- Coverage   97.05%   96.88%   -0.18%     
==========================================
  Files          77       78       +1     
  Lines        4483     4552      +69     
==========================================
+ Hits         4351     4410      +59     
- Misses        132      142      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @CarlosGitto, this is a great contribution, thank you very much!

Some early feedback:

Code coverage

  • Please, feel free to use # pragma: no cover in the import statements that codecov mentioned that are untested. This is one of the few exceptions we open to using # pragma: no cover . This should increase the current 85.50% of diff hit (target 97.05%).

Pre-commit

There were some minor linting details that pre-commit complained:

ix end of files..............................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing docs/getting_started/aws-container-run-job.rst

trim trailing whitespace......................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing docs/getting_started/aws-container-run-job.rst

ruff..........................................................................Failed
- hook id: ruff
- files were modified by this hook

Found 1 error (1 fixed, 0 remaining).

black.........................................................................Failed
- hook id: black
- files were modified by this hook

reformatted cosmos/__init__.py

To learn more about how we use pre-commit, please, check https://github.com/astronomer/astronomer-cosmos/blob/c344eb4750f0269ecd267326373814abf56ec18e/docs/contributing.rst#pre-commit

I'm optimistic we'll be able to ship this as part of Cosmos 1.9 - we'll do a more thorough review in the upcoming days

DbtRunOperationMixin,
DbtSeedMixin,
DbtSnapshotMixin,
DbtTestMixin,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably also want to import DbtSourceMixin and implement the correspondent class to avoid this type issue:
#1290

super().__init__(*args, **kwargs)


class DbtTestAwsEcsOperator(DbtTestMixin, DbtAwsEcsBaseOperator):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some operators can leverage the full_refresh configuration. You may want to follow something similar to #1501 to make sure this works for this execution mode.

@@ -0,0 +1,175 @@
.. title:: Getting Started with Astronomer Cosmos on AWS ECS

Getting Started with Astronomer Cosmos on AWS ECS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Addition to this excellent documentation, it would be great if you could also update the page that gives an overview on the execution modes available, referencing this newly introduced page:
https://astronomer.github.io/astronomer-cosmos/getting_started/execution-modes.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Enable execution mode for AWS ECS tasks
4 participants