Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v2,sdk.v2): Remove need for base image root access to write artifacts #6530

Closed
wants to merge 8 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
- '{{$}}'
- --function_to_execute
- preprocess
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, preprocess, --pipeline_name,
'{{inputs.parameters.pipeline-name}}', --run_id, $(KFP_RUN_ID), --run_resource,
Expand Down Expand Up @@ -111,7 +111,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -134,11 +135,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: gcr.io/ml-pipeline/kfp-launcher:1.8.6
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
- name: train
container:
Expand Down Expand Up @@ -181,7 +183,7 @@ spec:
- '{{$}}'
- --function_to_execute
- train
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, train, --pipeline_name, '{{inputs.parameters.pipeline-name}}',
--run_id, $(KFP_RUN_ID), --run_resource, workflows.argoproj.io/$(WORKFLOW_ID),
Expand Down Expand Up @@ -219,7 +221,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -241,11 +244,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: gcr.io/ml-pipeline/kfp-launcher:1.8.6
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
arguments:
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ spec:
- '{{$}}'
- --function_to_execute
- preprocess
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, preprocess, --pipeline_name,
'{{inputs.parameters.pipeline-name}}', --run_id, $(KFP_RUN_ID), --run_resource,
Expand Down Expand Up @@ -111,7 +111,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -134,11 +135,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: my-custom-image
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
- name: train
container:
Expand Down Expand Up @@ -181,7 +183,7 @@ spec:
- '{{$}}'
- --function_to_execute
- train
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, train, --pipeline_name, '{{inputs.parameters.pipeline-name}}',
--run_id, $(KFP_RUN_ID), --run_resource, workflows.argoproj.io/$(WORKFLOW_ID),
Expand Down Expand Up @@ -219,7 +221,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:3.7
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -241,11 +244,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: my-custom-image
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
arguments:
parameters:
Expand Down
12 changes: 8 additions & 4 deletions sdk/python/kfp/compiler/v2_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ def update_op(op: dsl.ContainerOp,
launcher_container = dsl.UserContainer(
name="kfp-launcher",
image=image_name,
command=["launcher", "--copy", "/kfp-launcher/launch"],
command=["launcher", "--copy", "/var/run/kfp/bin/launch"],
mirror_volume_mounts=True)

op.add_init_container(launcher_container)
op.add_volume(k8s_client.V1Volume(name='kfp-launcher'))
op.add_volume_mount(
k8s_client.V1VolumeMount(
name='kfp-launcher', mount_path='/kfp-launcher'))
name='kfp-launcher', mount_path='/var/run/kfp'))
op.add_volume(k8s_client.V1Volume(name='gcs'))
op.add_volume_mount(
k8s_client.V1VolumeMount(
name='gcs', mount_path='/gcs'))

