-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dagster-aws] [docs] add documentation for ECS Pipes
- Loading branch information
1 parent
38144fb
commit a07ac44
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
examples/docs_snippets/docs_snippets/guides/dagster/dagster_pipes/ecs/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.11-slim | ||
|
||
RUN python -m pip install --no-cache dagster-pipes boto3 | ||
|
||
# TODO: replace this with `pip install dagster-pipes` once the docs are finished | ||
RUN pip install --no-cache-dir dagster-pipes boto3 | ||
|
||
WORKDIR /app | ||
|
||
COPY task.py . |
48 changes: 48 additions & 0 deletions
48
examples/docs_snippets/docs_snippets/guides/dagster/dagster_pipes/ecs/dagster_code.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# start_asset_marker | ||
import os | ||
|
||
# dagster_glue_pipes.py | ||
import boto3 | ||
from dagster_aws.pipes import PipesECSClient | ||
from docutils.nodes import entry | ||
|
||
from dagster import AssetExecutionContext, asset | ||
|
||
|
||
|
||
@asset | ||
def ecs_pipes_asset(context: AssetExecutionContext, pipes_ecs_client: PipesECSClient): | ||
return pipes_ecs_client.run( | ||
context=context, | ||
task_definition="dagster-pipes", | ||
launch_type="FARGATE", | ||
network_configuration={ | ||
"awsvpcConfiguration": { | ||
"subnets": [ | ||
"subnet-a96acdc0" | ||
], | ||
"securityGroups": ["sg-028d32553728591b2"], | ||
"assignPublicIp": "ENABLED", | ||
} | ||
}, | ||
).get_materialize_result() | ||
|
||
|
||
# end_asset_marker | ||
|
||
# start_definitions_marker | ||
|
||
from dagster import Definitions # noqa | ||
from dagster_aws.pipes import PipesS3MessageReader | ||
|
||
|
||
defs = Definitions( | ||
assets=[ecs_pipes_asset], | ||
resources={ | ||
"pipes_ecs_client": PipesECSClient( | ||
client=boto3.client("ecs"), | ||
) | ||
}, | ||
) | ||
|
||
# end_definitions_marker |
14 changes: 14 additions & 0 deletions
14
examples/docs_snippets/docs_snippets/guides/dagster/dagster_pipes/ecs/dev.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# this Dockerfile can be used for ECS Pipes development | ||
|
||
FROM python:3.11-slim | ||
|
||
RUN python -m pip install --no-cache dagster-pipes boto3 | ||
|
||
RUN --mount=type=cache,target=/root/.cache/pip pip install boto3 | ||
|
||
COPY python_modules/dagster-pipes /src/dagster-pipes | ||
|
||
RUN pip install -e /src/dagster-pipes | ||
|
||
WORKDIR /app | ||
COPY examples/docs_snippets/docs_snippets/guides/dagster/dagster_pipes/ecs/task.py . |
21 changes: 21 additions & 0 deletions
21
examples/docs_snippets/docs_snippets/guides/dagster/dagster_pipes/ecs/task.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import boto3 | ||
from dagster_pipes import ( | ||
PipesEnvVarParamsLoader, | ||
PipesS3ContextLoader, | ||
open_dagster_pipes, | ||
) | ||
|
||
client = boto3.client("s3") | ||
|
||
|
||
def main(): | ||
with open_dagster_pipes() as pipes: | ||
pipes.log.info("Hello from AWS ECS task!") | ||
pipes.report_asset_materialization( | ||
metadata={"some_metric": {"raw_value": 0, "type": "int"}}, | ||
data_version="alpha", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |