Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-45676: Update repo infrastructure #160

Merged
merged 24 commits into from
Aug 14, 2024
Merged

DM-45676: Update repo infrastructure #160

merged 24 commits into from
Aug 14, 2024

Conversation

jonathansick
Copy link
Member

@jonathansick jonathansick commented Aug 9, 2024

  • Use uv for installing and compiling dependencies
  • Use ruff-shared.toml.
  • Update to Pydantic 2.
  • Switch to using faststream for Kafka (for better integration with Pydantic schemas)
  • Switch to using testcontainers[kafka] for providing a Kafka dependency for nox sessions.

This takes care of installing nox and caching.
We now recompute dependencies whenever we update the app, rather than on
an automatic schedule. periodic-ci.yaml ensures that the dependencies
can be updated without breaking tests.
This toml configuration comes from the FastAPI template at
https://github.com/lsst/templates
This updates the Pydantic dependency to version 2, but likely isn't
working yet. The issue is that Kafkit is still using Pydantic 2. But
since we're moving to faststream and using Pydantic models directly
without the Confluent Schema Registry we may just switch to that now
too.
This switches Ook to using faststream and directly using Pydantic models
rather than using Kafkit's Pydantic adapter for the Confluent Schema
Registry. This faststream is approach is also how we're now building
squarebot.
To get testcontainers to work

- Change the app so that its creation is deferred to a create_app
  function
- Don't import the kafka_router into the main namespace so that the app
  fixture in conftest.py can reset the kafka_router with the new
  configuration.
This changes the approach previously taken where I ran testcontainers in
the pytest conftest.py module. Here I'm running the testcontainers in
the nox sessions, which is more similar to how tox-docker runs. The
advantage of this approach is that it doesn't require any code
modifications and patching because the environment variables for the
Kafka configuration can be made *before* starting up the app tests /
development run or documentation building sessions.

Running testcontainers via pytest could still be a useful technique if
different tests need full isolation of their testcontainers, but of
course this is a slow and resource-intensive approach.
We need to make sure testcontainers[kafka] is in the environment that
nox is running in. Locally this is handled by having nox set up the
local virtual environmemnt with nox -s init or nox -s venv-init.
jonathansick added a commit to lsst-sqre/phalanx that referenced this pull request Aug 13, 2024
Updates Ook to use faststream for its kafka usage. See lsst-sqre/ook#160
This is needed to ensure the standalone Factory in the CLI context
works.
This ensures that the handler function is imported and therefore
registered to the kafka router.

Note need to avoid circ deps with kafkarouter
@jonathansick jonathansick marked this pull request as ready for review August 14, 2024 20:46
@jonathansick jonathansick merged commit 1930f04 into main Aug 14, 2024
4 checks passed
@jonathansick jonathansick deleted the tickets/DM-45676 branch August 14, 2024 20:49
jonathansick added a commit to lsst-sqre/phalanx that referenced this pull request Aug 14, 2024
Updates Ook to use faststream for its kafka usage. See lsst-sqre/ook#160

Includes an updated Kafka SSL configuration:

- Update environment variable names to match the new Ook configuration
  models.

- Drop the Confluent Schema Registry configurations, which are no longer
  needed.
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