Skip to content

Commit

Permalink
Snow 1058245 SqlAlchemy 2.0 support (#469)
Browse files Browse the repository at this point in the history
SNOW-1058245-sqlalchemy-20-support: Add support for installation SQLAlchemy 2.0
  • Loading branch information
sfc-gh-mraba authored Jul 2, 2024
1 parent 58fb1bd commit d78f0c0
Show file tree
Hide file tree
Showing 30 changed files with 558 additions and 217 deletions.
108 changes: 75 additions & 33 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
python-version: '3.8'
- name: Upgrade and install tools
run: |
python -m pip install -U pip
python -m pip install -U hatch
python -m pip install -U uv
python -m uv pip install -U hatch
python -m hatch env create default
- name: Set PY
run: echo "PY=$(hatch run gh-cache-sum)" >> $GITHUB_ENV
Expand All @@ -49,6 +49,10 @@ jobs:
name: Test package build and installation
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: true
matrix:
hatch-env: [default, sa20]
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -59,15 +63,14 @@ jobs:
python-version: '3.8'
- name: Upgrade and install tools
run: |
python -m pip install -U pip
python -m pip install -U hatch
python -m pip install -U uv
python -m uv pip install -U hatch
- name: Build package
run: |
python -m hatch clean
python -m hatch build
python -m hatch -e ${{ matrix.hatch-env }} build --clean
- name: Install and check import
run: |
python -m pip install dist/snowflake_sqlalchemy-*.whl
python -m uv pip install dist/snowflake_sqlalchemy-*.whl
python -c "import snowflake.sqlalchemy; print(snowflake.sqlalchemy.__version__)"
test-dialect:
Expand All @@ -79,7 +82,7 @@ jobs:
matrix:
os: [
ubuntu-latest,
macos-latest,
macos-13,
windows-latest,
]
python-version: ["3.8"]
Expand All @@ -98,8 +101,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and prepare environment
run: |
python -m pip install -U pip
python -m pip install -U hatch
python -m pip install -U uv
python -m uv pip install -U hatch
python -m hatch env create default
- name: Setup parameters file
shell: bash
Expand All @@ -125,7 +128,7 @@ jobs:
matrix:
os: [
ubuntu-latest,
macos-latest,
macos-13,
windows-latest,
]
python-version: ["3.8"]
Expand All @@ -144,8 +147,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and install hatch
run: |
python -m pip install -U pip
python -m pip install -U hatch
python -m pip install -U uv
python -m uv pip install -U hatch
python -m hatch env create default
- name: Setup parameters file
shell: bash
Expand All @@ -162,16 +165,16 @@ jobs:
path: |
./coverage.xml
test-dialect-run-v20:
name: Test dialect run v20 ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
test-dialect-v20:
name: Test dialect v20 ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
needs: [ lint, build-install ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
ubuntu-latest,
macos-latest,
macos-13,
windows-latest,
]
python-version: ["3.8"]
Expand All @@ -197,21 +200,67 @@ jobs:
.github/workflows/parameters/parameters_${{ matrix.cloud-provider }}.py.gpg > tests/parameters.py
- name: Upgrade pip and install hatch
run: |
python -m pip install -U pip
python -m pip install -U hatch
python -m pip install -U uv
python -m uv pip install -U hatch
python -m hatch env create default
- name: Run tests
run: hatch run test-run_v20
run: hatch run sa20:test-dialect
- uses: actions/upload-artifact@v4
with:
name: coverage.xml_dialect-run-20-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
name: coverage.xml_dialect-v20-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
path: |
./coverage.xml
test-dialect-compatibility-v20:
name: Test dialect v20 compatibility ${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
needs: lint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [
ubuntu-latest,
macos-13,
windows-latest,
]
python-version: ["3.8"]
cloud-provider: [
aws,
azure,
gcp,
]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip and install hatch
run: |
python -m pip install -U uv
python -m uv pip install -U hatch
python -m hatch env create default
- name: Setup parameters file
shell: bash
env:
PARAMETERS_SECRET: ${{ secrets.PARAMETERS_SECRET }}
run: |
gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETERS_SECRET" \
.github/workflows/parameters/parameters_${{ matrix.cloud-provider }}.py.gpg > tests/parameters.py
- name: Run tests
run: hatch run sa20:test-dialect-compatibility
- uses: actions/upload-artifact@v4
with:
name: coverage.xml_dialect-v20-compatibility-${{ matrix.os }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
path: |
./coverage.xml
combine-coverage:
name: Combine coverage
if: ${{ success() || failure() }}
needs: [test-dialect, test-dialect-compatibility, test-dialect-run-v20]
needs: [test-dialect, test-dialect-compatibility, test-dialect-v20, test-dialect-compatibility-v20]
runs-on: ubuntu-latest
steps:
- name: Set up Python
Expand All @@ -220,8 +269,8 @@ jobs:
python-version: "3.8"
- name: Prepare environment
run: |
pip install -U pip
pip install -U hatch
python -m pip install -U uv
python -m uv pip install -U hatch
hatch env create default
- uses: actions/checkout@v4
with:
Expand All @@ -233,22 +282,15 @@ jobs:
run: |
hatch run coverage combine -a artifacts/coverage.xml_*/coverage.xml
hatch run coverage report -m
hatch run coverage xml -o combined_coverage.xml
hatch run coverage html -d htmlcov
- name: Store coverage reports
uses: actions/upload-artifact@v4
with:
name: combined_coverage.xml
path: combined_coverage.xml
- name: Store htmlcov report
uses: actions/upload-artifact@v4
with:
name: combined_htmlcov
path: htmlcov
name: coverage.xml
path: coverage.xml
- name: Uplaod to codecov
uses: codecov/codecov-action@v4
with:
file: combined_coverage.xml
file: coverage.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
flags: unittests
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/create_req_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Upgrade setuptools, pip and wheel
run: python -m pip install -U setuptools pip wheel
run: python -m pip install -U setuptools pip wheel uv
- name: Install Snowflake SQLAlchemy
shell: bash
run: python -m pip install .
run: python -m uv pip install .
- name: Generate reqs file name
shell: bash
run: echo "requirements_file=temp_requirement/requirements_$(python -c 'from sys import version_info;print(str(version_info.major)+str(version_info.minor))').reqs" >> $GITHUB_ENV
Expand All @@ -34,7 +34,7 @@ jobs:
mkdir temp_requirement
echo "# Generated on: $(python --version)" >${{ env.requirements_file }}
python -m pip freeze | grep -v snowflake-sqlalchemy 1>>${{ env.requirements_file }} 2>/dev/null
echo "snowflake-sqlalchemy==$(python -m pip show snowflake-sqlalchemy | grep ^Version | cut -d' ' -f2-)" >>${{ env.requirements_file }}
echo "snowflake-sqlalchemy==$(python -m uv pip show snowflake-sqlalchemy | grep ^Version | cut -d' ' -f2-)" >>${{ env.requirements_file }}
id: create-reqs-file
- name: Show created req file
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jira_close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
token: ${{ secrets.SNOWFLAKE_GITHUB_TOKEN }} # stored in GitHub secrets
path: .
- name: Jira login
uses: atlassian/gajira-login@master
uses: atlassian/gajira-login@v3
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/jira_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Jira login
uses: atlassian/gajira-login@master
uses: atlassian/gajira-login@v3
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
Expand All @@ -22,7 +22,7 @@ jobs:
jira=$(echo -n $TITLE | awk '{print $1}' | sed -e 's/://')
echo ::set-output name=jira::$jira
- name: Comment on issue
uses: atlassian/gajira-comment@master
uses: atlassian/gajira-comment@v3
if: startsWith(steps.extract.outputs.jira, 'SNOW-')
with:
issue: "${{ steps.extract.outputs.jira }}"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/jira_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
path: .

- name: Login
uses: atlassian/gajira-login@v2.0.0
uses: atlassian/gajira-login@v3
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

- name: Create JIRA Ticket
id: create
uses: atlassian/gajira-create@v2.0.1
uses: atlassian/gajira-create@v3
with:
project: SNOW
issuetype: Bug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@e53eb8b103ffcb59469888563dc324e3c8ba6f06
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/stale_issue_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v7
- uses: actions/stale@v9
with:
close-issue-message: 'To clean up and re-prioritize bugs and feature requests we are closing all issues older than 6 months as of Apr 1, 2023. If there are any issues or feature requests that you would like us to address, please re-create them. For urgent issues, opening a support case with this link [Snowflake Community](https://community.snowflake.com/s/article/How-To-Submit-a-Support-Case-in-Snowflake-Lodge) is the fastest way to get a response'
days-before-issue-stale: ${{ inputs.staleDays }}
Expand Down
6 changes: 5 additions & 1 deletion DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ Source code is also available at:

# Release Notes

- v1.6.0(Not released)

- support for installing with SQLAlchemy 2.0.x

- v1.5.4

- Add ability to set ORDER / NOORDER sequence on columns with IDENTITY

- v1.5.3(April 16, 2024)

- Limit SQLAlchemy to < 2.0.0 before releasing version compatible with 2.0
- Limit SQLAlchemy to < 2.0.0 before releasing version compatible with 2.0

- v1.5.2(April 11, 2024)

Expand Down
14 changes: 10 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = ["SQLAlchemy>=1.4.19,<2.0.0", "snowflake-connector-python<4.0.0"]
dependencies = ["SQLAlchemy>=1.4.19", "snowflake-connector-python<4.0.0"]

[tool.hatch.version]
path = "src/snowflake/sqlalchemy/version.py"
Expand Down Expand Up @@ -73,19 +73,25 @@ exclude = ["/.github"]
packages = ["src/snowflake"]

[tool.hatch.envs.default]
extra-dependencies = ["SQLAlchemy>=1.4.19,<2.0.0"]
features = ["development", "pandas"]
python = "3.8"
installer = "uv"

[tool.hatch.envs.sa20]
extra-dependencies = ["SQLAlchemy>=1.4.19,<=2.1.0"]
python = "3.8"

[tool.hatch.envs.default.env-vars]
COVERAGE_FILE = "coverage.xml"
SQLACHEMY_WARN_20 = "1"

[tool.hatch.envs.default.scripts]
check = "pre-commit run --all-files"
test-dialect = "pytest -ra -vvv --tb=short --cov snowflake.sqlalchemy --cov-append --junitxml ./junit.xml --ignore=tests/sqlalchemy_test_suite"
test-dialect-compatibility = "pytest -ra -vvv --tb=short --cov snowflake.sqlalchemy --cov-append --junitxml ./junit.xml tests/sqlalchemy_test_suite"
test-run_v20 = "pytest -ra -vvv --tb=short --cov snowflake.sqlalchemy --cov-append --junitxml ./junit.xml --ignore=tests/sqlalchemy_test_suite --run_v20_sqlalchemy"
test-dialect = "pytest -ra -vvv --tb=short --cov snowflake.sqlalchemy --cov-append --junitxml ./junit.xml --ignore=tests/sqlalchemy_test_suite tests/"
test-dialect-compatibility = "pytest -ra -vvv --tb=short --cov snowflake.sqlalchemy --cov-append --junitxml ./junit.xml tests/sqlalchemy_test_suite tests/"
gh-cache-sum = "python -VV | sha256sum | cut -d' ' -f1"
check-import = "python -c 'import snowflake.sqlalchemy; print(snowflake.sqlalchemy.__version__)'"

[tool.ruff]
line-length = 88
Expand Down
2 changes: 1 addition & 1 deletion snyk/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SQLAlchemy>=1.4.19,<2.0.0
SQLAlchemy>=1.4.19
snowflake-connector-python<4.0.0
2 changes: 2 additions & 0 deletions snyk/requiremtnts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
snowflake-connector-python<4.0.0
SQLAlchemy>=1.4.19,<2.1.0
Loading

0 comments on commit d78f0c0

Please sign in to comment.