From bd58ca6447bccb2b22e1c91c670b6266481a0995 Mon Sep 17 00:00:00 2001 From: Chethan UK Date: Sun, 5 Jun 2022 01:07:15 +0100 Subject: [PATCH] AIP-47 - Migrate livy DAGs to new design #22439 --- .../apache/livy/example_dags/__init__.py | 16 ---------------- .../index.rst | 2 +- .../operators.rst | 2 +- .../providers/apache/livy}/example_livy.py | 18 +++++++++++++++++- 4 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 airflow/providers/apache/livy/example_dags/__init__.py rename {airflow/providers/apache/livy/example_dags => tests/system/providers/apache/livy}/example_livy.py (76%) diff --git a/airflow/providers/apache/livy/example_dags/__init__.py b/airflow/providers/apache/livy/example_dags/__init__.py deleted file mode 100644 index 13a83393a9124..0000000000000 --- a/airflow/providers/apache/livy/example_dags/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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. diff --git a/docs/apache-airflow-providers-apache-livy/index.rst b/docs/apache-airflow-providers-apache-livy/index.rst index cd2f5058c61fc..8ac4ff3dac16f 100644 --- a/docs/apache-airflow-providers-apache-livy/index.rst +++ b/docs/apache-airflow-providers-apache-livy/index.rst @@ -37,7 +37,7 @@ Content :maxdepth: 1 :caption: Resources - Example DAGs + Example DAGs PyPI Repository Installing from sources diff --git a/docs/apache-airflow-providers-apache-livy/operators.rst b/docs/apache-airflow-providers-apache-livy/operators.rst index 6d3aba0d677b3..09d97bbbdb93e 100644 --- a/docs/apache-airflow-providers-apache-livy/operators.rst +++ b/docs/apache-airflow-providers-apache-livy/operators.rst @@ -29,7 +29,7 @@ LivyOperator This operator wraps the Apache Livy batch REST API, allowing to submit a Spark application to the underlying cluster. -.. exampleinclude:: /../../airflow/providers/apache/livy/example_dags/example_livy.py +.. exampleinclude:: /../../tests/system/providers/apache/livy/example_livy.py :language: python :start-after: [START create_livy] :end-before: [END create_livy] diff --git a/airflow/providers/apache/livy/example_dags/example_livy.py b/tests/system/providers/apache/livy/example_livy.py similarity index 76% rename from airflow/providers/apache/livy/example_dags/example_livy.py rename to tests/system/providers/apache/livy/example_livy.py index cf7bbbfb1b18d..8420e756ec661 100644 --- a/airflow/providers/apache/livy/example_dags/example_livy.py +++ b/tests/system/providers/apache/livy/example_livy.py @@ -20,13 +20,18 @@ The tasks below trigger the computation of pi on the Spark instance using the Java and Python executables provided in the example library. """ + +import os from datetime import datetime from airflow import DAG from airflow.providers.apache.livy.operators.livy import LivyOperator +ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID") +DAG_ID = "example_livy_operator" + with DAG( - dag_id='example_livy_operator', + dag_id=DAG_ID, default_args={'args': [10]}, schedule_interval='@daily', start_date=datetime(2021, 1, 1), @@ -48,3 +53,14 @@ livy_java_task >> livy_python_task # [END create_livy] + + from tests.system.utils.watcher import watcher + + # This test needs watcher in order to properly mark success/failure + # when "tearDown" task with trigger rule is part of the DAG + list(dag.tasks) >> watcher() + +from tests.system.utils import get_test_run # noqa: E402 + +# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest) +test_run = get_test_run(dag)