Skip to content

Conversation

wassimbensalem
Copy link
Contributor

Description

This PR enhances the Katib Python SDK to support multiple pip index URLs, allowing users to install packages from both public (e.g., PyPI) and private repositories within the same experiment. This addresses a common use case in enterprise environments where teams rely on both open-source and internal proprietary packages.

The implementation replaces the pip_index_url (string) parameter in the tune method with pip_index_urls (a list of strings). The first URL in the list is used as the primary --index-url, and all subsequent URLs are added as --extra-index-url flags for the pip install command.

To ensure backward compatibility, the pip_index_urls parameter defaults to ["https://pypi.org/simple"] if not provided.

Changes Included

  • sdk/python/v1beta1/kubeflow/katib/api/katib_client.py:
    • Updated the tune method to accept pip_index_urls: List[str] instead of pip_index_url: str.
  • sdk/python/v1beta1/kubeflow/katib/utils/utils.py:
    • Added a new format_pip_index_urls utility function to correctly format the list of URLs into a pip-compatible command string.
    • Updated get_script_for_python_packages to use the new formatting function.
  • Testing:
    • Added a new test file sdk/python/v1beta1/kubeflow/katib/utils/utils_test.py to unit-test the format_pip_index_urls function.
    • Added a new test case to sdk/python/v1beta1/kubeflow/katib/api/katib_client_test.py to verify that the tune method correctly generates the container arguments when pip_index_urls is used.

Example Usage

Before:

# Can only use one index URL
client.tune(
    name="experiment",
    pip_index_url="https://my-private-repo.com/simple/"
)

After:

# Can specify multiple index URLs
client.tune(
    name="experiment",
    pip_packages=["scikit-learn", "my-private-lib"],
    pip_index_urls=[
        "https://pypi.org/simple/",
        "https://my-private-repo.com/simple/"
    ]
)

Fixes #2565

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign gaocegege for approval. For more information see the Kubernetes Code Review Process.

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change pip_index_url to pip_index_urls list in Katib SDK

1 participant