Skip to content

Commit

Permalink
add KFP SDK production best practice note for packages_to_install (#3552
Browse files Browse the repository at this point in the history
)

* add notice

* add paragraph to Containerized Python Components section
  • Loading branch information
connor-mccarthy committed Jul 24, 2023
1 parent a61dd2a commit 8470894
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -10,6 +10,8 @@ The following assumes a basic familiarity with [Lightweight Python Components][l

Containerized Python Components extend [Lightweight Python Components][lightweight-python-components] by relaxing the constraint that Lightweight Python Components be hermetic (i.e., fully self-contained). This means Containerized Python Component functions can depend on symbols defined outside of the function, imports outside of the function, code in adjacent Python modules, etc. To achieve this, the KFP SDK provides a convenient way to package your Python code into a container.

As a production software best practice, component authors should prefer Containerized Python Components to [Lightweight Python Components][lightweight-python-components] when their component specifies [`packages_to_install`][packages-to-install], since the KFP SDK will install these dependencies into the component's image when it is built, rather than at task runtime.

The following shows how to use Containerized Python Components by modifying the `add` component from the [Lightweight Python Components][lightweight-python-components] example:

```python
Expand Down Expand Up @@ -106,4 +108,5 @@ Since `add`'s `target_image` uses [Google Cloud Artifact Registry][artifact-regi
[docker-from]: https://docs.docker.com/engine/reference/builder/#from
[artifact-registry]: https://cloud.google.com/artifact-registry/docs/docker/authentication
[vertex-pipelines]: https://cloud.google.com/vertex-ai/docs/pipelines/introduction
[iam]: https://cloud.google.com/iam
[iam]: https://cloud.google.com/iam
[packages-to-install]: https://www.kubeflow.org/docs/components/pipelines/v2/components/lightweight-python-components/#packages_to_install
Expand Up @@ -79,6 +79,8 @@ def sin(val: float = 3.14) -> float:
return np.sin(val).item()
```

**Note:** As a production software best practice, prefer using [Containerized Python Components][containerized-python-components] when your component specifies `packages_to_install` to eliminate installation of your dependencies at runtime.

#### pip_index_urls

`pip_index_urls` exposes the ability to pip install `packages_to_install` from package indices other than the default [PyPI.org][pypi-org].
Expand Down

0 comments on commit 8470894

Please sign in to comment.