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

Enable unit tests for Python-3.11 #1984

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
ed393a6
Enable unit tests for Python-3.11
pankajastro Jul 12, 2023
7ee3d85
Check pip version
utkarsharma2 Jul 26, 2023
72761cc
Fix airflow 2.6.0 issue
utkarsharma2 Jul 26, 2023
1dacb20
Merge branch 'main' into py-3-11
utkarsharma2 Jul 26, 2023
2e89578
Fix start_date issue
utkarsharma2 Jul 26, 2023
605ea0e
Fix start_date issue
utkarsharma2 Jul 26, 2023
78b39fe
Add ti start_date to db
utkarsharma2 Jul 27, 2023
dc41fc1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2023
31e6858
Fix for integration tests
utkarsharma2 Jul 27, 2023
d1d8f89
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2023
bdded87
Set start_date explicitly
utkarsharma2 Jul 27, 2023
0e61078
Remove pin
utkarsharma2 Jul 27, 2023
31b9461
Remove pin
utkarsharma2 Jul 27, 2023
348e5da
Using PyYAML<=5.3.1
utkarsharma2 Jul 27, 2023
bea4311
Add importError in exception
utkarsharma2 Jul 28, 2023
686a6de
Testing CI Fix
utkarsharma2 Jul 28, 2023
ed0aa9d
Remove PyYaml
utkarsharma2 Jul 28, 2023
d663743
Fix CI
utkarsharma2 Jul 28, 2023
44556b5
Fix CI
utkarsharma2 Jul 28, 2023
86b8afc
Try PyYAML==6.0.1
utkarsharma2 Jul 31, 2023
9e337e2
Remove apache-airflow-providers-mysql temp
utkarsharma2 Jul 31, 2023
2c8cf2a
Remove apache-airflow-providers-microsoft-mssql
utkarsharma2 Jul 31, 2023
74e2cd8
Change constrain
utkarsharma2 Jul 31, 2023
31b6364
Update constraint file
utkarsharma2 Jul 31, 2023
9ab44dd
Add apache-airflow-providers-microsoft-mssql back
utkarsharma2 Jul 31, 2023
b878d88
Add packages to install in OS
utkarsharma2 Jul 31, 2023
a6e73e7
Add packages to install in OS
utkarsharma2 Jul 31, 2023
5977728
Add back the PyYAML
utkarsharma2 Jul 31, 2023
81d86fb
Add constrain file for installation of airflow 2.6.3
utkarsharma2 Jul 31, 2023
1e6c361
Add constrain file
utkarsharma2 Jul 31, 2023
9033e73
Fix constraint for unit test
utkarsharma2 Jul 31, 2023
1bb5532
Fix constraint file
utkarsharma2 Jul 31, 2023
23f1d35
Fix CI
utkarsharma2 Jul 31, 2023
fe4220f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2023
c62e1dd
Fix CI
utkarsharma2 Jul 31, 2023
1d2f059
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 31, 2023
43086a0
Fix CI
utkarsharma2 Jul 31, 2023
4cdfed3
Fix CI
utkarsharma2 Jul 31, 2023
288e058
Add pandas_gbq>=0.15.0
utkarsharma2 Jul 31, 2023
b17aa82
Add all python versions backs
utkarsharma2 Jul 31, 2023
e0f5bd8
Fix tests
utkarsharma2 Aug 1, 2023
4e4c297
Fix tests
utkarsharma2 Aug 2, 2023
363e4b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2023
dc0f06b
Update constraint file
utkarsharma2 Aug 2, 2023
d869363
Fix test
utkarsharma2 Aug 2, 2023
cb4db68
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2023
3c57806
Fix tests
utkarsharma2 Aug 2, 2023
2223480
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2023
e3c7e96
Fix tests
utkarsharma2 Aug 2, 2023
a478bc4
Fix tests
utkarsharma2 Aug 2, 2023
b6f1b48
Fix tests
utkarsharma2 Aug 2, 2023
67ff81d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2023
d97ffe8
Fix tests
utkarsharma2 Aug 2, 2023
2d89b1a
Fix tests
utkarsharma2 Aug 2, 2023
743ae18
Fix tests
utkarsharma2 Aug 2, 2023
8dcffe1
Fix tests
utkarsharma2 Aug 2, 2023
bbea698
Fix tests
utkarsharma2 Aug 2, 2023
c8815a9
Fix tests
utkarsharma2 Aug 2, 2023
3d2c0a4
Fix tests
utkarsharma2 Aug 2, 2023
9f07b8f
Fix test
utkarsharma2 Aug 2, 2023
9474928
Fix test
utkarsharma2 Aug 2, 2023
3d859ee
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2023
449cd15
Fix tests
utkarsharma2 Aug 2, 2023
c5cbf28
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 2, 2023
a5c2809
Fix tests
utkarsharma2 Aug 2, 2023
6379971
Fix tests
utkarsharma2 Aug 2, 2023
0504d0b
Fix tests
utkarsharma2 Aug 2, 2023
8080a20
Fix tests
utkarsharma2 Aug 2, 2023
4b88efa
Fix CI
utkarsharma2 Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions .github/workflows/ci-python-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ jobs:
~/.cache/pip
.nox
key: ${{ runner.os }}-${{ hashFiles('python-sdk/pyproject.toml') }}-${{ hashFiles('python-sdk/src/astro/__init__.py') }}
- run: sudo apt-get install -y --no-install-recommends build-essential libsasl2-2 libsasl2-dev libsasl2-modules freetds-dev libssl-dev libkrb5-dev libmariadb-dev
- run: pip --version
- run: cat ../.github/ci-test-connections.yaml > test-connections.yaml
- run: python -c 'import os; print(os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON", "").strip())' > ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
- run: sqlite3 /tmp/sqlite_default.db "VACUUM;"
Expand All @@ -203,10 +205,10 @@ jobs:
AZURE_WASB_CONN_STRING: ${{ secrets.AZURE_WASB_CONN_STRING }}
AZURE_WASB_ACCESS_KEY: ${{ secrets.AZURE_WASB_ACCESS_KEY }}

