Skip to content

feat(backend): support KALE_PYPI_PROD_URL for configurable production PyPI index#866

Merged
google-oss-prow[bot] merged 3 commits into
kubeflow:mainfrom
Bhavd33p:feat/kale-pypi-prod-url
Jul 22, 2026
Merged

feat(backend): support KALE_PYPI_PROD_URL for configurable production PyPI index#866
google-oss-prow[bot] merged 3 commits into
kubeflow:mainfrom
Bhavd33p:feat/kale-pypi-prod-url

Conversation

@Bhavd33p

@Bhavd33p Bhavd33p commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • compute_pip_index_urls() hardcoded the production pip index fallback to https://pypi.org/simple, appended unconditionally regardless of KALE_PIP_INDEX_URLS/KALE_DEV_MODE overrides
  • Add KALE_PYPI_PROD_URL env var to make this fallback configurable, defaulting to https://pypi.org/simple for backward compatibility
  • Documented alongside the other KALE_PIP_*/KALE_DEV_MODE vars in docs/source/user-guide/running-pipelines.md and docs/source/api/cli.md

Fixes #797

Test plan

  • pytest kale/tests/unit_tests/test_utils.py -k compute_pip_index_urls -v — 8 passed (5 existing + 3 new)
  • Full unit suite: pytest kale/tests/unit_tests/ — 247 passed
  • Manual check: KALE_PYPI_PROD_URL set → used in place of pypi.org; unset → falls back to https://pypi.org/simple

🤖 Generated with Claude Code

… PyPI index

Air-gapped or mirror-only deployments can't reach pypi.org, but Kale
always appended it as the hardcoded production fallback in generated
pipeline components regardless of other pip index overrides. Add
KALE_PYPI_PROD_URL so this fallback is configurable, defaulting to
https://pypi.org/simple for backward compatibility.

Fixes kubeflow#797

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: [Bhavdeep Singh] <bhavdeep3singh@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the “production” pip simple index URL used in generated KFP components configurable via KALE_PYPI_PROD_URL, while keeping the existing default (https://pypi.org/simple) for backward compatibility. This supports air-gapped and mirror-only deployments that cannot reach public PyPI.

Changes:

  • Updated compute_pip_index_urls() to read the production fallback index from KALE_PYPI_PROD_URL.
  • Added unit tests covering default and override behaviors for the new environment variable.
  • Documented KALE_PYPI_PROD_URL alongside other runtime environment variables.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
kale/common/utils.py Adds KALE_PYPI_PROD_URL support in pip index URL computation and updates related docstring text.
kale/tests/unit_tests/test_utils.py Adds tests validating default and overridden production index behavior.
docs/source/user-guide/running-pipelines.md Documents KALE_PYPI_PROD_URL in the runtime environment variables table.
docs/source/api/cli.md Documents KALE_PYPI_PROD_URL in the CLI environment variables table.
Comments suppressed due to low confidence (1)

kale/common/utils.py:238

  • compute_pip_index_urls() can return duplicate index URLs. If KALE_PIP_INDEX_URLS already includes the production URL (or it matches the devpi URL), the function appends pypi_prod_url again unconditionally; the later “remove duplicates” block is ineffective because it checks membership after appending. Also, KALE_PYPI_PROD_URL isn’t stripped, so whitespace-only values become invalid URLs. Consider normalizing KALE_PYPI_PROD_URL and ensuring it only appears once (as the final entry).
    pypi_prod_url = os.getenv("KALE_PYPI_PROD_URL", "https://pypi.org/simple")
    urls: list[str]

    # explicit override wins
    env_override = os.getenv("KALE_PIP_INDEX_URLS")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread kale/common/utils.py Outdated
Comment on lines +212 to +215
return a list with the devpi simple URL (`KALE_DEVPI_SIMPLE_URL`) or
its default value.
3. Otherwise, return the production default:
["https://pypi.org/simple"].
[`KALE_PYPI_PROD_URL`] (defaults to ["https://pypi.org/simple"]).
Comment on lines +149 to +158
def test_compute_pip_index_urls_prod_url_override_with_explicit_indexes(monkeypatch):
"""KALE_PYPI_PROD_URL still lands last when KALE_PIP_INDEX_URLS is set."""
_clear_env(monkeypatch)
monkeypatch.setenv("KALE_PYPI_PROD_URL", "https://pypi.internal.example.com/simple")
monkeypatch.setenv("KALE_PIP_INDEX_URLS", "https://mirror.one/simple")

assert utils.compute_pip_index_urls() == [
"https://mirror.one/simple",
"https://pypi.internal.example.com/simple",
]

@jesuino jesuino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @Bhavd33p

Thanks for your contribution!

Would you please check the Copilot review comments?

Thanks!

@Bhavd33p

Bhavd33p commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

@jesuino Yes I will do the required changes

Edit :Kindly review the changes

Address Copilot review feedback on kubeflow#866:
- compute_pip_index_urls() could return the production URL twice when
  KALE_PIP_INDEX_URLS (or the devpi URL) already contained it, since the
  old dedup check ran after the unconditional append and could never
  fire. Now the production URL is filtered out of the base list and
  appended once at the end.
- KALE_PYPI_PROD_URL is stripped, and a whitespace-only value falls
  back to the default instead of producing an invalid index URL.
- Updated the docstring precedence description and added tests for the
  duplicate and whitespace-only cases.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: [Bhavdeep Singh] <bhavdeep3singh@gmail.com>

@jesuino jesuino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@google-oss-prow google-oss-prow Bot added the lgtm label Jul 20, 2026
@jesuino

jesuino commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@Bhavd33p it looks good to me! please rebase your branch so we can see the CI results and merge it!

@google-oss-prow google-oss-prow Bot removed the lgtm label Jul 22, 2026

@ederign ederign left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/approve
/lgtm

@google-oss-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ederign

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow
google-oss-prow Bot merged commit 295c3a0 into kubeflow:main Jul 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature(backend): Support KALE_PYPI_PROD_URL for configurable production PyPI index

4 participants