Skip to content

Commit

Permalink
Add kwargs param in DocsOperator method upload_to_cloud_storage (#1422
Browse files Browse the repository at this point in the history
)

This PR addresses an issue where the `callback` callable parameter's
handling was modified in PR
#1389 leading to a
change in
the way keyword arguments like context were passed to the callable.

However, the Docs Operator has its own implementation of the callback
callable,
which only expects a single parameter, project_dir. As a result, passing
extra
keyword arguments like context is causing a mismatch and resulting in
the error described in #1420.

This PR adds the `kwargs` param in `upload_to_cloud_storage` method of the Docs operators

We have integration tests for these operator but look like CI does have
not required setup and it get ignored.

https://github.com/astronomer/astronomer-cosmos/blob/main/dev/dags/dbt_docs.py

related: #1420
  • Loading branch information
pankajastro authored Dec 26, 2024
1 parent dada5cf commit 4ac32cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

1.8.1a1 (2024-12-23)
--------------------

Bug Fixes

* Add ``kwargs`` param in DocsOperator method ``upload_to_cloud_storage`` by @pankajastro in #1422

1.8.0 (2024-12-20)
--------------------

Expand Down
2 changes: 1 addition & 1 deletion cosmos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Contains dags, task groups, and operators.
"""

__version__ = "1.8.0"
__version__ = "1.8.1a1"


from cosmos.airflow.dag import DbtDag
Expand Down
8 changes: 4 additions & 4 deletions cosmos/operators/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ def __init__(
self.callback = self.upload_to_cloud_storage

@abstractmethod
def upload_to_cloud_storage(self, project_dir: str) -> None:
def upload_to_cloud_storage(self, project_dir: str, **kwargs: Any) -> None:
"""Abstract method to upload the generated documentation to cloud storage."""


Expand Down Expand Up @@ -893,7 +893,7 @@ def __init__(
kwargs["connection_id"] = aws_conn_id
super().__init__(*args, **kwargs)

def upload_to_cloud_storage(self, project_dir: str) -> None:
def upload_to_cloud_storage(self, project_dir: str, **kwargs: Any) -> None:
"""Uploads the generated documentation to S3."""
self.log.info(
'Attempting to upload generated docs to S3 using S3Hook("%s")',
Expand Down Expand Up @@ -959,7 +959,7 @@ def __init__(
kwargs["bucket_name"] = container_name
super().__init__(*args, **kwargs)

def upload_to_cloud_storage(self, project_dir: str) -> None:
def upload_to_cloud_storage(self, project_dir: str, **kwargs: Any) -> None:
"""Uploads the generated documentation to Azure Blob Storage."""
self.log.info(
'Attempting to upload generated docs to Azure Blob Storage using WasbHook(conn_id="%s")',
Expand Down Expand Up @@ -1003,7 +1003,7 @@ class DbtDocsGCSLocalOperator(DbtDocsCloudLocalOperator):

ui_color = "#4772d5"

def upload_to_cloud_storage(self, project_dir: str) -> None:
def upload_to_cloud_storage(self, project_dir: str, **kwargs: Any) -> None:
"""Uploads the generated documentation to Google Cloud Storage"""
self.log.info(
'Attempting to upload generated docs to Storage using GCSHook(conn_id="%s")',
Expand Down

0 comments on commit 4ac32cf

Please sign in to comment.