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

Improve Cosmos test environment Airflow installation #811

Closed
jbandoro opened this issue Jan 23, 2024 · 3 comments · Fixed by #812
Closed

Improve Cosmos test environment Airflow installation #811

jbandoro opened this issue Jan 23, 2024 · 3 comments · Fixed by #812
Assignees
Labels
area:dependencies Related to dependencies, like Python packages, library versions, etc execution:virtualenv Related to Virtualenv execution environment

Comments

@jbandoro
Copy link
Collaborator

Opening up this issue after #806 was merged where more pinning specific to Airflow version dependencies had to be done in overrides and a workaround to uninstall a provider that is not available in earlier Airflow versions.

A possible better way to install Airflow is to use the recommended constraint file, this way we wouldn't have to keep track of pinning different Airflow dependencies for different versions. Installing with a constraint file can be done like the below where it depends on a specific airflow version and python version:

pip install "apache-airflow==2.8.1" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.8.1/constraints-3.8.txt"

After the work @tatiana did in #806 by adding a hatch post-install-commands, I think we could use the pre-install-commands to install airflow with a constraint file. The pyproject.toml would like:

######################################
# TESTING
######################################

[tool.hatch.envs.tests]
dependencies = [
    "astronomer-cosmos[tests]",
    "types-PyYAML",
    "types-attrs",
    "types-requests",
    "types-python-dateutil",
    "Werkzeug<3.0.0",
    "apache-airflow-providers-cncf-kubernetes>=5.1.1",
    "apache-airflow-providers-docker>=3.5.0",
]
pre-install-commands = [
    "pip install 'apache-airflow=={matrix:airflow}' --constraint 'https://raw.githubusercontent.com/apache/airflow/constraints-{matrix:airflow}/constraints-{matrix:python}.txt'"
]

[[tool.hatch.envs.tests.matrix]]
python = ["3.8", "3.9", "3.10"]
airflow = ["2.3.4", "2.4.3", "2.5.3", "2.6.3", "2.7.3", "2.8.1"]


[tool.hatch.envs.tests.scripts]
...

The update above would remove the need to have the [tool.hatch.envs.tests.overrides] section. However the matrix does change a bit where the Airflow patch version is required.

The GH workflow would also need to be updated so the matrix matches.

An advantage of this is that we would not need to worry about newer releases of Airflow breaking the CI tests, but we would need to increment the patch version above when a latest version of Airflow is released.

@jbandoro jbandoro self-assigned this Jan 23, 2024
Copy link

dosubot bot commented Jan 23, 2024

🤖

Hey @jbandoro! Great to see you back here with another insightful suggestion. I'm currently diving into the details of your issue. Hang tight, I'll provide you with a comprehensive response shortly!

@dosubot dosubot bot added area:dependencies Related to dependencies, like Python packages, library versions, etc execution:virtualenv Related to Virtualenv execution environment labels Jan 23, 2024
@tatiana
Copy link
Collaborator

tatiana commented Jan 23, 2024

I really like this, @jbandoro , it looks much cleaner!

Copy link

dosubot bot commented Jan 23, 2024

🤖

It's great to hear that you're enjoying the cleaner look! If you have any questions or need assistance with anything related to the project, feel free to ask. I'm here to help!


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

tatiana pushed a commit that referenced this issue Jan 26, 2024
This PR installs apache-airflow in the hatch `pre-install-commands`
section so Airflow related dependency conflicts do not need to be
managed in the override section that has been removed.

Installing from the Airflow constraint file for versions <=2.6 fails
because PyYAML is pinned in the constraint file for those versions to
6.0.0 and [a workaround ](yaml/pyyaml#736) is
required becaused older versions of PyYAML can no longer be installed
from unmodified source or sdist with the release of Cython3.

Closes: #811
tatiana pushed a commit that referenced this issue Jan 26, 2024
This PR installs apache-airflow in the hatch `pre-install-commands`
section so Airflow related dependency conflicts do not need to be
managed in the override section that has been removed.

Installing from the Airflow constraint file for versions <=2.6 fails
because PyYAML is pinned in the constraint file for those versions to
6.0.0 and [a workaround ](yaml/pyyaml#736) is
required becaused older versions of PyYAML can no longer be installed
from unmodified source or sdist with the release of Cython3.

Closes: #811
(cherry picked from commit 928ba83)
arojasb3 pushed a commit to arojasb3/astronomer-cosmos that referenced this issue Jul 14, 2024
This PR installs apache-airflow in the hatch `pre-install-commands`
section so Airflow related dependency conflicts do not need to be
managed in the override section that has been removed.

Installing from the Airflow constraint file for versions <=2.6 fails
because PyYAML is pinned in the constraint file for those versions to
6.0.0 and [a workaround ](yaml/pyyaml#736) is
required becaused older versions of PyYAML can no longer be installed
from unmodified source or sdist with the release of Cython3.

Closes: astronomer#811
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dependencies Related to dependencies, like Python packages, library versions, etc execution:virtualenv Related to Virtualenv execution environment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants