C2w4a1 - DAG import errors

For Week 4 Assignment: Building an Advanced Data Pipeline With Data Quality , after copying the dags to s3 directory, at step 6
“Running the DAGs with Airflow”, the airflow UI shows dag
import errors… NameError: name ‘alitran’ is not defined

Hello @Rajeev_Prabhakar
Unfortunately, I was not able to reproduce the issue. Apparently, there is an error with importing the DAG from your model_trip_duration_alitran.py file. Is the same happening with the other two DAGs or only this one?
Please, provide a screenshot of the Airflow homepage where you can see the complete error. It should say in which line the import error is happening, and we will be able to delve deeper into this issue by knowing that.

@Amir_Zare - yes, it’s happening for all DAGs…

The json files for all vendors were also created, but, that didn’t
seem to have helped…

@Rajeev_Prabhakar the problem is with line 36 of your template.py file. The {{ vendor_name }} placeholder should be withing quotation marks, so that in the final Alitran DAG file we have vendor_name="alitran", not vendor_name=alitran. As it is, python is looking for a variable named alitran, and it can’t find it.

@Amir_Zare
ok, I fixed that…thanks !

I noticed that in the template.py, the editor
or interface shows a red x mark (parsing failed
invalid syntax) against the function definition
entry when I try step 5.1.2.

@Amir_Zare - any suggestions on how to resolve parsing failed/invalid syntax error when defining the function using
the jinja template syntax ?

@Rajeev_Prabhakar are you able to run python3 ./generate_dags.py from step 5.3.2? If this runs without a problem and Airflow is importing your DAGs, you can ignore the editor’s warning.