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

Release 1.2.2 #650

Merged
merged 9 commits into from
Nov 6, 2023
Merged

Release 1.2.2 #650

merged 9 commits into from
Nov 6, 2023

Conversation

tatiana
Copy link
Collaborator

@tatiana tatiana commented Nov 6, 2023

Bug fixes

Others

navedgaras and others added 9 commits November 6, 2023 14:25
…nd `LoadMethod.CUSTOM` (#615)

Resolving issues with the DBT_MANIFEST/CUSTOM load methods when the
has_test attribute is not assigned to the node correctly.

## Description

When a tag selector is used, all tests are filtered out because of the
DbtResourceType.TEST node does not have any information about tags. To
bypass this limitation - tags are assigned to tests based on their
parent model.

## Related Issue(s)

Closes: #580

Co-authored-by: edgarasnavickas <[email protected]>
(cherry picked from commit 58de67e)
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.1 →
v0.1.3](astral-sh/ruff-pre-commit@v0.1.1...v0.1.3)
- [github.com/psf/black: 23.10.0 →
23.10.1](psf/black@23.10.0...23.10.1)
<!--pre-commit.ci end-->

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 8c89d8b)
)

Reduce Cosmos code complexity from 18 to 10, automating checks as part of the CI.

```shell
❯ pre-commit run flake8 --all-files
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

cosmos/dbt/graph.py:134:5: C901 'DbtGraph.load_via_dbt_ls' is too complex (16)
cosmos/dbt/parser/project.py:136:5: C901 'DbtModel.__post_init__' is too complex (18)
cosmos/dbt/parser/project.py:346:5: C901 'LegacyDbtProject._handle_config_file' is too complex (15)
cosmos/dbt/selector.py:87:1: C901 'select_nodes_ids_by_intersection' is too complex (16)
```

Closes: #525
(cherry picked from commit f9809a8)
To run the integration tests locally without errors, developers have to
set more environment variables than the ones that are currently in the
docs. If these were excluded, they would get errors like:

```shell
tests/test_example_dags_no_connections.py:59: in <module>
    @pytest.mark.parametrize("dag_id", get_dag_ids())
tests/test_example_dags_no_connections.py:54: in get_dag_ids
    dag_bag = get_dag_bag()
tests/test_example_dags_no_connections.py:49: in get_dag_bag
    assert not db.import_errors
E   AssertionError: assert not {'/Users/justin.bandoro/astronomer-cosmos/dev/dags/example_cosmos_python_models.py': 'Traceback (most recent call last...ema.yml from project jaffle_shop: Parsing Error\n    Env var required but not provided: \'DATABRICKS_CLUSTER_ID\'\n\n'}
E    +  where {'/Users/justin.bandoro/astronomer-cosmos/dev/dags/example_cosmos_python_models.py': 'Traceback (most recent call last...ema.yml from project jaffle_shop: Parsing Error\n    Env var required but not provided: \'DATABRICKS_CLUSTER_ID\'\n\n'} = <airflow.models.dagbag.DagBag object at 0x1579cd000>.import_errors
```

(cherry picked from commit 156e51d)
At the moment, all PRs are failing due to issues with integration tests
not being able to run. An example of error message:
```
FAILED tests/test_example_dags.py::test_example_dag[extract_dag] - assert not {'/home/runner/work/astronomer-cosmos/astronomer-cosmos/dev/dags/example_cosmos_python_models.py': 'Traceback (most recent call last):\n  File "/opt/hostedtoolcache/Python/3.9.18/x64/lib/python3.9/selectors.py", line 416, in select\n    fd_event_list = self._selector.poll(timeout)\n  File "/home/runner/.local/share/hatch/env/virtual/astronomer-cosmos/Za_bFbg4/tests.py3.9-2.4/lib/python3.9/site-packages/airflow/utils/timeout.py", line 69, in handle_timeout\n    raise AirflowTaskTimeout(self.error_message)\nairflow.exceptions.AirflowTaskTimeout: DagBag import timeout for /home/runner/work/astronomer-cosmos/astronomer-cosmos/dev/dags/example_cosmos_python_models.py after 30.0s.\nPlease take a look at these docs to improve your DAG import time:\n* https://airflow.apache.org/docs/apache-airflow/2.4.0/best-practices.html#top-level-python-code\n* https://airflow.apache.org/docs/apache-airflow/2.4.0/best-practices.html#reducing-dag-complexity, PID: 2558\n'}
```
This issue relates to #520 - something we'll be soon working on.

