Skip to content

Install greenlet via the sqlalchemy[asyncio] extra - #380

Open
anshuly0720 wants to merge 1 commit into
openml:mainfrom
anshuly0720:fix/sqlalchemy-asyncio-extra
Open

anshuly0720 wants to merge 1 commit into
openml:mainfrom
anshuly0720:fix/sqlalchemy-asyncio-extra

Conversation

@anshuly0720

Copy link
Copy Markdown

Description

Fixes: #377

src/database/engine.py uses sqlalchemy.ext.asyncio, which requires greenlet. Since SQLAlchemy 2.1, greenlet is only installed with the asyncio extra, so fresh builds currently install SQLAlchemy 2.1.x without it and the python-api container exits on startup.

This changes the dependency in pyproject.toml from sqlalchemy to sqlalchemy[asyncio]. No code changes.

Verified locally: after rebuilding the image (docker compose up -d --build python-api), the container starts, /docs loads, and pytest -m "not php_api and not slow" passes (303 passed, 1 xfailed). With the PHP API running, tests/routers/task_type_get_test.py also passes (12 passed).

Checklist

Always:

  • I have performed a self-review of my own pull request to ensure it contains all relevant information, and the proposed changes are minimal but sufficient to accomplish their task.

Required for code changes:

  • Tests pass locally
  • I have commented my code in hard-to-understand areas, and provided or updated docstrings as needed (N/A: dependency change only)
  • Changes are already covered under existing tests
  • I have added tests that cover the changes (only required if not already under coverage) (N/A)

If applicable:

  • I have made corresponding changes to the documentation pages (/docs) (N/A)

Extra context:

  • This PR and the commits have been created autonomously by a bot/agent.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The project now declares sqlalchemy[asyncio] instead of sqlalchemy. The linked issue reports that a fresh python-api container fails to start when greenlet is missing from the environment.

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 8d80c

This adds the dependency extra needed for fresh builds to install greenlet, so the python-api container can start. It carries no meaningful merge risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: the dependency is switched to the sqlalchemy[asyncio] extra so greenlet is installed. It matches the single pyproject.toml change and the linked issue about the pytho…
Description check Passed The description explains the cause (engine.py uses sqlalchemy.ext.asyncio, which needs greenlet, and SQLAlchemy 2.1 installs greenlet only with the asyncio extra). It names the pyproject.toml change a…
Linked Issues check Passed Directly linked issue #377 requires the python-api container to start when SQLAlchemy 2.1.x is installed from a fresh build. The issue cites the missing greenlet dependency for sqlalchemy.ext.asyncio,…
Out of Scope Changes check Passed The whole-PR change set is a single-line edit in pyproject.toml, changing the sqlalchemy dependency to sqlalchemy[asyncio]. This edit is the fix that issue #377 proposes. No unrelated files or code ch…
Full details: Title check

Explanation

The title states the main change: the dependency is switched to the sqlalchemy[asyncio] extra so greenlet is installed. It matches the single pyproject.toml change and the linked issue about the python-api container failing at startup. The title is specific and short.

Full details: Description check

Explanation

The description explains the cause (engine.py uses sqlalchemy.ext.asyncio, which needs greenlet, and SQLAlchemy 2.1 installs greenlet only with the asyncio extra). It names the pyproject.toml change and gives local verification steps. It is directly related to the changeset.

Full details: Linked Issues check

Explanation

Directly linked issue #377 requires the python-api container to start when SQLAlchemy 2.1.x is installed from a fresh build. The issue cites the missing greenlet dependency for sqlalchemy.ext.asyncio, and the fix it proposes is changing sqlalchemy to sqlalchemy[asyncio]. The reviewed head pyproject.toml lists sqlalchemy[asyncio] in dependencies, which pulls in greenlet through the asyncio extra and so addresses the root cause. The change is a dependency declaration only, so no code or automated test is required. The author reports a local rebuild that starts the container and passes the test suite. This evidence was not re-run in this review.

Full details: Out of Scope Changes check

Explanation

The whole-PR change set is a single-line edit in pyproject.toml, changing the sqlalchemy dependency to sqlalchemy[asyncio]. This edit is the fix that issue #377 proposes. No unrelated files or code changes are part of the PR. The reviewed head file confirms the declared dependency. The base blob was not read in this review, so the before-state rests on the PR description and the raw summary (+1/-1).

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2cc11eb7-0cca-4bf2-b6cf-1bccb7224c52
Commits

Reviewing files that changed from the base of the PR and between 621da17 and 8d80cc8.

Files selected for processing: 1

  • pyproject.toml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Jayant-kernel

Copy link
Copy Markdown

@anshuly0720
I tested locally at 8d80cc8: the fresh Docker build succeeds, the API starts, and /docs returns 200

Removing greenlet reproduces the original error. The non-PHP, non-slow tests gave 299 passed, 1 xfailed and 4 dataset-filtering failures; those same four also fail with the base source using the same dependencies.
The dependency fix looks good from these checks.

@anshuly0720

Copy link
Copy Markdown
Author

Thanks @Jayant-kernel for testing! Interesting about the 4 dataset-filtering failures: they all passed for me (303 passed, 1 xfailed), so they may depend on the local environment. Since they also fail on main, I'll keep them out of this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python-api container fails to start: greenlet missing with SQLAlchemy 2.1

2 participants