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

オープン
#329 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python, sqlalchemy

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
47
フォーク
33
平均マージ
2時間 28分
マージ済み PR(30日)
10

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dathere/datapusher-plus のほかの issue

dathere/datapusher-plus の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。