# op.command + op.args will have the following sections:
# 1. args passed to kfp-launcher
Expand All @@ -62,7 +66,7 @@ def update_op(op: dsl.ContainerOp,
#
# example:
# - command:
# - /kfp-launcher/launch
# - /var/run/kfp/bin/launch
# - '--mlmd_server_address'
# - $(METADATA_GRPC_SERVICE_HOST)
# - '--mlmd_server_port'
Expand All @@ -88,7 +92,7 @@ def update_op(op: dsl.ContainerOp,
# import xxx
# ...
op.command = [
"/kfp-launcher/launch",
"/var/run/kfp/bin/launch",
"--mlmd_server_address",
"$(METADATA_GRPC_SERVICE_HOST)",
"--mlmd_server_port",
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/kfp/v2/components/types/artifact_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from typing import Dict, Generic, List, Optional, Type, TypeVar, Union

_GCS_LOCAL_MOUNT_PREFIX = '/gcs/'
_MINIO_LOCAL_MOUNT_PREFIX = '/minio/'
_S3_LOCAL_MOUNT_PREFIX = '/s3/'
_MINIO_LOCAL_MOUNT_PREFIX = '/var/run/kfp/artifact/minio/'
_S3_LOCAL_MOUNT_PREFIX = '/var/run/kfp/artifact/s3/'


class Artifact(object):
Expand Down
40 changes: 25 additions & 15 deletions sdk/python/tests/compiler/testdata/uri_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spec:
args: [sh, -c, 'mkdir -p "$(dirname $0)" && python -c "import random; result
= ''heads'' if random.randint(0,1) == 0 else ''tails''; print(result, end='''')"
| tee $0', '{{$.outputs.parameters[''output''].output_file}}']
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, flip-coin, --pipeline_name,
'{{inputs.parameters.pipeline-name}}', --run_id, $(KFP_RUN_ID), --run_resource,
Expand Down Expand Up @@ -72,7 +72,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: python:alpine3.6
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -93,11 +94,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: gcr.io/ml-pipeline/kfp-launcher:1.6.6
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
- name: for-loop-2
inputs:
Expand Down Expand Up @@ -125,7 +127,7 @@ spec:
set -e -x
gsutil cat "$0"
- '{{$.inputs.artifacts[''input_gcs_path''].uri}}'
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, read-from-gcs, --pipeline_name,
'{{inputs.parameters.pipeline-name}}', --run_id, $(KFP_RUN_ID), --run_resource,
Expand Down Expand Up @@ -160,7 +162,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -177,11 +180,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: gcr.io/ml-pipeline/kfp-launcher:1.6.6
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
- name: read-from-gcs-2
container:
Expand All @@ -192,7 +196,7 @@ spec:
set -e -x
gsutil cat "$0"
- '{{$.inputs.artifacts[''input_gcs_path''].uri}}'
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, read-from-gcs-2, --pipeline_name,
'{{inputs.parameters.pipeline-name}}', --run_id, $(KFP_RUN_ID), --run_resource,
Expand Down Expand Up @@ -227,7 +231,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -244,11 +249,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: gcr.io/ml-pipeline/kfp-launcher:1.6.6
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
- name: read-from-gcs-3
container:
Expand All @@ -259,7 +265,7 @@ spec:
set -e -x
gsutil cat "$0"
- '{{$.inputs.artifacts[''input_gcs_path''].uri}}'
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, read-from-gcs-3, --pipeline_name,
'{{inputs.parameters.pipeline-name}}', --run_id, $(KFP_RUN_ID), --run_resource,
Expand Down Expand Up @@ -294,7 +300,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -311,11 +318,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: gcr.io/ml-pipeline/kfp-launcher:1.6.6
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
- name: uri-artifact-pipeline
inputs:
Expand Down Expand Up @@ -377,7 +385,7 @@ spec:
echo "$0" | gsutil cp - "$1"
- '{{$.inputs.parameters[''text'']}}'
- '{{$.outputs.artifacts[''output_gcs_path''].uri}}'
command: [/kfp-launcher/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
command: [/var/run/kfp/bin/launch, --mlmd_server_address, $(METADATA_GRPC_SERVICE_HOST),
--mlmd_server_port, $(METADATA_GRPC_SERVICE_PORT), --runtime_info_json, $(KFP_V2_RUNTIME_INFO),
--container_image, $(KFP_V2_IMAGE), --task_name, write-to-gcs, --pipeline_name,
'{{inputs.parameters.pipeline-name}}', --run_id, $(KFP_RUN_ID), --run_resource,
Expand Down Expand Up @@ -413,7 +421,8 @@ spec:
- configMapRef: {name: metadata-grpc-configmap, optional: true}
image: google/cloud-sdk:slim
volumeMounts:
- {mountPath: /kfp-launcher, name: kfp-launcher}
- {mountPath: /var/run/kfp, name: kfp-launcher}
- {mountPath: /gcs, name: gcs}
inputs:
parameters:
- {name: pipeline-name}
Expand All @@ -433,11 +442,12 @@ spec:
pipelines.kubeflow.org/v2_component: "true"
pipelines.kubeflow.org/enable_caching: "true"
initContainers:
- command: [launcher, --copy, /kfp-launcher/launch]
- command: [launcher, --copy, /var/run/kfp/bin/launch]
image: gcr.io/ml-pipeline/kfp-launcher:1.6.6
name: kfp-launcher
mirrorVolumeMounts: true
volumes:
- {name: gcs}
- {name: kfp-launcher}
arguments:
parameters:
Expand Down
Loading