Skip to content

Fix pytest collection errors#17

Merged
mabry1985 merged 1 commit intodevfrom
fix/pytest-collection-errors
Apr 20, 2026
Merged

Fix pytest collection errors#17
mabry1985 merged 1 commit intodevfrom
fix/pytest-collection-errors

Conversation

@mabry1985
Copy link
Copy Markdown
Contributor

@mabry1985 mabry1985 commented Apr 20, 2026

Fix pytest collection errors on test_memory_persistence and test_skill_index.

Addresses the bug found during v0.2.0 smoke testing where running pytest tests/ in a fresh Docker env fails at collection with:
ModuleNotFoundError: No module named langchain_core.language_models; langchain_core is not a package

Recovered by Ava via REST API after pipeline could not push the branch itself.

Summary by CodeRabbit

  • Chores
    • Updated dependency constraints to include langchain-core with minimum version requirement.
    • Enhanced test infrastructure configuration for improved test execution and verification.
    • Updated CI/CD pipeline to validate published runtime images.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Walkthrough

This PR enhances test infrastructure by adding Docker-based test validation in the publish workflow, configuring pytest's Python path, adding an explicit langchain-core dependency, and implementing a conftest hook to manage import resolution order during test execution.

Changes

Cohort / File(s) Summary
GitHub Workflow
.github/workflows/docker-publish.yml
Added a new verification step that runs the published Docker image to collect tests with pytest --collect-only, ensuring the test suite is properly discoverable in the built image.
Python Build & Test Configuration
pyproject.toml, requirements.txt
Updated pytest config to include project root in sys.path via pythonpath = ["."], and added explicit langchain-core>=0.3.0 dependency constraint.
Test Infrastructure
tests/conftest.py
New pytest configuration file with pytest_configure hook that reorders sys.path to prioritize site-packages directories at the start, ensuring consistent import resolution during test execution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required 'Summary' and 'Test plan' sections from the template, though it provides context about the bug. The 'Closes' section is also blank. Add a Summary section with 1-3 bullets explaining what changed and why, and include a Test plan section with verification steps. Link any related issues in the Closes section.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing pytest collection errors, which aligns with the core problem addressed by the changeset across configuration files and test infrastructure.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pytest-collection-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/docker-publish.yml:
- Around line 78-86: The publish workflow step that runs the docker command uses
an unpinned pip install ("pip install -q pytest pytest-asyncio") inside the
docker run -c shell; change that install to use lower-bound version constraints
(e.g., "pytest>=..." and "pytest-asyncio>=...") consistent with the repo's
dependency pattern so the pytest toolchain is pinned during the runtime image
verification, keeping the rest of the docker run invocation (SHORT_SHA,
--entrypoint sh, and python -m pytest ... --collect-only) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 67ac33c3-54f1-400f-890e-222c815a82d6

📥 Commits

Reviewing files that changed from the base of the PR and between 7803721 and 61891a3.

📒 Files selected for processing (4)
  • .github/workflows/docker-publish.yml
  • pyproject.toml
  • requirements.txt
  • tests/conftest.py

Comment on lines +78 to +86
- name: Verify — pytest collection in runtime image
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
docker run --rm \
-v "${{ github.workspace }}:/repo" \
-w /repo \
--entrypoint sh \
"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${SHORT_SHA}" \
-c 'pip install -q pytest pytest-asyncio && python -m pytest tests/ --collect-only -q'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Workflow installs of pytest =="
rg -n --type=yaml 'pip install .*pytest' .github/workflows

echo
echo "== Declared pytest dependencies in repo manifests =="
rg -n --iglob 'pyproject.toml' --iglob 'requirements*.txt' 'pytest(-asyncio)?'

Repository: protoLabsAI/protoAgent

Length of output: 335


🏁 Script executed:

cat -n pyproject.toml

Repository: protoLabsAI/protoAgent

Length of output: 384


🏁 Script executed:

wc -l pyproject.toml && echo "---" && cat pyproject.toml

Repository: protoLabsAI/protoAgent

Length of output: 336


🏁 Script executed:

find . -type f \( -name "requirements*.txt" -o -name "setup.py" -o -name "setup.cfg" -o -name "poetry.lock" -o -name "package-lock.json" -o -name "Pipfile.lock" -o -name "pdm.lock" \) | head -20

Repository: protoLabsAI/protoAgent

Length of output: 104


🏁 Script executed:

cat requirements.txt

Repository: protoLabsAI/protoAgent

Length of output: 345


🏁 Script executed:

echo "== Checking other CI workflows for pytest usage ==" && \
find .github/workflows -name "*.yml" -o -name "*.yaml" | xargs grep -l pytest 2>/dev/null || echo "No other pytest usage found"

Repository: protoLabsAI/protoAgent

Length of output: 153


Pin the pytest toolchain in this publish-time verification step.

Line 86 installs unpinned pytest and pytest-asyncio, making this main-branch publish workflow susceptible to nondeterministic failures from upstream releases. The repo uses lower-bound version constraints elsewhere (e.g., gradio>=5.0, httpx>=0.27); apply the same pattern here.

💡 Suggested change
-            -c 'pip install -q pytest pytest-asyncio && python -m pytest tests/ --collect-only -q'
+            -c 'python -m pip install -q "pytest>=8" "pytest-asyncio>=0.24" && python -m pytest tests/ --collect-only -q'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Verify — pytest collection in runtime image
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
docker run --rm \
-v "${{ github.workspace }}:/repo" \
-w /repo \
--entrypoint sh \
"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${SHORT_SHA}" \
-c 'pip install -q pytest pytest-asyncio && python -m pytest tests/ --collect-only -q'
- name: Verify — pytest collection in runtime image
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
docker run --rm \
-v "${{ github.workspace }}:/repo" \
-w /repo \
--entrypoint sh \
"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${SHORT_SHA}" \
-c 'python -m pip install -q "pytest>=8" "pytest-asyncio>=0.24" && python -m pytest tests/ --collect-only -q'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/docker-publish.yml around lines 78 - 86, The publish
workflow step that runs the docker command uses an unpinned pip install ("pip
install -q pytest pytest-asyncio") inside the docker run -c shell; change that
install to use lower-bound version constraints (e.g., "pytest>=..." and
"pytest-asyncio>=...") consistent with the repo's dependency pattern so the
pytest toolchain is pinned during the runtime image verification, keeping the
rest of the docker run invocation (SHORT_SHA, --entrypoint sh, and python -m
pytest ... --collect-only) unchanged.

@mabry1985 mabry1985 merged commit 118c9b2 into dev Apr 20, 2026
1 check passed
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.

1 participant