Run-Unit-tests-Airflow-2-5:
Run-Unit-tests-Airflow-2-6:
strategy:
matrix:
version: [ '3.8', '3.9', '3.10' ]
version: [ '3.8', '3.9', '3.10', '3.11' ]
if: >-
github.event_name == 'push' ||
(
Expand Down Expand Up @@ -240,9 +242,13 @@ jobs:
~/.cache/pip
.nox
key: ${{ runner.os }}-2.5-${{ hashFiles('python-sdk/pyproject.toml') }}-${{ hashFiles('python-sdk/src/astro/__init__.py') }}
- run: sudo apt-get install -y --no-install-recommends build-essential libsasl2-2 libsasl2-dev libsasl2-modules freetds-dev libssl-dev libkrb5-dev libmariadb-dev
- run: sudo add-apt-repository "deb http://dl.bintray.com/apache/arrow/ubuntu $(lsb_release --codename --short) main" |
sudo apt-get install libarrow-dev libparquet-dev libarrow-python-dev
- run: pip3 --version
- run: sqlite3 /tmp/sqlite_default.db "VACUUM;"
- run: pip3 install nox
- run: nox -s "test-${{ matrix.version }}(airflow='2.6.0')" -- tests/ --cov=src --cov-report=xml --cov-branch
- run: nox -s "test-${{ matrix.version }}(airflow='2.6.3')" -- tests/ --cov=src --cov-report=xml --cov-branch
- name: Upload coverage
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -315,11 +321,12 @@ jobs:
~/.cache/pip
.nox
key: ${{ runner.os }}-2.5-${{ hashFiles('python-sdk/pyproject.toml') }}-${{ hashFiles('python-sdk/src/astro/__init__.py') }}
- run: sudo apt-get install -y --no-install-recommends build-essential libsasl2-2 libsasl2-dev libsasl2-modules freetds-dev libssl-dev libkrb5-dev libmariadb-dev
- run: cat ../.github/ci-test-connections.yaml > test-connections.yaml
- run: python -c 'import os; print(os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON", "").strip())' > ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
- run: sqlite3 /tmp/sqlite_default.db "VACUUM;"
- run: pip3 install nox
- run: nox -s "test-3.8(airflow='2.6.0')" -- tests_integration/ -k "test_load_file.py and not redshift" --splits 3 --group ${{ matrix.group }} --store-durations --durations-path /tmp/durations-${{ matrix.group }} --cov=src --cov-report=xml --cov-branch
- run: nox -s "test-3.8(airflow='2.6.3')" -- tests_integration/ -k "test_load_file.py and not redshift" --splits 3 --group ${{ matrix.group }} --store-durations --durations-path /tmp/durations-${{ matrix.group }} --cov=src --cov-report=xml --cov-branch
- run: cat /tmp/durations-${{ matrix.group }}
- name: Upload coverage
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -411,11 +418,12 @@ jobs:
~/.cache/pip
.nox
key: ${{ runner.os }}-2.5-${{ hashFiles('python-sdk/pyproject.toml') }}-${{ hashFiles('python-sdk/src/astro/__init__.py') }}
- run: sudo apt-get install -y --no-install-recommends build-essential libsasl2-2 libsasl2-dev libsasl2-modules freetds-dev libssl-dev libkrb5-dev libmariadb-dev
- run: cat ../.github/ci-test-connections.yaml > test-connections.yaml
- run: python -c 'import os; print(os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON", "").strip())' > ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
- run: sqlite3 /tmp/sqlite_default.db "VACUUM;"
- run: pip3 install nox
- run: nox -s "test-3.8(airflow='2.6.0')" -- tests_integration/ -k "test_example_dags.py and not redshift" --splits 3 --group ${{ matrix.group }} --store-durations --durations-path /tmp/durations-${{ matrix.group }} --cov=src --cov-report=xml --cov-branch
- run: nox -s "test-3.8(airflow='2.6.3')" -- tests_integration/ -k "test_example_dags.py and not redshift" --splits 3 --group ${{ matrix.group }} --store-durations --durations-path /tmp/durations-${{ matrix.group }} --cov=src --cov-report=xml --cov-branch
- run: cat /tmp/durations-${{ matrix.group }}
- name: Upload coverage
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -507,11 +515,12 @@ jobs:
~/.cache/pip
.nox
key: ${{ runner.os }}-2.5-${{ hashFiles('python-sdk/pyproject.toml') }}-${{ hashFiles('python-sdk/src/astro/__init__.py') }}
- run: sudo apt-get install -y --no-install-recommends build-essential libsasl2-2 libsasl2-dev libsasl2-modules freetds-dev libssl-dev libkrb5-dev libmariadb-dev
- run: cat ../.github/ci-test-connections.yaml > test-connections.yaml
- run: python -c 'import os; print(os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON", "").strip())' > ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
- run: sqlite3 /tmp/sqlite_default.db "VACUUM;"
- run: pip3 install nox
- run: nox -s "test-3.8(airflow='2.6.0')" -- tests_integration/ -k "not test_load_file.py and not test_example_dags.py and not redshift" --splits 11 --group ${{ matrix.group }} --store-durations --durations-path /tmp/durations-${{ matrix.group }} --cov=src --cov-report=xml --cov-branch
- run: nox -s "test-3.8(airflow='2.6.3')" -- tests_integration/ -k "not test_load_file.py and not test_example_dags.py and not redshift" --splits 11 --group ${{ matrix.group }} --store-durations --durations-path /tmp/durations-${{ matrix.group }} --cov=src --cov-report=xml --cov-branch
- run: cat /tmp/durations-${{ matrix.group }}
- name: Upload coverage
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -601,6 +610,7 @@ jobs:
~/.cache/pip
.nox
key: ${{ runner.os }}-2.2.5-${{ hashFiles('python-sdk/pyproject.toml') }}-${{ hashFiles('python-sdk/src/astro/__init__.py') }}
- run: sudo apt-get install -y --no-install-recommends build-essential libsasl2-2 libsasl2-dev libsasl2-modules freetds-dev libssl-dev libkrb5-dev libmariadb-dev
- run: cat ../.github/ci-test-connections.yaml > test-connections.yaml
- run: python -c 'import os; print(os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON", "").strip())' > ${{ env.GOOGLE_APPLICATION_CREDENTIALS }}
- run: sqlite3 /tmp/sqlite_default.db "VACUUM;"
Expand All @@ -627,7 +637,7 @@ jobs:
fail-fast: false
matrix:
python: [ '3.7', '3.8', '3.9', '3.10' ]
airflow: [ '2.2.5', '2.3.4', '2.4.2', '2.5.3', '2.6.0']
airflow: [ '2.2.5', '2.3.4', '2.4.2', '2.5.3', '2.6.3']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -643,6 +653,7 @@ jobs:
with:
path: ${{ steps.pip-cache.outputs.pip_cache_dir }}
key: constraints-${{ matrix.python }}-${{ matrix.airflow }}-${{ hashFiles('python-sdk/pyproject.toml') }}-${{ hashFiles('python-sdk/src/astro/__init__.py') }}
- run: sudo apt-get install -y --no-install-recommends build-essential libsasl2-2 libsasl2-dev libsasl2-modules freetds-dev libssl-dev libkrb5-dev libmariadb-dev
- run: pip3 install -U pip wheel build nox
- run: nox -s build
- run: pip3 install 'apache-airflow==${{ matrix.airflow }}' "$(ls dist/*.whl)[all]"
Expand All @@ -658,7 +669,7 @@ jobs:
Code-Coverage:
if: github.event.action != 'labeled'
needs:
- Run-Unit-tests-Airflow-2-5
- Run-Unit-tests-Airflow-2-6
- Run-Integration-tests-Airflow-2-5
- Run-load-file-Integration-Airflow-2-5
- Run-example-dag-Integration-Airflow-2-5
Expand Down Expand Up @@ -693,7 +704,7 @@ jobs:
collect-durations:
runs-on: ubuntu-latest
needs:
- Run-Unit-tests-Airflow-2-5
- Run-Unit-tests-Airflow-2-6
- Run-Integration-tests-Airflow-2-5
- Run-load-file-Integration-Airflow-2-5
steps:
Expand Down Expand Up @@ -723,7 +734,7 @@ jobs:
if: github.event_name == 'release'
name: Build and publish Python 🐍 distributions 📦 to PyPI
needs:
- Run-Unit-tests-Airflow-2-5
- Run-Unit-tests-Airflow-2-6
- Run-example-dag-tests-Airflow-2-2-5
- Run-Integration-tests-Airflow-2-5
- Run-load-file-Integration-Airflow-2-5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def top_movies_by_genre(input_df: pd.DataFrame):
)
movies_by_genre = top_movies_by_genre(input_df=imdb_movies)
with tempfile.NamedTemporaryFile(suffix=".csv") as tmp_file:
ExportToFileOperator.partial(output_file=File(path=tmp_file.name), task_id="export_movies").expand(
input_data=movies_by_genre
)
ExportToFileOperator.partial(
if_exists="replace", output_file=File(path=tmp_file.name), task_id="export_movies"
).expand(input_data=movies_by_genre)
28 changes: 23 additions & 5 deletions python-sdk/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def dev(session: nox.Session) -> None:
session.install("-e", ".[all,tests]")