In the meantime, we're increasing the DAG Parsing time in the CI - so
our tests can run again.

We should also review how we run the integration tests - we probably do
not need to run all DAGs against the Python x Airflow matrix, and we
could parallelise some of those.

(cherry picked from commit 358f4b0)
1) Airflow 2.4 & Werkzeug =>3 issue

Our integration tests failed for Airflow 2.4 and under since Werkzeug
3.0 and higher during `airflow db init` with:
```
Traceback (most recent call last):
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/bin/airflow", line 10, in <module>
    sys.exit(main())
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/airflow/__main__.py", line 39, in main
    args.func(args)
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/airflow/cli/cli_parser.py", line 52, in command
    return func(*args, **kwargs)
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/airflow/cli/commands/db_command.py", line 37, in initdb
    db.initdb()
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/airflow/utils/session.py", line 75, in wrapper
    return func(*args, session=session, **kwargs)
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/airflow/utils/db.py", line 681, in initdb
    _create_db_from_orm(session=session)
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/airflow/utils/db.py", line 653, in _create_db_from_orm
    from airflow.www.fab_security.sqla.models import Model
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/airflow/www/fab_security/sqla/models.py", line 27, in <module>
    from flask_appbuilder.models.sqla import Model
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_appbuilder/__init__.py", line 5, in <module>
    from .api import ModelRestApi  # noqa: F401
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_appbuilder/api/__init__.py", line 24, in <module>
    from ..baseviews import AbstractViewApi
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_appbuilder/baseviews.py", line 22, in <module>
    from .forms import GeneralModelConverter
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_appbuilder/forms.py", line 3, in <module>
    from flask_wtf import FlaskForm
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_wtf/__init__.py", line 3, in <module>
    from .recaptcha import *
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_wtf/recaptcha/__init__.py", line 2, in <module>
    from .fields import *
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_wtf/recaptcha/fields.py", line 3, in <module>
    from . import widgets
  File "/Users/tati/Library/Application Support/hatch/env/virtual/astronomer-cosmos/4VBJdS-x/tests.py3.10-2.4/lib/python3.10/site-packages/flask_wtf/recaptcha/widgets.py", line 2, in <module>
    from werkzeug.urls import url_encode
```
Which led to no Airflow tables being created during the tests
initialisation.

2) Example DAG `cosmos_manifest_example` relying on pre-existing data

The selection statement used in the `cosmos_manifest_example` expected
data to pre-exist in the database. This probably worked before because
of the order of the tests run - and it broke up recently once this test
started running before others.

Since tests should be self-contained, the filter clause was changed so
this DAG execution becomes independent.

(cherry picked from commit 14b3090)
… Rendering and Execution (#634)

This MR finishes the work that was started in #605 to add full support
for ProjectConfig.dbt_project_path = None, and implements #568.

Within this PR, several things have been updated:
1 - Added project_path fields to RenderConfig and ExecutionConfig
2 - Simplified the consumption of RenderConfig in the dbtGraph class
3 - added option to configure different dbt executables for Rendering vs
Execution.

Closes: #568
(cherry picked from commit b64eb9a)
Bug fixes

* Support ProjectConfig.dbt_project_path = None & different paths for Rendering and Execution by @MrBones757 in #634
* Fix adding test nodes to DAGs built using LoadMethod.DBT_MANIFEST and LoadMethod.CUSTOM by @edgga in #615

Others

* Add pre-commit hook for McCabe max complexity check and fix errors by @jbandoro in #629
* Update contributing docs for running integration tests by @jbandoro in #638
* Fix CI issue running integration tests by @tatiana in #640 and #644
* pre-commit updates in #637
@tatiana tatiana requested a review from a team as a code owner November 6, 2023 15:31
@tatiana tatiana requested a review from a team November 6, 2023 15:31
Copy link
Collaborator

@jlaneve jlaneve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excited for this one!

@tatiana tatiana merged commit 3e12377 into release-1.2 Nov 6, 2023
@tatiana tatiana deleted the release-1.2.2 branch November 6, 2023 21:45
@tatiana tatiana added this to the 1.2.2 milestone Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants