Skip to content

Python SDK: Move to PyPI Installation with Optional Local Dev Mode#1826

Merged
renuka-fernando merged 5 commits into
wso2:mainfrom
sehan-dissanayake:local-and-pypi-sdk
May 6, 2026
Merged

Python SDK: Move to PyPI Installation with Optional Local Dev Mode#1826
renuka-fernando merged 5 commits into
wso2:mainfrom
sehan-dissanayake:local-and-pypi-sdk

Conversation

@sehan-dissanayake
Copy link
Copy Markdown
Contributor

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.

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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

Warning

Rate limit exceeded

@sehan-dissanayake has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 47 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d4da895-1e62-45d2-936c-b0e603e00980

📥 Commits

Reviewing files that changed from the base of the PR and between ac4d1d8 and 59fcad0.

📒 Files selected for processing (2)
  • gateway/gateway-runtime/Dockerfile
  • gateway/gateway-runtime/Makefile
📝 Walkthrough

Walkthrough

The 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)
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: transitioning Python SDK installation from file copying to PyPI, with local dev mode support.
Description check ✅ Passed The description covers Purpose (why), Goals (what), and Approach (how) adequately, though it omits some template sections like documentation and security checks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 55 minutes and 47 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
gateway/gateway-runtime/Makefile (1)

33-35: Add Makefile-side validation for PYTHON_SDK_SOURCE to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d3b563 and 379df12.

📒 Files selected for processing (8)
  • gateway/gateway-builder/internal/policyengine/generator.go
  • gateway/gateway-builder/internal/policyengine/policyengine_test.go
  • gateway/gateway-controller/default-policies/prompt-compressor.yaml
  • gateway/gateway-runtime/Dockerfile
  • gateway/gateway-runtime/Makefile
  • gateway/gateway-runtime/python-executor/executor/__init__.py
  • gateway/gateway-runtime/python-executor/requirements.txt
  • gateway/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

@renuka-fernando renuka-fernando merged commit 7d14ca9 into wso2:main May 6, 2026
5 checks passed
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.

2 participants