Skip to content

Use with-connect for Posit Connect integration tests#243

Merged
edavidaja merged 15 commits into
mainfrom
connect-test-simplification
Jul 1, 2026
Merged

Use with-connect for Posit Connect integration tests#243
edavidaja merged 15 commits into
mainfrom
connect-test-simplification

Conversation

@edavidaja

Copy link
Copy Markdown
Collaborator

What & why

Replaces vetiver's bespoke Connect-in-Docker test harness (docker-compose.yml + script/setup-rsconnect/ user bootstrap) with posit-dev/with-connect, the shared tool for running Posit Connect in CI. The Connect integration test now reads CONNECT_SERVER/CONNECT_API_KEY from the environment and derives the pin namespace from the authenticated user, so vetiver no longer maintains its own Connect provisioning scripts.

Design and implementation plan are included under docs/superpowers/.

Changes

  • vetiver/tests/test_rsconnect.py — read creds from env (lazy, so the default make test collection doesn't require them), single admin user, runtime-derived username (<user>/model). Updated for current rsconnect-python (content_list), fresh-container deploys (new=True), and a trailing-slash fix on content_url.
  • vetiver/server.pypredict() now sets Content-Type: application/json on the DataFrame branch. Without it, vetiver.predict(endpoint, df) returns 422 against current FastAPI/pydantic-v2 Connect (the json= branches were unaffected). This is a real user-facing fix the migration surfaced; the test exercises the real path rather than working around it.
  • Makefilemake test-rsc boots Connect via with-connect; removed dev/dev-start/dev-stop and RSC_API_KEYS.
  • .github/workflows/tests.ymltest-connect job uses the with-connect Action.
  • .github/workflows/weekly.yml — rsconnect canary jobs use the Action (with a failure-notification issue); pins-only jobs no longer start Connect.
  • Deleted docker-compose.yml, script/setup-rsconnect/, vetiver/tests/rsconnect_api_keys.json.

Notes

  • with-connect is pinned to commit 0783dabd (no release tags exist yet).
  • The deployed requirements.txt is filtered (drop editable/local vetiver, append plain vetiver) in the Makefile and weekly jobs, where vetiver isn't installable from a remote. The per-PR test-connect job intentionally keeps a plain freeze so it deploys this PR's vetiver via its git+...@<sha> install — see the inline comment.
  • The local integration test was verified passing repeatedly via with-connect.
  • Pre-existing, unrelated failures in this repo (not touched here): test_monitor.py/test_prepare_docker.py collection errors and test_server.py::test_endpoint_adds (a direct client.post with the same Content-Type root cause).
  • Pairs with forthcoming rsconnect-python changes that drop its vetiver-specific test baggage.
edavidaja added 11 commits June 30, 2026 14:36
Adopt posit-dev/with-connect in both repos, move vetiver's Connect tests
fully into vetiver, strip vetiver-specific test baggage from rsconnect-python
(re-homing its own system-caches integration test), and relabel the
deploy_python_fastapi compatibility shim rather than removing it.
Replaces the bespoke docker-compose credential setup (hardcoded
localhost:3939 + JSON key file with named users) with env-var
credentials provided by with-connect. Credentials are read lazily
at module scope via os.environ.get() to avoid KeyError during
normal test collection when CONNECT_SERVER / CONNECT_API_KEY are
not set.

Additional fixes needed for compatibility with rsconnect-python 1.29.x
and FastAPI 0.138.x / pydantic v2:
- content_search() renamed to content_list()
- new=True required to avoid stale AppStore GUID across fresh containers
- content_url may include a trailing slash; strip before appending /predict
- Content-Type: application/json required; modern FastAPI/pydantic v2 no
  longer accepts JSON body without explicit content-type header
- remove RSC_API_KEYS variable and dev/dev-start/dev-stop/$(RSC_API_KEYS) targets
- test-rsc now boots Connect via pinned with-connect (0783dab)
- generate requirements.txt via uv run pip freeze, filtering editable/local
  vetiver entries and appending plain 'vetiver' so Connect can pip-install it
- invoke pytest via uv run --with pytest on the specific test file to avoid
  collection errors in unrelated test files
- data: replace removed pkg_resources with importlib.resources (unblocks
  Docker and no-extras jobs that import vetiver.data)
- monitor: use pd.api.types.is_datetime64_any_dtype; np.issubdtype now
  raises on pandas string dtype. Drop the now-unused numpy import
- test_monitor: pandas dropped the uppercase 'S' freq alias; use 's'
- test_prepare_docker: the two test functions were decorated as fixtures
  (since 238e967) so they never ran and broke collection under newer
  pytest. Restore them as tests and add an autouse fixture that restores
  the shared fsspec LocalFileSystem protocol they mutate, preventing the
  leak that otherwise corrupted test_write_app
- test_server: test_endpoint_adds must send Content-Type: application/json
  (same root cause as the predict() fix in this branch)
- ci: pin fastapi<0.116 in the pydantic v1 job; fastapi>=0.116
  unconditionally imports IncEx from pydantic v2
- test-connect: the with-connect action runs `uv tool install` for a tool
  that requires Python >=3.13, but inherits UV_PYTHON=3.9 from setup-uv.
  Repoint UV_PYTHON=3.13 before the action so the tool installs; the freeze
  and pytest command still run in the 3.9 VIRTUAL_ENV (the deploy manifest
  must record a Python version Connect actually has)
- docs: pin griffe<2; quartodoc 0.11.x breaks against the griffe 2.x rewrite
  (imports griffe.loader, passes the removed parse_numpy kwarg), which was
  failing `make docs`
The with-connect Connect image provides only Python 3.14.6 as a Local
environment. rsconnect records the client Python in the deploy manifest, so
freezing under 3.9 made Connect fail to build the content ("no compatible
Local environment with Python version 3.9.25"). Run the whole job on 3.14 so
the freeze matches; 3.14 also satisfies with-connect's own requires-python
(>=3.13), so the separate UV_PYTHON override is no longer needed.
Comment thread .github/workflows/weekly.yml Outdated

@isabelizimm isabelizimm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM besides one small update for weekly versions! thank you so much for updating this (and doing a little maintenance along the way) 🙏 it's okay to merge this with the pre-commit failure, that's unrelated. I can fix stuff in a follow up PR if there ends up being anything

Co-authored-by: Isabel Zimmerman <54685329+isabelizimm@users.noreply.github.com>
@edavidaja edavidaja merged commit 0d39808 into main Jul 1, 2026
22 of 24 checks passed
@edavidaja edavidaja deleted the connect-test-simplification branch July 1, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants