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

Clean up some more warnings in tests #27085

Merged
merged 1 commit into from
Oct 18, 2022
Merged

Conversation

uranusjr
Copy link
Member

Picking them up bit by bit while I work on other things...

Picking them up bit by bit while I work on other things...
@boring-cyborg boring-cyborg bot added the area:API Airflow's REST/HTTP API label Oct 17, 2022
@tirkarthi
Copy link
Contributor

I wrote a small script using ast module that might be helpful with create_dagrun related deprecation warnings.

import ast
import sys


class Visitor(ast.NodeVisitor):
    def __init__(self, code, filename):
        self.code = code
        self.filename = filename

    def visit_Call(self, node):
        if (
            getattr(node.func, "attr", None) == "create_dagrun"
            and any(keyword.arg == "execution_date" for keyword in node.keywords)
            and not any(keyword.arg == "data_interval" for keyword in node.keywords)
        ):
            if node.lineno != node.end_lineno:
                line = "\n".join(
                    self.code.splitlines()[node.lineno - 1 : node.end_lineno - 1]
                )
            else:
                line = self.code.splitlines()[node.lineno - 1]
            print(self.filename, node.lineno, line)
        self.generic_visit(node)


def main(filename):
    with open(filename) as f:
        code = f.read()
        Visitor(code=code, filename=filename).visit(ast.parse(code))


if __name__ == "__main__":
    main(sys.argv[1])
find tests/api/ -iname '*py' | xargs -I{} python ../airflow_create_dagrun_warning.py {} 
tests/api/common/test_mark_tasks.py 542         return self.dag1.create_dagrun(
            run_type=DagRunType.MANUAL, state=state, start_date=date, execution_date=date
tests/api/common/test_mark_tasks.py 747         self.dag2.create_dagrun(
            run_type=DagRunType.MANUAL,
            state=State.FAILED,
            execution_date=self.execution_dates[0],
            session=session,
tests/api/common/test_mark_tasks.py 753         dr2 = self.dag2.create_dagrun(
            run_type=DagRunType.MANUAL,
            state=State.FAILED,
            execution_date=self.execution_dates[1],
            session=session,
tests/api/common/test_mark_tasks.py 759         self.dag2.create_dagrun(
            run_type=DagRunType.MANUAL,
            state=State.RUNNING,
            execution_date=self.execution_dates[2],
            session=session,

@uranusjr uranusjr merged commit ea55626 into apache:main Oct 18, 2022
@uranusjr uranusjr deleted the warnings-clean branch October 18, 2022 02:45
@potiuk
Copy link
Member

potiuk commented Oct 24, 2022

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants