Skip to content

Commit

Permalink
Add default group_id to init params (#399)
Browse files Browse the repository at this point in the history
## Description

When attempting to override the `group_id` parameter of a DbtTaskGroup,
I get the following error:

```text
TypeError: __init__() got multiple values for argument 'group_id'
```

## Related Issue(s)
closes #398 

## Breaking Change?

There are no breaking changes with this PR

## 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: Julian LaNeve <[email protected]>
  • Loading branch information
2 people authored and tatiana committed Aug 9, 2023
1 parent 3343033 commit 34c2462
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cosmos/airflow/task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ class DbtTaskGroup(TaskGroup, DbtToAirflowConverter): # type: ignore[misc] # ig

def __init__(
self,
group_id: str = "dbt_task_group",
*args: Any,
**kwargs: Any,
) -> None:
group_id = kwargs.get("group_id", kwargs.get("dbt_project_name", "dbt_task_group"))
TaskGroup.__init__(self, group_id, *args, **airflow_kwargs(**kwargs))
group_id = group_id
TaskGroup.__init__(self, group_id=group_id, *args, **airflow_kwargs(**kwargs))
kwargs["task_group"] = self
DbtToAirflowConverter.__init__(self, *args, **specific_kwargs(**kwargs))
1 change: 1 addition & 0 deletions dev/dags/basic_cosmos_task_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def basic_cosmos_task_group() -> None:
pre_dbt = EmptyOperator(task_id="pre_dbt")

jaffle_shop = DbtTaskGroup(
group_id="test_123",
project_config=ProjectConfig(
DBT_ROOT_PATH / "jaffle_shop",
),
Expand Down

0 comments on commit 34c2462

Please sign in to comment.