Skip to content

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

@a5dur

Description

@a5dur

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/datapusher-plus.git@3.1.0-alpha#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions