Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ jobs:
strategy:
fail-fast: false
matrix:
client: ['node', 'python', 'node-protocolv2']
client: ['node', 'python', 'node-protocolv2', 'python-protocolv2']
server: ['node', 'python', 'node-protocolv2']
# protocolv2 clients aren't bakcwards compatible with protocolv1 servers
exclude:
- client: 'node-protocolv2'
server: 'python'
- client: 'node-protocolv2'
server: 'node'
- client: 'python-protocolv2'
server: 'python'
- client: 'python-protocolv2'
server: 'node'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ schema.json:
codegen-python: schema.json
cd impls/python; \
./generate_client.sh

codegen-python-v2:
cd impls/python-protocolv2; \
./generate_client.sh

start-node-protocolv2:
cd impls/node-protocolv2 && \
npm ci && \
HEARTBEAT_MS=500 PORT=9887 SERVER_TRANSPORT_ID=server \
npm run --silent start:server
Empty file.
18 changes: 18 additions & 0 deletions impls/python-protocolv2/client.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# syntax=docker/dockerfile:1

FROM python:3.11-slim-bookworm

WORKDIR /usr/src/river

RUN apt-get update && apt-get install -fy git
RUN pip install uv==0.6.8

COPY pyproject.toml .
COPY uv.lock .
COPY README.md .
COPY src src

RUN uv sync

# bash is required for "time" in python:3.11-slim-bookworm
CMD ["bash", "-c", "time timeout 120 uv run python -u -m testservice.client --log-cli-level=debug"]
47 changes: 47 additions & 0 deletions impls/python-protocolv2/generate_client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

set -ex

REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"

cd "${REPO_ROOT_DIR}/impls/python-protocolv2"

rm -rf \
src/river_python_test/protos/*pb2* \
src/river_python_test/protos/service_river.py \
|| true
git clean -fdx src/river_python_test/protos/ || true

mkdir -p src/river_python_test/protos

uv run python -m grpc_tools.protoc \
--proto_path="${REPO_ROOT_DIR}/protos" \
--python_out=./src \
--mypy_out=./src \
--grpc_python_out=./src \
--mypy_grpc_out=./src \
"${REPO_ROOT_DIR}/protos/testservice/protos/service.proto"

uv run python -m replit_river.codegen \
server \
--module testservice.protos \
--output ./src/testservice/protos \
"${REPO_ROOT_DIR}/protos/testservice/protos/service.proto"

uv run python -m replit_river.codegen \
client \
--output ./src/testservice/protos \
--client-name TestCient \
--protocol-version v2.0 \
"${REPO_ROOT_DIR}/schema-v2.json"

"${REPO_ROOT_DIR}/scripts/patch-grpc.sh" "$(pwd)"

if ! uv run ruff check --fix; then
uv run ruff check --add-noqa
fi

uv run ruff format
uv run pyright .

echo "Completed"
66 changes: 66 additions & 0 deletions impls/python-protocolv2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[project]
name = "river-python-test"
version = "1.0.0"
description = "River toolkit for Python"
readme = "README.md"
requires-python = ">=3.12"
Copy link

Choose a reason for hiding this comment

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

There's a version mismatch between the pyproject.toml file which requires Python ≥3.12 and the client.dockerfile which uses Python 3.11. This could lead to runtime issues or dependency conflicts. Consider either:

  1. Updating the dockerfile to use Python 3.12+:

    FROM python:3.12-slim-bookworm
  2. Or adjusting the pyproject.toml requirements to match the Docker environment:

    requires-python = ">=3.11"

Ensuring version consistency will help prevent potential deployment problems.

Suggested change
requires-python = ">=3.12"
+requires-python = ">=3.11"

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

dependencies = [
"replit-river==0.17.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/testservice"]

[dependency-groups]
dev = [
"deptry>=0.23.0",
"mypy>=1.15.0",
"mypy-protobuf>=3.6.0",
"pyright>=1.1.396",
"pytest>=8.3.5",
"pytest-asyncio>=0.25.3",
"pytest-cov>=4.1.0",
"pytest-mock>=3.14.0",
"ruff>=0.11.0",
"types-protobuf>=5.29.1.20250315",
]

[tool.ruff]
lint.select = ["F", "E", "W", "I001"]

# Should be kept in sync with mypy.ini in the project root.
# The VSCode mypy extension can only read /mypy.ini.
# While mypy run inside the chat container can only see this file.
[tool.mypy]
plugins = "pydantic.mypy"
disallow_untyped_defs = true
warn_return_any = true

[tool.pytest.ini_options]
asyncio_mode = "auto" # auto-detect async tests/fixtures
addopts = "--tb=short"
env = [
"DD_DOGSTATSD_DISABLE=true",
"DD_TRACE_ENABLED=false",
]
filterwarnings = [
"ignore::DeprecationWarning", # google SDKs cause this noise
]
markers = [
"e2e: marks tests as end-to-end (deselect with '-m \"not e2e\"')",
]

[[tool.mypy.overrides]]
module = [
"google.auth.*",
"google.oauth2.*",
"google.cloud.sqlalchemy_spanner.sqlalchemy_spanner.*",
"grpc.*",
"grpc_tools.*",
"nanoid.*",
]
ignore_missing_imports = true
Loading
Loading