-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the API of kubeflow pipeline from
vineyard.csi.read/writer
t…
…o `client.get/put` (#1614) Signed-off-by: Ye Cao <[email protected]>
- Loading branch information
Showing
22 changed files
with
855 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM python:3.10 | ||
|
||
RUN pip3 install --no-cache-dir pandas requests scikit-learn numpy vineyard | ||
|
||
WORKDIR / | ||
|
||
ARG APP | ||
ENV APP ${APP} | ||
|
||
COPY ${APP} /${APP} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
REGISTRY := "ghcr.io/v6d-io/v6d/kubeflow-example" | ||
docker-build: | ||
docker build prepare-data/ -f Dockerfile \ | ||
--build-arg APP=prepare-data.py \ | ||
-t $(REGISTRY)/prepare-data | ||
|
||
docker build preprocess/ -f Dockerfile \ | ||
--build-arg APP=preprocess.py \ | ||
-t $(REGISTRY)/preprocess-data | ||
|
||
docker build train/ -f Dockerfile \ | ||
--build-arg APP=train.py \ | ||
-t $(REGISTRY)/train-data | ||
|
||
docker build test/ -f Dockerfile \ | ||
--build-arg APP=test.py \ | ||
-t $(REGISTRY)/test-data | ||
|
||
push-images: | ||
docker push $(REGISTRY)/prepare-data | ||
docker push $(REGISTRY)/preprocess-data | ||
docker push $(REGISTRY)/train-data | ||
docker push $(REGISTRY)/test-data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from kfp import dsl | ||
from kubernetes.client.models import V1EnvVar | ||
import kubernetes as k8s | ||
|
||
def PreProcess(data_multiplier: int, registry: str): | ||
vineyard_volume = dsl.PipelineVolume( | ||
volume=k8s.client.V1Volume( | ||
name="vineyard-socket", | ||
host_path=k8s.client.V1HostPathVolumeSource( | ||
path="/var/run/vineyard-kubernetes/vineyard-system/vineyardd-sample" | ||
) | ||
) | ||
) | ||
|
||
op = dsl.ContainerOp( | ||
name='Preprocess Data', | ||
image = f'{registry}/preprocess-data', | ||
container_kwargs={ | ||
'image_pull_policy': "Always", | ||
'env': [V1EnvVar('VINEYARD_IPC_SOCKET', '/var/run/vineyard.sock')] | ||
}, | ||
pvolumes={ | ||
"/data": dsl.PipelineVolume(pvc="benchmark-data"), | ||
"/var/run": vineyard_volume, | ||
}, | ||
command = ['python3', 'preprocess.py'], | ||
arguments=[f'--data_multiplier={data_multiplier}', '--with_vineyard=True'], | ||
) | ||
op.add_pod_label('scheduling.k8s.v6d.io/vineyardd-namespace', 'vineyard-system') | ||
op.add_pod_label('scheduling.k8s.v6d.io/vineyardd', 'vineyardd-sample') | ||
op.add_pod_label('scheduling.k8s.v6d.io/job', 'preprocess-data') | ||
op.add_pod_annotation('scheduling.k8s.v6d.io/required', '') | ||
return op | ||
|
||
def Train(comp1, registry: str): | ||
op = dsl.ContainerOp( | ||
name='Train Data', | ||
image=f'{registry}/train-data', | ||
container_kwargs={ | ||
'image_pull_policy': "Always", | ||
'env': [V1EnvVar('VINEYARD_IPC_SOCKET', '/var/run/vineyard.sock')] | ||
}, | ||
pvolumes={ | ||
"/data": comp1.pvolumes['/data'], | ||
"/var/run": comp1.pvolumes['/var/run'], | ||
}, | ||
command = ['python3', 'train.py'], | ||
arguments=['--with_vineyard=True'], | ||
) | ||
op.add_pod_label('scheduling.k8s.v6d.io/vineyardd-namespace', 'vineyard-system') | ||
op.add_pod_label('scheduling.k8s.v6d.io/vineyardd', 'vineyardd-sample') | ||
op.add_pod_label('scheduling.k8s.v6d.io/job', 'train-data') | ||
op.add_pod_annotation('scheduling.k8s.v6d.io/required', 'preprocess-data') | ||
return op | ||
|
||
def Test(comp2, registry: str): | ||
op = dsl.ContainerOp( | ||
name='Test Data', | ||
image=f'{registry}/test-data', | ||
container_kwargs={ | ||
'image_pull_policy': "Always", | ||
'env': [V1EnvVar('VINEYARD_IPC_SOCKET', '/var/run/vineyard.sock')] | ||
}, | ||
pvolumes={ | ||
"/data": comp2.pvolumes['/data'], | ||
"/var/run": comp2.pvolumes['/var/run'] | ||
}, | ||
command = ['python3', 'test.py'], | ||
arguments=['--with_vineyard=True'], | ||
) | ||
op.add_pod_label('scheduling.k8s.v6d.io/vineyardd-namespace', 'vineyard-system') | ||
op.add_pod_label('scheduling.k8s.v6d.io/vineyardd', 'vineyardd-sample') | ||
op.add_pod_label('scheduling.k8s.v6d.io/job', 'test-data') | ||
op.add_pod_annotation('scheduling.k8s.v6d.io/required', 'train-data') | ||
return op | ||
|
||
@dsl.pipeline( | ||
name='Machine Learning Pipeline', | ||
description='An example pipeline that trains and logs a regression model.' | ||
) | ||
def pipeline(data_multiplier: int, registry: str): | ||
comp1 = PreProcess(data_multiplier=data_multiplier, registry=registry) | ||
comp2 = Train(comp1, registry=registry) | ||
comp3 = Test(comp2, registry=registry) | ||
|
||
if __name__ == '__main__': | ||
from kfp import compiler | ||
compiler.Compiler().compile(pipeline, __file__[:-3]+ '.yaml') |
Oops, something went wrong.