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

[dagster-airlift] mwaa example #23574

Merged
merged 2 commits into from
Aug 13, 2024
Merged

[dagster-airlift] mwaa example #23574

merged 2 commits into from
Aug 13, 2024

Conversation

dpeng817
Copy link
Contributor

@dpeng817 dpeng817 commented Aug 12, 2024

Adds example code for having dags running in mwaa and observing them running locally in dagster.

The goal here is twofold:

  • Provide sample code for using the mwaa utility functions we build
  • Provide an easily stood up and reproducible test bed for deploying code to mwaa and testing underlying dagster functionality.

Copy link

vercel bot commented Aug 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dagster-docs-next ❌ Failed (Inspect) Aug 12, 2024 10:22pm

@@ -31,16 +32,17 @@ def get_session_info(region: str, env_name: str) -> Tuple[str, str]:


class MwaaSessionAuthBackend(AirflowAuthBackend):
def __init__(self, region: str, env_name: str):
def __init__(self, region: str, env_name: str, profile_name: Optional[str] = None):
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm maybe we should just take in the boto.Session object directly as we might just replicate the entire interface here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should just revisit the interface in general. I think we should be aiming to only auth the mwaa session once in general, not just retrieving the client I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I bias towards getting this in so you guys can build on top of mwaa if needed, and then iterating on the API once it's under test

Copy link
Member

Choose a reason for hiding this comment

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

kk

Comment on lines +1 to +20
"""This script uploads DAG files and requirements.txt to an S3 bucket in a directory
matching the name of the specified MWAA environment. It then attempts to update
the MWAA environment with the new S3 location. If the environment doesn't exist,
it provides instructions for creating one.

The script prompts for user confirmation before deleting any existing contents
in the target S3 directory, then uploads the new files, ensuring a clean deployment.
"""

import os
from typing import List

import boto3
import click
from botocore.exceptions import ClientError


def get_s3_objects(s3_client: boto3.client, bucket: str, prefix: str) -> List[dict]:
"""Get list of objects in the S3 bucket with the given prefix."""
try:
Copy link
Member

Choose a reason for hiding this comment

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

This is a lot of code. Does MWAA not provide some of this stuff as utilities? This looks like we are reimplementing AWS tooling with ChatGPT or something.

Copy link
Contributor Author

@dpeng817 dpeng817 Aug 13, 2024

Choose a reason for hiding this comment

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

MWAA has pretty bad tooling for this stuff unfortunately. I pulled a lot of this from examples colton has shown me of previous mwaa deploy scripts (+ chat GPT to throw it in python land). The utilities here really are this bad unfortunately though; if you look at the AWS documentation it's exactly the steps we take here more or less: https://docs.aws.amazon.com/mwaa/latest/userguide/configuring-dag-folder.html#configuring-dag-folder-uploading

Copy link
Member

@schrockn schrockn left a comment

Choose a reason for hiding this comment

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

Inline comments

@dpeng817 dpeng817 force-pushed the dpeng817/simple_migration_example branch from 82c5dd1 to 11ecaf3 Compare August 13, 2024 20:55
@dpeng817 dpeng817 force-pushed the dpeng817/mwaa-example branch from 3044ea5 to f7ad1a4 Compare August 13, 2024 20:55
@dpeng817 dpeng817 force-pushed the dpeng817/simple_migration_example branch from 11ecaf3 to ebd571c Compare August 13, 2024 21:08
@dpeng817 dpeng817 force-pushed the dpeng817/mwaa-example branch from f7ad1a4 to 96183a0 Compare August 13, 2024 21:09
@dpeng817 dpeng817 force-pushed the dpeng817/simple_migration_example branch from ebd571c to ca408aa Compare August 13, 2024 21:12
@dpeng817 dpeng817 force-pushed the dpeng817/mwaa-example branch from 96183a0 to c6858a9 Compare August 13, 2024 21:12
@dpeng817 dpeng817 force-pushed the dpeng817/simple_migration_example branch from ca408aa to 28f23c8 Compare August 13, 2024 21:17
@dpeng817 dpeng817 force-pushed the dpeng817/mwaa-example branch from c6858a9 to 551bdb1 Compare August 13, 2024 21:17
Base automatically changed from dpeng817/simple_migration_example to master August 13, 2024 21:35
@dpeng817 dpeng817 merged commit 52904a4 into master Aug 13, 2024
1 check passed
@dpeng817 dpeng817 deleted the dpeng817/mwaa-example branch August 13, 2024 21:35
PedramNavid pushed a commit that referenced this pull request Aug 14, 2024
Adds example code for having dags running in mwaa and observing them
running locally in dagster.

The goal here is twofold:
- Provide sample code for using the mwaa utility functions we build
- Provide an easily stood up and reproducible test bed for deploying
code to mwaa and testing underlying dagster functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants