Skip to content

Commit ed4600d

Browse files
fix: add --user when install python packages (#136)
Signed-off-by: Brian Gallagher <[email protected]>
1 parent 57d2052 commit ed4600d

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Kubeflow Trainer client supports local development without needing a Kubernetes
7878
### Available Backends
7979

8080
- **KubernetesBackend** (default) - Production training on Kubernetes
81-
- **ContainerBackend** - Local development with Docker/Podman isolation
81+
- **ContainerBackend** - Local development with Docker/Podman isolation
8282
- **LocalProcessBackend** - Quick prototyping with Python subprocesses
8383

8484
**Quick Start:**

kubeflow/trainer/backends/kubernetes/backend_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def get_custom_trainer(
217217
"""
218218
pip_command = [f"--index-url {pip_index_urls[0]}"]
219219
pip_command.extend([f"--extra-index-url {repo}" for repo in pip_index_urls[1:]])
220+
pip_command.append("--user")
220221
pip_command = " ".join(pip_command)
221222

222223
packages_command = " ".join(packages_to_install)

kubeflow/trainer/backends/kubernetes/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@ def get_script_for_python_packages(
247247
# first url will be the index-url.
248248
options = [f"--index-url {pip_index_urls[0]}"]
249249
options.extend(f"--extra-index-url {extra_index_url}" for extra_index_url in pip_index_urls[1:])
250-
# For the OpenMPI, the packages must be installed for the mpiuser.
251-
if is_mpi:
252-
options.append("--user")
250+
# Always install for the user to avoid permission issues across environments.
251+
options.append("--user")
253252

254253
header_script = textwrap.dedent(
255254
"""

kubeflow/trainer/backends/kubernetes/utils_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _build_runtime() -> types.Runtime:
5454
"--no-warn-script-location --index-url https://pypi.org/simple "
5555
"--extra-index-url https://private.repo.com/simple "
5656
"--extra-index-url https://internal.company.com/simple "
57-
"torch numpy custom-package\n"
57+
"--user torch numpy custom-package\n"
5858
),
5959
),
6060
TestCase(
@@ -71,7 +71,7 @@ def _build_runtime() -> types.Runtime:
7171
"fi\n\n"
7272
"PIP_DISABLE_PIP_VERSION_CHECK=1 python -m pip install --quiet "
7373
"--no-warn-script-location --index-url https://pypi.org/simple "
74-
"torch numpy custom-package\n"
74+
"--user torch numpy custom-package\n"
7575
),
7676
),
7777
TestCase(
@@ -111,7 +111,7 @@ def _build_runtime() -> types.Runtime:
111111
"fi\n\n"
112112
"PIP_DISABLE_PIP_VERSION_CHECK=1 python -m pip install --quiet "
113113
f"--no-warn-script-location --index-url "
114-
f"{constants.DEFAULT_PIP_INDEX_URLS[0]} torch numpy\n"
114+
f"{constants.DEFAULT_PIP_INDEX_URLS[0]} --user torch numpy\n"
115115
),
116116
),
117117
],

kubeflow/trainer/backends/localprocess/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# The exec script to embed training function into container command.
4444
DEPENDENCIES_SCRIPT = textwrap.dedent(
4545
"""
46-
PIP_DISABLE_PIP_VERSION_CHECK=1 pip install $QUIET \
46+
PIP_DISABLE_PIP_VERSION_CHECK=1 pip install $QUIET --user \
4747
--no-warn-script-location $PIP_INDEX $PACKAGE_STR
4848
"""
4949
)

0 commit comments

Comments
 (0)