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

feat(backend): support yaml with platform-specific specs #8983

Merged
merged 7 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/src/apiserver/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
)

var ErrorInvalidPipelineSpec = fmt.Errorf("pipeline spec is invalid")
var ErrorInvalidPlatformSpec = fmt.Errorf("Platform spec is invalid")

// inferTemplateFormat infers format from pipeline template.
// There is no guarantee that the template is valid in inferred format, so validation
Expand Down
140 changes: 80 additions & 60 deletions backend/src/apiserver/template/template_test.go

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions backend/src/apiserver/template/testdata/hello_world.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# this is a comment
components:
comp-hello-world:
executorLabel: exec-hello-world
inputDefinitions:
parameters:
text:
type: STRING
deploymentSpec:
executors:
exec-hello-world:
container:
args:
- "--text"
- "{{$.inputs.parameters['text']}}"
command:
- sh
- "-ec"
- |
program_path=$(mktemp)
printf "%s" "$0" > "$program_path"
python3 -u "$program_path" "$@"
- |
def hello_world(text):
print(text)
return text

import argparse
_parser = argparse.ArgumentParser(prog='Hello world', description='')
_parser.add_argument("--text", dest="text", type=str, required=True, default=argparse.SUPPRESS)
_parsed_args = vars(_parser.parse_args())

_outputs = hello_world(**_parsed_args)
image: python:3.7
pipelineInfo:
name: namespace/n1/pipeline/hello-world
root:
dag:
tasks:
hello-world:
cachingOptions:
enableCache: true
componentRef:
name: comp-hello-world
inputs:
parameters:
text:
componentInputParameter: text
taskInfo:
name: hello-world
inputDefinitions:
parameters:
text:
type: STRING
schemaVersion: 2.0.0
sdkVersion: kfp-1.6.5
218 changes: 218 additions & 0 deletions backend/src/apiserver/template/testdata/pipeline_with_volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
# PIPELINE DEFINITION
# Name: my-pipeline
components:
comp-comp:
executorLabel: exec-comp
comp-comp-2:
executorLabel: exec-comp-2
comp-comp-3:
executorLabel: exec-comp-3
comp-createpvc:
executorLabel: exec-createpvc
inputDefinitions:
parameters:
access_modes:
parameterType: LIST
annotations:
isOptional: true
parameterType: STRUCT
pvc_name:
isOptional: true
parameterType: STRING
pvc_name_suffix:
isOptional: true
parameterType: STRING
size:
parameterType: STRING
storage_class:
defaultValue: ''
isOptional: true
parameterType: STRING
volume_name:
isOptional: true
parameterType: STRING
outputDefinitions:
parameters:
name:
parameterType: STRING
comp-deletepvc:
executorLabel: exec-deletepvc
inputDefinitions:
parameters:
pvc_name:
parameterType: STRING
deploymentSpec:
executors:
exec-comp:
container:
args:
- --executor_input
- '{{$}}'
- --function_to_execute
- comp
command:
- sh
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.13'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
- 'program_path=$(mktemp -d)

printf "%s" "$0" > "$program_path/ephemeral_component.py"

python3 -m kfp.components.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@"

'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef comp():\n pass\n\n"
image: python:3.7
exec-comp-2:
container:
args:
- --executor_input
- '{{$}}'
- --function_to_execute
- comp
command:
- sh
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.13'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
- 'program_path=$(mktemp -d)

printf "%s" "$0" > "$program_path/ephemeral_component.py"

python3 -m kfp.components.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@"

'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef comp():\n pass\n\n"
image: python:3.7
exec-comp-3:
container:
args:
- --executor_input
- '{{$}}'
- --function_to_execute
- comp
command:
- sh
- -c
- "\nif ! [ -x \"$(command -v pip)\" ]; then\n python3 -m ensurepip ||\
\ python3 -m ensurepip --user || apt-get install python3-pip\nfi\n\nPIP_DISABLE_PIP_VERSION_CHECK=1\
\ python3 -m pip install --quiet --no-warn-script-location 'kfp==2.0.0-beta.13'\
\ && \"$0\" \"$@\"\n"
- sh
- -ec
- 'program_path=$(mktemp -d)

printf "%s" "$0" > "$program_path/ephemeral_component.py"

python3 -m kfp.components.executor_main --component_module_path "$program_path/ephemeral_component.py" "$@"

'
- "\nimport kfp\nfrom kfp import dsl\nfrom kfp.dsl import *\nfrom typing import\
\ *\n\ndef comp():\n pass\n\n"
image: python:3.7
exec-createpvc:
container:
image: argostub/createpvc
exec-deletepvc:
container:
image: argostub/deletepvc
pipelineInfo:
name: my-pipeline
root:
dag:
tasks:
comp:
cachingOptions:
enableCache: true
componentRef:
name: comp-comp
taskInfo:
name: comp
comp-2:
cachingOptions:
enableCache: true
componentRef:
name: comp-comp-2
dependentTasks:
- comp
taskInfo:
name: comp-2
comp-3:
cachingOptions:
enableCache: true
componentRef:
name: comp-comp-3
taskInfo:
name: comp-3
createpvc:
cachingOptions:
enableCache: true
componentRef:
name: comp-createpvc
inputs:
parameters:
access_modes:
runtimeValue:
constant:
- ReadWriteMany
pvc_name_suffix:
runtimeValue:
constant: -my-pvc
size:
runtimeValue:
constant: 5Gi
storage_class:
runtimeValue:
constant: standard
taskInfo:
name: createpvc
deletepvc:
cachingOptions:
enableCache: true
componentRef:
name: comp-deletepvc
dependentTasks:
- comp-2
- createpvc
inputs:
parameters:
pvc_name:
taskOutputParameter:
outputParameterKey: name
producerTask: createpvc
taskInfo:
name: deletepvc
schemaVersion: 2.1.0
sdkVersion: kfp-2.0.0-beta.13
---
platforms:
kubernetes:
deploymentSpec:
executors:
exec-comp:
pvcMount:
- mountPath: /data
taskOutputParameter:
outputParameterKey: name
producerTask: createpvc
exec-comp-2:
pvcMount:
- mountPath: /reused_data
taskOutputParameter:
outputParameterKey: name
producerTask: createpvc
exec-comp-3:
pvcMount:
- constant: my-existing-pvc
mountPath: /data
Loading