Use with-connect for Posit Connect integration tests#243
Merged
Conversation
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
…ements.txt generation
- 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.
isabelizimm
reviewed
Jul 1, 2026
isabelizimm
approved these changes
Jul 1, 2026
Contributor
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Replaces vetiver's bespoke Connect-in-Docker test harness (
docker-compose.yml+script/setup-rsconnect/user bootstrap) withposit-dev/with-connect, the shared tool for running Posit Connect in CI. The Connect integration test now readsCONNECT_SERVER/CONNECT_API_KEYfrom 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 defaultmake testcollection 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 oncontent_url.vetiver/server.py—predict()now setsContent-Type: application/jsonon the DataFrame branch. Without it,vetiver.predict(endpoint, df)returns 422 against current FastAPI/pydantic-v2 Connect (thejson=branches were unaffected). This is a real user-facing fix the migration surfaced; the test exercises the real path rather than working around it.Makefile—make test-rscboots Connect viawith-connect; removeddev/dev-start/dev-stopandRSC_API_KEYS..github/workflows/tests.yml—test-connectjob uses thewith-connectAction..github/workflows/weekly.yml— rsconnect canary jobs use the Action (with a failure-notification issue); pins-only jobs no longer start Connect.docker-compose.yml,script/setup-rsconnect/,vetiver/tests/rsconnect_api_keys.json.Notes
with-connectis pinned to commit0783dabd(no release tags exist yet).requirements.txtis filtered (drop editable/local vetiver, append plainvetiver) in the Makefile and weekly jobs, where vetiver isn't installable from a remote. The per-PRtest-connectjob intentionally keeps a plain freeze so it deploys this PR's vetiver via itsgit+...@<sha>install — see the inline comment.with-connect.test_monitor.py/test_prepare_docker.pycollection errors andtest_server.py::test_endpoint_adds(a directclient.postwith the same Content-Type root cause).rsconnect-pythonchanges that drop its vetiver-specific test baggage.