Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dbt docs natively in Airflow via plugin (astronomer#737)
## Description This PR adds a plugin (via the Airflow plugins entrypoint) that adds a menu item inside of `Browse` that renders the dbt docs: ![image](https://github.com/astronomer/astronomer-cosmos/assets/31971762/77b5e8d6-ada5-484c-b463-a01352ab61f6) And this is what it looks like. (This example is inside the dev docker compose): <img width="1627" alt="image" src="https://github.com/astronomer/astronomer-cosmos/assets/31971762/387bd139-cd3f-4e57-90e6-aea7c426092d"> The docs are rendered via an iframe with some additional hacks to make the page render in a user friendly way. I chose an iframe over vendoring the `index.html` in the templates for a few reasons, but mostly to support custom `{% block __overview__ %}` text. However, extracting the text from `index.html` and rendering it in a custom page is certainly an option too. The dbt docs are specified in the Airflow config with the following parameters: ```ini [cosmos] dbt_docs_dir = path/to/docs/here dbt_docs_conn_id = my_conn_id ``` Note that the path can be a link to any of the following: - S3 - Azure Blob Storage - Google Cloud Storage - HTTP/HTTPS - Local storage This is designed to work with the operators that dump the dbt docs, and the documentation changes I added make that clear. Lastly, if docs are not hooked up, a message comes up telling the user that they should set their dbt docs up: <img width="816" alt="image" src="https://github.com/astronomer/astronomer-cosmos/assets/31971762/b385275a-c618-46a1-b36d-1148c1b5706e"> ### Current limitations - Most importantly, **I need help testing the S3 / Azure / GCS integrations.** I _think_ I got them right but I'll need someone to actually try them. - **I also wouldn't mind some help testing the UI on more browsers.** I've tested both Firefox and Chrome. - **The iframe hack is less than ideal; I would preferably want the dbt docs to have a fixed height.** So instead of using the scroll bar of the Airflow UI, use the scroll bar of the dbt docs UI. The issue is basically that I am not an HTML/CSS/JavaScript person. I don't think there is any reason this shouldn't be possible, so I can continue to look into this as the PR is reviewed, or someone else can just do it for me. - I cannot run tests locally (lots of issues, mostly the databricks DAG in `dev/dags/` fails locally), so I actually have no idea whether the test suite works. I was just planning on letting Github Actions take a stab at it. ### API Decisions The core maintainers of the repo should provide some feedback on a few high level API decisions: - **Config variable names:** Let me know if `dbt_docs_dir` and `dbt_docs_conn_id` are appropriate names. Other names could be like, `dbt_docs_path`, or `dbt_docs_dir_conn_id`, or `dbt_docs_path_conn_id`, etc. - **Location in UI:** I entertained two ideas: (a) Adding a menu button called Cosmos with dbt docs underneath. (b) Adding it under browse. Ultimately I decided on option 2. ## Related Issue(s) Closes astronomer#571. ## Breaking Change? This PR should not cause any breaking changes. ## Checklist - [x] I have made corresponding changes to the documentation (if required) - [x] I have added tests that prove my fix is effective or that my feature works --------- Co-authored-by: Tatiana Al-Chueyr <[email protected]> Co-authored-by: Justin Bandoro <[email protected]>
- Loading branch information