coufon commented on a change in pull request #5594: [AIRFLOW-4924] Loading DAGs 
asynchronously in Airflow webserver
URL: https://github.com/apache/airflow/pull/5594#discussion_r304672110
 
 

 ##########
 File path: tests/dags/test_stringified_dags.py
 ##########
 @@ -0,0 +1,192 @@
+# -*- coding: utf-8 -*-
+#
+# 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.
+
+"""Unit tests for stringified DAGs."""
+
+import multiprocessing
+import pickle
+import unittest
+from datetime import datetime
+
+from airflow import example_dags
+from airflow.contrib import example_dags as contrib_example_dags
+from airflow.models import BaseOperator
+from airflow.models import DAG
+from airflow.models import DagBag
+from airflow.dag.stringified_dags import _is_primitive
+from airflow.dag.stringified_dags import stringify
+from airflow.operators.bash_operator import BashOperator
+
+
+# airflow/example_dags/
+EXAMPLE_DAGS = [
+    'example_bash_operator',
+    'example_branch_operator',
+    'example_branch_dop_operator_v3',
+    'example_http_operator',
+    'latest_only_with_trigger',
+    'latest_only',
+    'example_passing_params_via_test_command',
+    'example_pig_operator',
+    'example_python_operator',
+    'example_short_circuit_operator',
+    'example_skip_dag',
+    'example_subdag_operator',
+    'example_trigger_controller_dag',
+    'example_trigger_target_dag',
+    'example_xcom',
+    'test_utils',
+    'tutorial'
+]
+
+# airflow/contrib/example_dags/
+CONTRIB_EXAMPLE_DAGS = [
+    # 'azure_container_instances_default',
+    'example_azure_cosmosdb_sensor',
+    'example_databricks_operator',
+    'example_dingding_operator',
+    'emr_job_flow_automatic_steps_dag',
+    'emr_job_flow_manual_steps_dag',
+    'example_gcp_bigtable_operators',
+    'example_gcp_cloud_build',
+    'example_gcp_compute',
+    'example_gcp_compute_igm',
+    'example_gcp_dataproc_create_cluster',
+    'example_gcp_dataproc_pig_operator',
+    'example_gcp_function',
+    'example_gcp_natural_language',
+    'example_gcp_spanner',
+    'example_gcp_speech',
+    # 'example_gcp_sql',
+    'example_gcp_sql_query',
+    'example_gcp_transfer',
+    'example_gcp_translate',
+    'example_gcp_video_intelligence',
+    'example_gcp_vision_autogenerated_id',
+    'example_gcp_vision_explicit_id',
+    'example_gcp_vision_annotate_image',
+    # 'example_gcs_acl',
+    'example_gcs_to_bq_operator',
+    'example_kubernetes_executor',
+    # 'example_kubernetes_executor_config',
 
 Review comment:
   There are DAG importing errors related to these DAGs:
   (1) for example_gcp_sql, example_gcs_acl, 
example_kubernetes_executor_config, the cause is in models/baseoperator.py, 
"resolve_template_files" calls getattr(self, attr) for template_fields, it 
returns an error if attr does not exist. I changed it to getattr(self, attr, 
None) as the fix.
   (2) for example_kubernetes_executor_config, it import "libs" with a relative 
path and the module can not be found. I replaced it by the full path 
"airflow.contrib.example_dags.libs".
   
   All example DAGs work after adding the two fixes. Hope the fixes make sense.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to