Python SDK: Move to PyPI Installation with Optional Local Dev Mode#1826
Conversation
Stop copying apip_sdk_core into generated python-executor and remove the sys.path injection used for source-tree imports. Add apip-sdk-core to python-executor/requirements.txt and update Dockerfile to install the SDK from PyPI by default, with a PYTHON_SDK_SOURCE build-arg to allow a local monorepo install for dev (copying local SDK into the build context and installing it when PYTHON_SDK_SOURCE=local). Add PYTHON_SDK_SOURCE and a setup-python-dev target to the Makefile and update tests/generator expectations to no longer require file-copied SDK. Also remove helper/test code that created or patched a local SDK directory. These changes make runtime builds use the packaged SDK dependency while preserving a local-install path for developer iteration.
Update gateway/gateway-controller/default-policies/prompt-compressor.yaml: increment the prompt-compressor policy version from v0.1.0 to v0.9.0 to reflect the new release.
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR changes Python SDK handling from copying a local SDK into generated outputs to relying on an installed package. The generator no longer copies apip_sdk_core into python-executor outputs. Runtime modules that adjusted sys.path to find a local SDK were removed. requirements.txt now depends on apip-sdk-core. The Dockerfile build is parameterized via PYTHON_SDK_SOURCE (pypi|local) to control how dependencies are installed, and a Makefile target/arg was added to support local editable installs. The prompt-compressor policy version is bumped to v0.9.0. Sequence Diagram(s)sequenceDiagram
participant Dev as Developer (Makefile)
participant Docker as Docker Build
participant BuildStage as python-deps stage
participant PackageSource as SDK Source (PyPI or local)
participant Runtime as python-executor runtime
Dev->>Docker: docker build --build-arg PYTHON_SDK_SOURCE=(pypi|local)
Docker->>BuildStage: start python-deps stage
alt PYTHON_SDK_SOURCE == "pypi"
BuildStage->>PackageSource: pip install -r requirements.txt (apip-sdk-core from PyPI)
else PYTHON_SDK_SOURCE == "local"
BuildStage->>PackageSource: include /tmp/sdk-python and pip install -r requirements.txt (editable/local SDK)
else invalid
BuildStage-->>Docker: exit with error
end
BuildStage->>Docker: produce image with site-packages containing apip_sdk_core
Docker->>Runtime: runtime image runs (no local apip_sdk_core copied into python-executor)
Runtime->>PackageSource: import apip_sdk_core (resolved from installed site-packages)
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 55 minutes and 47 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
gateway/gateway-runtime/Makefile (1)
33-35: Add Makefile-side validation forPYTHON_SDK_SOURCEto fail fast.Current validation happens inside Docker build. A pre-check in Make avoids spending build time on invalid values.
Proposed Makefile refactor
+.PHONY: validate-python-sdk-source + +validate-python-sdk-source: + `@if` [ "$(PYTHON_SDK_SOURCE)" != "pypi" ] && [ "$(PYTHON_SDK_SOURCE)" != "local" ]; then \ + echo "ERROR: invalid PYTHON_SDK_SOURCE=$(PYTHON_SDK_SOURCE); expected 'local' or 'pypi'"; \ + exit 1; \ + fi + -build: test ## Build Gateway Runtime Docker image using buildx +build: test validate-python-sdk-source ## Build Gateway Runtime Docker image using buildx @@ -build-debug: ## Build debug Gateway Runtime image for remote debugging with dlv (VS Code attach on port 2346) +build-debug: validate-python-sdk-source ## Build debug Gateway Runtime image for remote debugging with dlv (VS Code attach on port 2346) @@ -build-coverage-image: test ## Build Gateway Runtime Docker image with coverage instrumentation +build-coverage-image: test validate-python-sdk-source ## Build Gateway Runtime Docker image with coverage instrumentation @@ -build-and-push-multiarch: ## Build and push Gateway Runtime Docker image for multiple architectures (amd64, arm64) +build-and-push-multiarch: validate-python-sdk-source ## Build and push Gateway Runtime Docker image for multiple architectures (amd64, arm64)Also applies to: 66-67, 93-94, 119-120, 146-147, 186-187
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@gateway/gateway-runtime/Makefile` around lines 33 - 35, Add a Makefile-side validation that checks PYTHON_SDK_SOURCE immediately after its assignment and fails fast on invalid values; specifically, add a conditional that uses the Make functions (e.g., filter or findstring) to allow only "pypi" or "local" and call $(error ...) when the value is not allowed. Apply the same pattern for the other SDK source variables mentioned (e.g., NODE_SDK_SOURCE, GO_SDK_SOURCE, etc.) so the build aborts early with a clear message instead of failing later during the Docker build.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@gateway/gateway-runtime/Makefile`:
- Around line 33-35: Add a Makefile-side validation that checks
PYTHON_SDK_SOURCE immediately after its assignment and fails fast on invalid
values; specifically, add a conditional that uses the Make functions (e.g.,
filter or findstring) to allow only "pypi" or "local" and call $(error ...) when
the value is not allowed. Apply the same pattern for the other SDK source
variables mentioned (e.g., NODE_SDK_SOURCE, GO_SDK_SOURCE, etc.) so the build
aborts early with a clear message instead of failing later during the Docker
build.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7bcc6d66-7604-4c29-b67e-8161634d6b2b
📒 Files selected for processing (8)
gateway/gateway-builder/internal/policyengine/generator.gogateway/gateway-builder/internal/policyengine/policyengine_test.gogateway/gateway-controller/default-policies/prompt-compressor.yamlgateway/gateway-runtime/Dockerfilegateway/gateway-runtime/Makefilegateway/gateway-runtime/python-executor/executor/__init__.pygateway/gateway-runtime/python-executor/requirements.txtgateway/gateway-runtime/python-executor/tests/__init__.py
💤 Files with no reviewable changes (3)
- gateway/gateway-builder/internal/policyengine/generator.go
- gateway/gateway-runtime/python-executor/executor/init.py
- gateway/gateway-runtime/python-executor/tests/init.py
Purpose
Stop copying apip_sdk_core into generated python-executor and remove the sys.path injection used for source-tree imports. Add apip-sdk-core to python-executor/requirements.txt and update Dockerfile to install the SDK from PyPI by default, with a PYTHON_SDK_SOURCE build-arg to allow a local monorepo install for dev (copying local SDK into the build context and installing it when PYTHON_SDK_SOURCE=local). Add PYTHON_SDK_SOURCE and a setup-python-dev target to the Makefile and update tests/generator expectations to no longer require file-copied SDK. Also remove helper/test code that created or patched a local SDK directory. These changes make runtime builds use the packaged SDK dependency while preserving a local-install path for developer iteration.