Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
82f8db0
update .gitignore
stankudrow May 30, 2025
8fc4799
add the ref to the Python .gitignore template
stankudrow May 30, 2025
f87e15a
add .python-version
stankudrow May 30, 2025
7cf8d43
groom the main __init__
stankudrow May 30, 2025
1002795
instruct sphinx to read pyproject.toml
stankudrow May 30, 2025
ecfcdaa
remove setup.py
stankudrow May 30, 2025
fd5c5c0
introduce pyproject.toml + uv
stankudrow May 30, 2025
eedcca2
purge the [pytest] section
stankudrow May 30, 2025
d2ab5e7
purge the __version__ module attribute
stankudrow May 30, 2025
e396f61
ruff the enum test modules
stankudrow May 30, 2025
f46065d
set line-length=79 to please flake8 (for now)
stankudrow May 30, 2025
6984863
update GH pull request template file
stankudrow May 30, 2025
8494190
update CHANGELOG -> add the PR #379 record
stankudrow May 30, 2025
d8132cb
replace a comma with a point in the .python-version
stankudrow May 30, 2025
2377f91
update the line about the docs changed
stankudrow May 30, 2025
c85e132
update GHA docs with sphinx-pyproject
stankudrow May 30, 2025
546eb19
SA>=2.0,<2.1
stankudrow Jun 1, 2025
08eb05f
remove flake8 from the PR template
stankudrow Jun 1, 2025
e7df1e6
align dependencies
Oct 31, 2025
122d43e
update alembic_table_reflection + ruff format
Oct 31, 2025
48109bb
skip json test + ruff format
Oct 31, 2025
a036a45
ruff format docs/conf.py
Oct 31, 2025
3328d15
update setup.cfg: specify non-empty password
Oct 31, 2025
103dd32
Revert "update alembic_table_reflection + ruff format"
Oct 31, 2025
b4f8421
get back the alembic table reflector
Oct 31, 2025
6583a83
add uv into the CI
Oct 31, 2025
3774381
update CI
Oct 31, 2025
daf79af
remove E501 error
Oct 31, 2025
27439a7
Revert "skip json test + ruff format"
Oct 31, 2025
8e12fb9
ruff format only soem tests
Oct 31, 2025
0f1b7eb
ruff format ch-sa/__init__.py
Oct 31, 2025
1e679e5
disable file linting (TEMPORARILY, TO BE UNCOMMENTED IN NEXT PRs)
Oct 31, 2025
3706f36
add uv into the SA-version.yaml
Oct 31, 2025
e6c2bbb
update the _alembic_reflect_table (not with the solution from #369)
Nov 1, 2025
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
18 changes: 8 additions & 10 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<!--
Link to relevant issues or previous PRs, one per line. Use "fixes" to
automatically close an issue.
Link to relevant issue(s) or previous PR(s), one per line. Use "fixes" to automatically close the related issue.
-->

- fixes #<issue number>

<!--
Ensure each step in CONTRIBUTING.rst is complete by adding an "x" to
each box below.
Ensure each step in the "CONTRIBUTING.rst" file is completed by adding an "x" inside each box below.

If only docs were changed, these aren't relevant and can be removed.
If only the documentation is changed, the checklist below may be removed.
-->

Checklist:

- [ ] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
- [ ] Add or update relevant docs, in the docs folder and in code.
- [ ] Ensure PR doesn't contain untouched code reformatting: spaces, etc.
- [ ] Run `flake8` and fix issues.
- [ ] Run `pytest` no tests failed. See https://clickhouse-sqlalchemy.readthedocs.io/en/latest/development.html.
- [ ] Add tests demonstrating the correct behavior of the change. All tests should pass.
- [ ] Add/Update relevant docs in the code and in the `docs` directory.
- [ ] Ensure the PR doesn't contain the code non-conformant with project formatting and linting rules.
- [ ] Run `ruff` and fix issues.
- [ ] Run `pytest` no tests failed. See the [development](https://clickhouse-sqlalchemy.readthedocs.io/en/latest/development.html) section.
32 changes: 20 additions & 12 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,45 @@ jobs:
- 8123:8123
- 9000:9000

name: ${{ matrix.python-version }} CH=${{ matrix.clickhouse-version }}
name: "Py=${{ matrix.python-version }}; CH=${{ matrix.clickhouse-version }}"
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install the project
run: uv sync --python ${{ matrix.python-version }} --locked --all-extras --dev
Copy link
Author

Choose a reason for hiding this comment

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

I have to specify this tedious --python {version} flag because uv respects the ".python-version" file and can consult and activate the version specified in it.


# - name: Lint
# run: |
# uv run --python ${{ matrix.python-version }} ruff check
# uv run --python ${{ matrix.python-version }} ruff format --check
Comment on lines +44 to +47
Copy link
Author

Choose a reason for hiding this comment

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

This PR is large enough and if ruff format all files, it'll get much larger, so my proposal is 1) comment these checks TEMPORARILY and make the pipeline pass and 2) the next PRs must be about only ruff format all files or, maybe, one for source-only files and the following for the tests.


- name: Install test requirements
run: |
pip install --upgrade pip setuptools wheel
pip install flake8 flake8-print coverage
python testsrequire.py
python setup.py develop
# Limit each test time execution.
pip install pytest-timeout
- name: Run flake8
run: flake8
uv pip install --python ${{ matrix.python-version }} pytest-timeout
Copy link
Author

Choose a reason for hiding this comment

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

Only this dependency is required, maybe move into the "pyproject.toml" and so be it and no need to dance with it here.


- name: Run tests
run: coverage run --source=clickhouse_sqlalchemy -m pytest --timeout=10 -v
timeout-minutes: 2

- name: Set up Python for coverage submission
if: ${{ matrix.python-version == '2.7' }}
uses: actions/setup-python@v5
with:
python-version: 3.8
architecture: x64
Comment on lines 59 to 63
Copy link
Author

Choose a reason for hiding this comment

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

Hm, is this necessary? This project does not support Python2.7, see the pyproject.toml and setup.py files.


- name: Install coveralls
run: |
# Newer coveralls do not work with github actions.
pip install 'coveralls<3.0.0'
uv pip install --python ${{ matrix.python-version }} "coveralls<3.0.0"

- name: Upload coverage
run: coveralls
env:
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@ on: [push, pull_request]
name: build-docs
jobs:
tests:
runs-on: ubuntu-22.04
name: Build docs
runs-on: ubuntu-22.04
strategy:
matrix:
python-version:
- "3.7"
- "3.12"
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: 3.12
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Update tools
run: pip install --upgrade pip setuptools wheel

- name: Install sphinx
run: pip install sphinx
run: uv sync --python ${{ matrix.python-version }} --group docs

- name: Install package
run: pip install -e .
run: uv pip install --python ${{ matrix.python-version }} -e .

- name: Build docs
run: cd docs && make html
29 changes: 18 additions & 11 deletions .github/workflows/sa-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on: [push, pull_request]
name: "SQLAlchemy >=2.0.0 versions"
jobs:
tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand All @@ -20,21 +20,28 @@ jobs:

name: ${{ matrix.python-version }} SA=2.0.${{ matrix.sa-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install the project
run: uv sync --python ${{ matrix.python-version }} --locked --all-extras --dev

- name: Install test requirements
run: |
pip install --upgrade pip setuptools wheel
python testsrequire.py
python setup.py develop
# Limit each test time execution.
pip install pytest-timeout
- name: Install SQLAlchemy
run: pip install sqlalchemy==2.0.${{ matrix.sa-version }}
uv pip install --python ${{ matrix.python-version }} pytest-timeout

- name: Install SQLAlchemy>=2
run: |
# remove locked SA and then replace with the target version
uv pip uninstall --python ${{ matrix.python-version }} sqlalchemy
uv pip install --python ${{ matrix.python-version }} sqlalchemy==2.0.${{ matrix.sa-version }}

- name: Run tests
run: pytest --timeout=10 -v
run: uv run --python ${{ matrix.python-version }} pytest --timeout=10 -v
timeout-minutes: 2
79 changes: 50 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# https://github.com/github/gitignore/blob/main/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
.idea

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -21,6 +21,8 @@ lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
Expand All @@ -38,56 +40,75 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# celery beat schedule file
celerybeat-schedule
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# uv.lock

# dotenv
.env
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# virtualenv
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# Spyder project settings
.spyderproject
# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the enitre vscode folder
.vscode/

# Rope project settings
.ropeproject
# Ruff stuff:
.ruff_cache/

# PyCharm project settings
.idea/
# PyPI configuration file
.pypirc
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7.9
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@

## [Unreleased]

- Introduce the `pyproject.toml` with [`uv`](https://docs.astral.sh/uv/) project manager. Pull request [#379](https://github.com/xzkostyan/clickhouse-sqlalchemy/pull/379) by [stankudrow](https://github.com/stankudrow). Solves the issue [#345](https://github.com/xzkostyan/clickhouse-sqlalchemy/issues/345). Special thanks to [Daniil Anichin](https://github.com/DaniilAnichin). Features:
- update the ".gitignore" file
- add the "pyproject.toml" file
- backend the project the the uv manager (the uv.lock file added)
- remove the "setup.py" file
- move from the dynamic versioning in favour of an explicit value in the "pyproject.toml" file
- add the `sphinx-pyproject` dependency for parsing metadata from the "pyproject.toml" file

## [0.3.2] - 2024-06-12

### Added

- ``quantile`` and ``quantileIf`` functions. Pull request [#303](https://github.com/xzkostyan/clickhouse-sqlalchemy/pull/303) by [aronbierbaum](https://github.com/aronbierbaum).
- ``AggregateFunction`` and ``SimpleAggregateFunction`` aggregate types. Pull request [#297](https://github.com/xzkostyan/clickhouse-sqlalchemy/pull/297) by [aronbierbaum](https://github.com/aronbierbaum).
- Date32 type. Pull request [#307](https://github.com/xzkostyan/clickhouse-sqlalchemy/pull/307) by [BTheunissen](https://github.com/BTheunissen). Solves issue [#302](https://github.com/xzkostyan/clickhouse-sqlalchemy/issues/302).

### Fixed

- Broken nested Map types. Pull request [#315](https://github.com/xzkostyan/clickhouse-sqlalchemy/pull/315) by [aksenof](https://github.com/aksenof). Solves issue [#314](https://github.com/xzkostyan/clickhouse-sqlalchemy/issues/314).

## [0.3.1] - 2024-03-14
Expand Down
14 changes: 5 additions & 9 deletions clickhouse_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@

from .ext.declarative import get_declarative_base
from .orm.session import make_session
from .sql import Table, MaterializedView, select


VERSION = (0, 3, 2)
__version__ = '.'.join(str(x) for x in VERSION)
Comment on lines -7 to -8
Copy link
Author

Choose a reason for hiding this comment

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

Honestly, I have not found an easier and cheaper way for uv to use dynamic versioning.

This solution - uv-dynamic-versioning - aims to retrieve data from a VCS.

I tried this solution - setuptools-scm - yet it didn't work (an unexpected version_file param or smth).

So, if you can find a better solution which allows the uv manager to support dynamic versioning in a cheap and an easy way, feel free to coautor and propose changes and even commits.



__all__ = (
'get_declarative_base',
'make_session',
'Table', 'MaterializedView', 'select'
"MaterializedView",
"Table",
"get_declarative_base",
"make_session",
"select",
)
Loading