feat(operators): support dbt docs on Kubernetes via DbtDocsS3KubernetesOperator#2058
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2058 +/- ##
==========================================
- Coverage 98.08% 98.04% -0.05%
==========================================
Files 103 103
Lines 7484 7571 +87
==========================================
+ Hits 7341 7423 +82
- Misses 143 148 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tatiana
left a comment
There was a problem hiding this comment.
@jx2lee, this looks great, thanks for your contribution!
Would it be possible to update the PR description to make it more informative and include an example DAG/code showing how you tested the feature? Something similar to:
generate_dbt_docs_aws = DbtDocsS3KubernetesOperator(
# Cosmos arguments:
task_id="generate_dbt_docs_aws",
project_dir=DBT_ROOT_PATH / "jaffle_shop",
profile_config=profile_config,
connection_id="aws_s3_conn",
bucket_name="cosmos-ci-docs",
install_deps=True,
# Specific to the K8s Pod Operator:
image= "dbt-jaffle-shop:1.0.0",
get_logs=True,
is_delete_operator_pod=False,
)
Also, could you extend this example DAG:
https://github.com/astronomer/astronomer-cosmos/blob/main/dev/dags/jaffle_shop_kubernetes.py
So it also uses this newly introduced operator? You could use this example as an inspiration:
https://github.com/astronomer/astronomer-cosmos/blob/main/dev/dags/dbt_docs.py
This DAG is run in our CI, and it would help us validating the feature from an integration test perspective.
5c4c990 to
72670fc
Compare
e1a871f to
8867487
Compare
Thanks for pointing that out! |
8867487 to
5ca0e0c
Compare
✅ Deploy Preview for sunny-pastelito-5ecb04 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@jx2lee thanks a lot for addressing the feedback! Currently the code coverage check is failing, but I believe that if you accept the changes I just proposed, the task will be run as part of our CI/CD and the coverage issue should be solved. The details for the code coverage are here:
Happy for us to merge it after you apply the changes and the coverage check is green. |
4b2933a to
b4310f4
Compare
|
Hi @jx2lee, while trying to run the example DAG, I noticed it is not working. Have you tried to run this example DAG and seen the files being uploaded to the S3 bucket from the K8s pod? I was curious why the CI was still complaining about code coverage. Only today I found some time to run your code locally to understand what was going wrong. There are a few issues:
For (3), I can see two main approaches to solving it: a) Defer to the K8s Pod operator to upload the files to S3. An example of how you could accomplish this is to invoke b) Copy the dbt docs files generated in the K8s Pod back to the Airflow worker, e.g., via XCom or by printing and parsing them, and then leverage the hook - like you're doing. A final point to keep in mind is that Cosmos callbacks currently only work for We'd also be happy to accept contributions for other execution modes, including I'd highly encourage you to run locally following the steps described in: For local development of the K8s features, I also find it particularly useful to run these commands: By running these commands locally, we can use Python's debugger, via |
|
@jx2lee Could you please add documentation for this in a follow-up PR? |
2345af8 to
155de54
Compare
@pankajastro Sure. I'll make PR soon. thanks ! |


Description
Add a new operator
DbtDocsS3KubernetesOperatorthat runsdbt docs generateon Kubernetes and uploads the generated documentation to AWS S3.Key changes
DbtDocsKubernetesOperator, extendingDbtKubernetesBaseOperator, to handledbt docs generateexecution.DbtDocsCloudKubernetesOperatoras an abstract class for cloud-specific doc upload implementations.DbtDocsS3KubernetesOperator, which:connection_id,bucket_name, and optionalfolder_dirparameters.S3Hookto upload output files (index.html,manifest.json,catalog.json,static_index.html) to the specified S3 bucket.dbt docscommand execution.Example usage
Related Issue(s)
closes #1906
Breaking Change?
Checklist