Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Test task doesn't accept full_refresh kwarg #1062

Closed
1 task done
CamposContentful opened this issue Jun 24, 2024 · 2 comments · Fixed by #1175
Closed
1 task done

[Bug] Test task doesn't accept full_refresh kwarg #1062

CamposContentful opened this issue Jun 24, 2024 · 2 comments · Fixed by #1175
Labels
area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc bug Something isn't working dbt:test Primarily related to dbt test command or functionality execution:kubernetes Related to Kubernetes execution environment triage-needed Items need to be reviewed / assigned to milestone

Comments

@CamposContentful
Copy link

CamposContentful commented Jun 24, 2024

Astronomer Cosmos Version

main (development)

If "Other Astronomer Cosmos version" selected, which one?

No response

dbt-core version

1.8.2

Versions of dbt adapters

dbt-redshift = "^1.8.1"

LoadMode

DBT_LS_MANIFEST

ExecutionMode

AWS_EKS

InvocationMode

None

airflow version

MWAA 2.7.2

Operating System

Fedora

If a you think it's an UI issue, what browsers are you seeing the problem on?

No response

Deployment

Amazon (AWS) MWAA

Deployment details

No response

What happened?

Hello everyone,
when passing the full_refresh parameter in operator_args for a DbtTaskGroup task.
I get the following error:

airflow.exceptions.AirflowException: Invalid arguments were passed to DbtTestAwsEksOperator (task_id: test). Invalid arguments were:
**kwargs: {'full_refresh': True}

The task is defined as:

    example_calculation = DbtTaskGroup(
        group_id="example_calculation_models",
        project_config=ProjectConfig(
            manifest_path=f"{os.path.dirname(os.path.realpath(__file__))}/manifest.json",
            project_name="example_calculation",
        ),
        profile_config=ProfileConfig(
            profile_name="default_profile", target_name="airflow", profiles_yml_filepath="./dbt_profiles/profiles.yml"
        ),
        render_config=RenderConfig(
            select=["tag:example_calculation"],
            load_method=LoadMode.DBT_MANIFEST,
            node_converters={
                DbtResourceType("source"): convert_source,  # known dbt node type to Cosmos (part of DbtResourceType)
            },
            test_behavior=TestBehavior.AFTER_ALL,
        ),
        execution_config=ExecutionConfig(execution_mode=ExecutionMode.AWS_EKS, dbt_project_path="/usr/app/dbt/"),
        operator_args={
            "in_cluster": False,
            "image_pull_policy": "Always",
            "get_logs": True,
            "is_delete_operator_pod": True,
            "on_finish_action": "delete_pod",
            "full_refresh": True,
        },
    )

My understanding is that the full_refresh argument should be ignored by dbt test.
I couldn't find any similar issues in the repo, do you an idea if I'm just setting the argument wrong or is something else.

Thanks!

Relevant log output

No response

How to reproduce

For execution_mode=ExecutionMode.AWS_EKS set up a dbt project with test and full_refresh option in operator_args.

Anything else :)?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Contact Details

jaime.campos@contentful.com

@CamposContentful CamposContentful added bug Something isn't working triage-needed Items need to be reviewed / assigned to milestone labels Jun 24, 2024
@dosubot dosubot bot added area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc dbt:test Primarily related to dbt test command or functionality execution:kubernetes Related to Kubernetes execution environment labels Jun 24, 2024
Copy link

dosubot bot commented Jun 24, 2024

Hey @CamposContentful! 👋 I'm here to help you with your bug report. I'm a bot that can assist with bug fixes, answering questions, and even help you become a contributor. Let's tackle this together!

The DbtTestAwsEksOperator does not support the full_refresh argument. The full_refresh argument is not applicable to the dbt test command, and thus, it is not included in the DbtTestAwsEksOperator's initialization or command flags [1].

To resolve this issue, you should remove the full_refresh argument from the operator_args when using the DbtTestAwsEksOperator. Here is the corrected task definition:

example_calculation = DbtTaskGroup(
    group_id="example_calculation_models",
    project_config=ProjectConfig(
        manifest_path=f"{os.path.dirname(os.path.realpath(__file__))}/manifest.json",
        project_name="example_calculation",
    ),
    profile_config=ProfileConfig(
        profile_name="default_profile", target_name="airflow", profiles_yml_filepath="./dbt_profiles/profiles.yml"
    ),
    render_config=RenderConfig(
        select=["tag:example_calculation"],
        load_method=LoadMode.DBT_MANIFEST,
        node_converters={
            DbtResourceType("source"): convert_source,  # known dbt node type to Cosmos (part of DbtResourceType)
        },
        test_behavior=TestBehavior.AFTER_ALL,
    ),
    execution_config=ExecutionConfig(execution_mode=ExecutionMode.AWS_EKS, dbt_project_path="/usr/app/dbt/"),
    operator_args={
        "in_cluster": False,
        "image_pull_policy": "Always",
        "get_logs": True,
        "is_delete_operator_pod": True,
        "on_finish_action": "delete_pod",
        # Remove "full_refresh" argument
    },
)

By removing the full_refresh argument, the DbtTestAwsEksOperator should no longer raise an AirflowException for invalid arguments.

To continue talking to Dosu, mention @dosu.

@tatiana
Copy link
Collaborator

tatiana commented Sep 21, 2024

Hi @CamposContentful , thank you for reporting and submitting a fix for this!
Based on the dbt (latest == 1.8) docs, https://docs.getdbt.com/reference/resource-configs/full_refresh, my understanding is also that full-refresh is only a parameter for dbt run and dbt seed.

ags-de pushed a commit to ags-de/astronomer-cosmos that referenced this issue Sep 24, 2024
… (and others) (astronomer#1175)

astronomer#590 added a fix to
consume the kwargs `full_refresh_ignore` if it wasn't consumed by a
higher class as it was preventing the use of test in the DbtTaskGroup if
`full_refresh_ignore` was set. The previous patch fixed this by
consuming the variable for the `DbtLocalBaseOperator`, leaving a bug in
kubernetes and docker operator. Since `AbstractDbtBaseOperator` has been
added as a base of `DbtDockerBaseOperator`, `DbtKubernetesBaseOperator`
and `DbtLocalBaseOperator`, moving the code there will fix all three.

Fixes astronomer#1062

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:execution Related to the execution environment/mode, like Docker, Kubernetes, Local, VirtualEnv, etc bug Something isn't working dbt:test Primarily related to dbt test command or functionality execution:kubernetes Related to Kubernetes execution environment triage-needed Items need to be reviewed / assigned to milestone
Projects
None yet
2 participants