3.1.0-alpha: requirements.txt pulls in Prefect 3 (SQLAlchemy>=2.0), conflicts with CKAN 2.10.3 SQLAlchemy 1.4.x

Đang mở
#329 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python, sqlalchemy
Lĩnh vực
backend, build-system

Hướng nghiên cứu

The conflict comes from requirements.txt (the prefect>=3.7,<3.8 line) and from pyproject.toml, which reads dependencies from that file. Start by checking whether the plugin import chain in plugin.py and cli.py really avoids prefect and SQLAlchemy 2.0, as the report claims. Done means a pip install -e . into a venv pinned to CKAN 2.10.3 keeps sqlalchemy at 1.4.x and the ckan CLI starts. Splitting prefect into an optional extra is the likely fix, but confirm the design with maintainers first.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

Installing DataPusher+ 3.1.0-alpha into a CKAN venv per the README's "install as a CKAN extension" instructions upgrades SQLAlchemy to 2.x (pulled in transitively by prefect>=3.7,<3.8). This breaks CKAN core, since ckan/model/tag.py still does from sqlalchemy.orm import relation — relation was a deprecated alias for relationship() in SQLAlchemy 1.x and was removed in 2.0.
Environment

CKAN 2.10.3 (pins sqlalchemy[mypy]==1.4.41)
Python 3.10
DataPusher+ installed via:

pip3 install -e 'git+https://github.com/dathere/[email protected]#egg=datapusher-plus'
pip3 install -r 'https://raw.githubusercontent.com/dathere/datapusher-plus/3.1.0-alpha/requirements.txt'

into CKAN's existing venv (/usr/lib/ckan/default), as documented.
Steps to Reproduce

Set up CKAN 2.10.3 in a venv (SQLAlchemy 1.4.41 installed as part of CKAN's own requirements).
Install DataPusher+ 3.1.0-alpha and its requirements.txt into that same venv.
Run any ckan CLI command, e.g. ckan -c /etc/ckan/default/ckan.ini run.

Expected behavior

CKAN CLI starts normally; DataPusher+ is available as a CKAN plugin alongside it.
Actual behavior

Traceback (most recent call last):
  File "/usr/lib/ckan/default/bin/ckan", line 3, in <module>
    from ckan.cli.cli import ckan
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/ckan/cli/cli.py", line 12, in <module>
    import ckan.plugins as p
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/ckan/plugins/__init__.py", line 3, in <module>
    from ckan.plugins.core import *  # noqa: re-export
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/ckan/plugins/core.py", line 21, in <module>
    import ckan.plugins.interfaces as interfaces
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/ckan/plugins/interfaces.py", line 17, in <module>
    from ckan.model.user import User
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/ckan/model/__init__.py", line 31, in <module>
    from ckan.model.package import (
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/ckan/model/package.py", line 492, in <module>
    from ckan.model import tag
  File "/usr/lib/ckan/default/lib/python3.10/site-packages/ckan/model/tag.py", line 6, in <module>
    from sqlalchemy.orm import relation
ImportError: cannot import name 'relation' from 'sqlalchemy.orm'

Root Cause

requirements.txt for 3.1.0-alpha includes:

prefect>=3.7,<3.8

Prefect 3.7.x requires sqlalchemy[asyncio]>=2.0,<3.0 (per PyPI metadata). When this is installed into a CKAN venv, pip upgrades SQLAlchemy from CKAN's pinned 1.4.x (1.4.41 on 2.10.3) to a 2.x release to satisfy Prefect's constraint.

CKAN core ( 2.10.x ) still relies on the SQLAlchemy 1.x relation alias in ckan/model/tag.py, which doesn't exist in SQLAlchemy 2.0. So any CKAN install with DP+ 3.1.0-alpha's full requirements.txt applied in the same environment is currently broken at the ckan CLI level — independent of CKAN version.
Workaround (proposed based on source inspection — needs verification)

Traced the import chain in the 3.1.0-alpha source: plugin.py imports cli.py at module load, but cli.py's prefect/prefect_client imports are all inside command function bodies (prefect_deploy, the worker-status check) — never executed at plugin-registration time (get_commands() just returns [datapusher_plus]). None of plugin.py's other imports (views, helpers, logic.action, logic.auth, config) touch prefect or SQLAlchemy 2.0. So the CKAN-plugin half of DP+ doesn't itself need SQLAlchemy 2.0 — only prefect-deploy / the worker side does.

The catch is that pyproject.tomldeclares dependencies = { file = ["requirements.txt"] } (via dynamic = ["dependencies", ...]), so even pip install -e . pulls in prefect → SQLAlchemy 2.0.

Ngôn ngữ chính
Python
Star
47
Fork
33
Merge trung bình
2 giờ 28 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dathere/datapusher-plus

Tất cả issue của dathere/datapusher-plus

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.