Skip to content

Commit bf62905

Browse files
committed
adding support for dsl.condition and dsl.parallelFor to docker runner
Signed-off-by: Nelesh Singla <[email protected]>
1 parent 6bfbad1 commit bf62905

21 files changed

+2336
-427
lines changed

.github/workflows/kfp-sdk-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ concurrency:
2020
jobs:
2121
sdk-tests:
2222
runs-on: ubuntu-latest
23+
timeout-minutes: 45
2324
strategy:
2425
matrix:
2526
python-version: ['3.9', '3.13']
@@ -57,7 +58,7 @@ jobs:
5758
sudo systemctl enable docker
5859
sudo usermod -aG docker "$USER"
5960
# Wait for Docker to be ready
60-
timeout 30 bash -c 'until docker info > /dev/null 2>&1; do sleep 1; done'
61+
timeout 5 bash -c 'until docker info > /dev/null 2>&1; do sleep 1; done'
6162
docker info
6263
6364
- name: Run SDK Tests

.github/workflows/kfp-sdk-unit-tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,21 @@ jobs:
4646
pip install -r sdk/python/requirements-dev.txt
4747
4848
- name: Run SDK Tests
49+
id: run-tests
4950
env:
5051
# We setup the env in the CI
5152
SETUP_ENV: false
5253
REPO_NAME: ${{ github.repository }}
5354
PULL_NUMBER: ${{ github.event.pull_request.number }}
55+
JUNIT_XML: "sdk-unit.xml"
5456
run: |
5557
./test/presubmit-tests-sdk-unit.sh
58+
echo "JUNIT_XML=$JUNIT_XML" >> "$GITHUB_OUTPUT"
59+
60+
- name: Publish Junit Summary
61+
id: summary
62+
uses: ./.github/actions/junit-summary
63+
if: (!cancelled())
64+
with:
65+
xml_files: ${{ steps.run-tests.outputs.JUNIT_XML }}
66+
continue-on-error: true

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ repos:
3838
- id: isort
3939
name: isort
4040
entry: isort --profile google
41-
- repo: https://github.com/pre-commit/mirrors-yapf
41+
- repo: https://github.com/google/yapf
4242
rev: "v0.32.0"
4343
hooks:
4444
- id: yapf

sdk/python/kfp/local/config.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,21 @@ class SubprocessRunner:
4242
4343
Args:
4444
use_venv: Whether to run the subprocess in a virtual environment. If True, dependencies will be installed in the virtual environment. If False, dependencies will be installed in the current environment. Using a virtual environment is recommended.
45+
serialize_pip_installs: Whether to serialize pip installations across parallel tasks to avoid race conditions. Only applies when use_venv=True. Default is True for safety.
46+
max_concurrent_pip_installs: Maximum number of concurrent pip installations when serialize_pip_installs=False. Default is 1.
4547
"""
4648
use_venv: bool = True
49+
serialize_pip_installs: bool = True
50+
max_concurrent_pip_installs: int = 1
51+
52+
def __post_init__(self):
53+
"""Configure the pip install manager when the runner is created."""
54+
if self.use_venv:
55+
# Lazy import to avoid circular imports
56+
from kfp.local.pip_install_manager import pip_install_manager
57+
pip_install_manager.configure(
58+
serialize_installs=self.serialize_pip_installs,
59+
max_concurrent=self.max_concurrent_pip_installs)
4760

4861

4962
class DockerRunner:
@@ -143,11 +156,14 @@ class DockerRunner:
143156
'working_dir',
144157
}
145158

146-
def __init__(self, **container_run_args):
159+
def __init__(self,
160+
max_concurrent_pip_installs: int = 1,
161+
**container_run_args):
147162
"""Runner constructor, taking any arguments to propagate to
148163
`containers.run` in the `docker` SDK.
149164
150165
Args:
166+
max_concurrent_pip_installs: Maximum number of concurrent pip installations across docker containers. Default is 1.
151167
**container_run_args: Keyword arguments that comport with `containers.run` in the `docker` SDK, with some exceptions (see below).
152168
153169
`containers.run` arguments are supported with the following exceptions:
@@ -183,6 +199,12 @@ def __init__(self, **container_run_args):
183199
)
184200

185201
self.container_run_args = container_run_args
202+
self.max_concurrent_pip_installs = max_concurrent_pip_installs
203+
204+
# Configure docker pip install manager
205+
# Lazy import to avoid circular imports
206+
from kfp.local.pip_install_manager import pip_install_manager
207+
pip_install_manager.configure_docker(max_concurrent_pip_installs)
186208

187209

188210
class LocalExecutionConfig:

0 commit comments

Comments
 (0)