@nox.session(python=["3.7", "3.8", "3.9", "3.10"])
@nox.parametrize("airflow", ["2.2.5", "2.4", "2.5.3", "2.6.0"])
@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"])
@nox.parametrize("airflow", ["2.2.5", "2.4", "2.5.3", "2.6.3"])
def test(session: nox.Session, airflow) -> None:
"""Run both unit and integration tests."""
env = {
Expand All @@ -37,11 +37,29 @@ def test(session: nox.Session, airflow) -> None:
# update the constraints file used below with that version of provider
# For example as part of MSSQL support we need apache-airflow-providers-microsoft-mssql>=3.2 and this
# has been updated in the below constraint file.
session.install(f"apache-airflow=={airflow}", "-c", "tests/modified_constraint_file.txt")
session.install("-e", ".[all,tests]", "-c", "tests/modified_constraint_file.txt")
session.install(f"apache-airflow=={airflow}", "-c", "tests/modified_constraint_file_2.2.5.txt")
session.install("-e", ".[all,tests]", "-c", "tests/modified_constraint_file_2.2.5.txt")
session.install("apache-airflow-providers-common-sql==1.2.0")
# install smart-open 6.3.0 since it has FTP implementation
session.install("smart-open>=6.3.0")
elif airflow == "2.6.3":
env["AIRFLOW__CORE__ALLOWED_DESERIALIZATION_CLASSES"] = "airflow\\.* astro\\.*"

session.install(
f"apache-airflow=={airflow}",
"-c",
f"tests/modified_constraint_file_2.6.3-python-{session.python}.txt",
)
if session.python == "3.11":
session.install(
"-e",
".[all,tests]",
"-c",
f"tests/modified_constraint_file_2.6.3-python-{session.python}.txt",
)
else:
session.install("-e", ".[all,tests]")

else:
env["AIRFLOW__CORE__ALLOWED_DESERIALIZATION_CLASSES"] = "airflow\\.* astro\\.*"

Expand Down Expand Up @@ -151,7 +169,7 @@ def build_docs(session: nox.Session) -> None:


@nox.session(python=["3.7", "3.8", "3.9", "3.10"])
@nox.parametrize("airflow", ["2.2.5", "2.3.4", "2.4.2", "2.5.3", "2.6.0"])
@nox.parametrize("airflow", ["2.2.5", "2.3.4", "2.4.2", "2.5.3", "2.6.3"])
def generate_constraints(session: nox.Session, airflow) -> None:
"""Generate constraints file"""
session.install("wheel")
Expand Down
13 changes: 7 additions & 6 deletions python-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ license = { file = "LICENSE" }

requires-python = ">=3.7"
dependencies = [
"apache-airflow>=2.0",
"apache-airflow==2.6.3",
"attrs>=20.0",
"pandas>=1.3.4,<2.0.0", # Pinning it to <2.0.0 to avoid breaking changes
"pyarrow",
"pydantic>=1.10.0,<2.0.0", # Airflow & Pydantic issue: https://github.com/apache/airflow/issues/32311
"python-frontmatter",
"smart-open",
"SQLAlchemy>=1.3.18",
"cached_property>=1.5.0;python_version<='3.7'"
"cached_property>=1.5.0;python_version<='3.7'",
#"pandas_gbq>=0.15.0"
]

keywords = ["airflow", "provider", "astronomer", "sql", "decorator", "task flow", "elt", "etl", "dag"]
Expand Down Expand Up @@ -55,15 +56,15 @@ tests = [
"sqlalchemy-stubs", # Change when sqlalchemy is upgraded https://docs.sqlalchemy.org/en/14/orm/extensions/mypy.html
]
google = [
"protobuf<=3.20", # Google bigquery client require protobuf <= 3.20.0. We can remove the limitation when this limitation is removed
#"protobuf<=3.20", # Google bigquery client require protobuf <= 3.20.0. We can remove the limitation when this limitation is removed
"apache-airflow-providers-google>=6.4.0",
"sqlalchemy-bigquery>=1.3.0",
"smart-open[gcs]>=5.2.1"
]
snowflake = [
"apache-airflow-providers-snowflake",
"snowflake-sqlalchemy>=1.2.0",
"snowflake-connector-python[pandas]<3.0.0",
"snowflake-connector-python[pandas]",
# pinning snowflake-connector-python[pandas]<3.0.0 due to a conflict in snowflake-connector-python/pyarrow/google
# packages and pandas-gbq/google packages which is forcing pandas-gbq of version 0.13.2 installed, which is not
# compatible with pandas 1.5.3
Expand Down Expand Up @@ -114,7 +115,7 @@ all = [
"apache-airflow-providers-snowflake",
"apache-airflow-providers-sftp",
"smart-open[all]>=5.2.1",
"snowflake-connector-python[pandas]<3.0.0",
"snowflake-connector-python[pandas]",
# pinning snowflake-connector-python[pandas]<3.0.0 due to a conflict in snowflake-connector-python/pyarrow/google
# packages and pandas-gbq/google packages which is forcing pandas-gbq of version 0.13.2 installed, which is not
# compatible with pandas 1.5.3
Expand All @@ -123,7 +124,7 @@ all = [
"databricks-cli",
"apache-airflow-providers-databricks",
"s3fs",
"protobuf<=3.20", # Google bigquery client require protobuf <= 3.20.0. We can remove the limitation when this limitation is removed
#"protobuf<=3.20", # Google bigquery client require protobuf <= 3.20.0. We can remove the limitation when this limitation is removed
"openlineage-airflow>=0.17.0",
"apache-airflow-providers-microsoft-azure",
"azure-storage-blob",
Expand Down
2 changes: 2 additions & 0 deletions python-sdk/src/astro/sql/operators/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def _get_executor_from_job_id(job_id: int) -> str | None:

with create_session() as session:
job = session.get(Job, job_id)
if job.executor_class is None and job.executor:
return type(job.executor).__name__
return job.executor_class if job else None

def get_all_task_outputs(self, context: Context) -> list[BaseTable]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ PyGithub==1.54.1
PyHive==0.6.5
PyJWT==1.7.1
PyNaCl==1.5.0
PyYAML==5.4.1
PyYAML==5.3.1
Pygments==2.11.2
Rx==3.2.0
SQLAlchemy-JSONField==1.0.0
Expand Down
Loading
Loading