-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* AIP-47 - Migrate beam DAGs to new design #22439
- Loading branch information
Showing
14 changed files
with
748 additions
and
449 deletions.
There are no files selected for viewing
437 changes: 0 additions & 437 deletions
437
airflow/providers/apache/beam/example_dags/example_beam.py
This file was deleted.
Oops, something went wrong.
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
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
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
File renamed without changes.
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,66 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" | ||
Example Airflow DAG for Apache Beam operators | ||
""" | ||
|
||
from airflow import models | ||
from airflow.providers.apache.beam.operators.beam import BeamRunJavaPipelineOperator | ||
from airflow.providers.google.cloud.transfers.gcs_to_local import GCSToLocalFilesystemOperator | ||
from tests.system.providers.apache.beam.utils import ( | ||
GCS_INPUT, | ||
GCS_JAR_DIRECT_RUNNER_BUCKET_NAME, | ||
GCS_JAR_DIRECT_RUNNER_OBJECT_NAME, | ||
START_DATE, | ||
) | ||
|
||
with models.DAG( | ||
"example_beam_native_java_direct_runner", | ||
schedule_interval=None, # Override to match your needs | ||
start_date=START_DATE, | ||
catchup=False, | ||
tags=['example'], | ||
) as dag: | ||
|
||
# [START howto_operator_start_java_direct_runner_pipeline] | ||
jar_to_local_direct_runner = GCSToLocalFilesystemOperator( | ||
task_id="jar_to_local_direct_runner", | ||
bucket=GCS_JAR_DIRECT_RUNNER_BUCKET_NAME, | ||
object_name=GCS_JAR_DIRECT_RUNNER_OBJECT_NAME, | ||
filename="/tmp/beam_wordcount_direct_runner_{{ ds_nodash }}.jar", | ||
) | ||
|
||
start_java_pipeline_direct_runner = BeamRunJavaPipelineOperator( | ||
task_id="start_java_pipeline_direct_runner", | ||
jar="/tmp/beam_wordcount_direct_runner_{{ ds_nodash }}.jar", | ||
pipeline_options={ | ||
'output': '/tmp/start_java_pipeline_direct_runner', | ||
'inputFile': GCS_INPUT, | ||
}, | ||
job_class='org.apache.beam.examples.WordCount', | ||
) | ||
|
||
jar_to_local_direct_runner >> start_java_pipeline_direct_runner | ||
# [END howto_operator_start_java_direct_runner_pipeline] | ||
|
||
|
||
from tests.system.utils import get_test_run | ||
|
||
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest) | ||
test_run = get_test_run(dag) |
65 changes: 65 additions & 0 deletions
65
tests/system/providers/apache/beam/example_beam_java_flink.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,65 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" | ||
Example Airflow DAG for Apache Beam operators | ||
""" | ||
|
||
from airflow import models | ||
from airflow.providers.apache.beam.operators.beam import BeamRunJavaPipelineOperator | ||
from airflow.providers.google.cloud.transfers.gcs_to_local import GCSToLocalFilesystemOperator | ||
from tests.system.providers.apache.beam.utils import ( | ||
GCS_INPUT, | ||
GCS_JAR_FLINK_RUNNER_BUCKET_NAME, | ||
GCS_JAR_FLINK_RUNNER_OBJECT_NAME, | ||
START_DATE, | ||
) | ||
|
||
with models.DAG( | ||
"example_beam_native_java_flink_runner", | ||
schedule_interval=None, # Override to match your needs | ||
start_date=START_DATE, | ||
catchup=False, | ||
tags=['example'], | ||
) as dag: | ||
|
||
jar_to_local_flink_runner = GCSToLocalFilesystemOperator( | ||
task_id="jar_to_local_flink_runner", | ||
bucket=GCS_JAR_FLINK_RUNNER_BUCKET_NAME, | ||
object_name=GCS_JAR_FLINK_RUNNER_OBJECT_NAME, | ||
filename="/tmp/beam_wordcount_flink_runner_{{ ds_nodash }}.jar", | ||
) | ||
|
||
start_java_pipeline_flink_runner = BeamRunJavaPipelineOperator( | ||
task_id="start_java_pipeline_flink_runner", | ||
runner="FlinkRunner", | ||
jar="/tmp/beam_wordcount_flink_runner_{{ ds_nodash }}.jar", | ||
pipeline_options={ | ||
'output': '/tmp/start_java_pipeline_flink_runner', | ||
'inputFile': GCS_INPUT, | ||
}, | ||
job_class='org.apache.beam.examples.WordCount', | ||
) | ||
|
||
jar_to_local_flink_runner >> start_java_pipeline_flink_runner | ||
|
||
|
||
from tests.system.utils import get_test_run | ||
|
||
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest) | ||
test_run = get_test_run(dag) |
65 changes: 65 additions & 0 deletions
65
tests/system/providers/apache/beam/example_beam_java_spark.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,65 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" | ||
Example Airflow DAG for Apache Beam operators | ||
""" | ||
|
||
from airflow import models | ||
from airflow.providers.apache.beam.operators.beam import BeamRunJavaPipelineOperator | ||
from airflow.providers.google.cloud.transfers.gcs_to_local import GCSToLocalFilesystemOperator | ||
from tests.system.providers.apache.beam.utils import ( | ||
GCS_INPUT, | ||
GCS_JAR_SPARK_RUNNER_BUCKET_NAME, | ||
GCS_JAR_SPARK_RUNNER_OBJECT_NAME, | ||
START_DATE, | ||
) | ||
|
||
with models.DAG( | ||
"example_beam_native_java_spark_runner", | ||
schedule_interval=None, # Override to match your needs | ||
start_date=START_DATE, | ||
catchup=False, | ||
tags=['example'], | ||
) as dag: | ||
|
||
jar_to_local_spark_runner = GCSToLocalFilesystemOperator( | ||
task_id="jar_to_local_spark_runner", | ||
bucket=GCS_JAR_SPARK_RUNNER_BUCKET_NAME, | ||
object_name=GCS_JAR_SPARK_RUNNER_OBJECT_NAME, | ||
filename="/tmp/beam_wordcount_spark_runner_{{ ds_nodash }}.jar", | ||
) | ||
|
||
start_java_pipeline_spark_runner = BeamRunJavaPipelineOperator( | ||
task_id="start_java_pipeline_spark_runner", | ||
runner="SparkRunner", | ||
jar="/tmp/beam_wordcount_spark_runner_{{ ds_nodash }}.jar", | ||
pipeline_options={ | ||
'output': '/tmp/start_java_pipeline_spark_runner', | ||
'inputFile': GCS_INPUT, | ||
}, | ||
job_class='org.apache.beam.examples.WordCount', | ||
) | ||
|
||
jar_to_local_spark_runner >> start_java_pipeline_spark_runner | ||
|
||
|
||
from tests.system.utils import get_test_run | ||
|
||
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest) | ||
test_run = get_test_run(dag) |
Oops, something went wrong.