commented lines (#) in --from-file method do not work
thomasglaser opened this issue · comments
I have a DAG as .py which i try to render using airflow-diagrams generate --from-file path/file.py
. The file has comments in it.
The error i get is:
ParserError: expected '<document start>', but found '<scalar>' in "file.py", line 13, column 1
I believe it is necessary to adjust the read file. Delete lines which begin with #
, also having in my to .lstrip the line because of indentation.
Hi Thomas,
--from-file
expects a yaml file containing serialised Airflow DAG information. To serialize you DAG information to yaml, you can use the download
command. E.g. airflow-diagrams download airflow_dags.yml
You can find an example yaml file here.
Thanks for raising the issue. There is very little to no documentation, I know. 😔
Alright, thanks. But how does it work with a local file? Is it even possible now?
You can create the file yourself ofc, but it is easier to download it either via the separate download
command or by simply not using --from-file
and instead let generate
download the information for you.
The reason I added the download
command is so that you can split the tasks necessary to create the diagrams file. This way only the download
command would need a connection to your airflow instance. The generate command does not need it if you pass --from-file
.
Thanks Felix. Asking more directly: is there a function that converts a local .py DAG file to the format that can be processed to a diagram with generate
? :-)
No, there isn't because the data is being retrieved from the rest api - not from the DAG file.