-
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 docs for PipesEMRClient
- Loading branch information
1 parent
c158f37
commit 1b18d97
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
examples/docs_snippets/docs_snippets/guides/dagster/dagster_pipes/emr/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,52 @@ | ||
# start_asset_marker | ||
import os | ||
|
||
import boto3 | ||
from dagster_aws.pipes import PipesEMRClient | ||
|
||
from dagster import AssetExecutionContext, asset | ||
|
||
|
||
@asset | ||
def glue_pipes_asset(context: AssetExecutionContext, pipes_emr_client: PipesEMRClient): | ||
return pipes_emr_client.run( | ||
context=context, | ||
run_job_flow_params={ | ||
"Name": "Example Job", | ||
"Instances": { | ||
"MasterInstanceType": "m5.xlarge", | ||
"SlaveInstanceType": "m5.xlarge", | ||
"InstanceCount": 3, | ||
}, | ||
"Steps": [ | ||
{ | ||
"Name": "Example Step", | ||
"ActionOnFailure": "CONTINUE", | ||
"HadoopJarStep": { | ||
"Jar": "command-runner.jar", | ||
"Args": [ | ||
"spark-submit", | ||
"--deploy-mode", | ||
"cluster", | ||
"example.py", | ||
], | ||
}, | ||
} | ||
], | ||
}, | ||
).get_materialize_result() | ||
|
||
|
||
# end_asset_marker | ||
|
||
# start_definitions_marker | ||
|
||
from dagster import Definitions # noqa | ||
|
||
|
||
defs = Definitions( | ||
assets=[glue_pipes_asset], | ||
resources={"pipes_emr_client": PipesEMRClient()}, | ||
) | ||
|
||
# end_definitions_marker |
26 changes: 26 additions & 0 deletions
26
examples/docs_snippets/docs_snippets/guides/dagster/dagster_pipes/emr/emr_script.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,26 @@ | ||
import boto3 | ||
from dagster_pipes import ( | ||
PipesCliArgsParamsLoader, | ||
PipesS3ContextLoader, | ||
open_dagster_pipes, | ||
) | ||
|
||
client = boto3.client("s3") | ||
context_loader = PipesS3ContextLoader(client) | ||
params_loader = PipesCliArgsParamsLoader() | ||
|
||
|
||
def main(): | ||
with open_dagster_pipes( | ||
context_loader=context_loader, | ||
params_loader=params_loader, | ||
) as pipes: | ||
pipes.log.info("Hello from AWS Glue job!") | ||
pipes.report_asset_materialization( | ||
metadata={"some_metric": {"raw_value": 0, "type": "int"}}, | ||
data_version="alpha", | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |