forked from opendatahub-io/data-science-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - do not merge - support parameter inputs in kfp-kubernetes
proof of concept for supporting parameter inputs in kfp-kubernetes. We've added support first to secret.py. Ref: kubeflow#10534 Ref: kubeflow#10914
- Loading branch information
1 parent
bbfb589
commit 3844a58
Showing
10 changed files
with
355 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from kfp import dsl | ||
from kfp import kubernetes | ||
|
||
|
||
@dsl.component | ||
def comp(): | ||
pass | ||
|
||
@dsl.pipeline | ||
def my_pipeline(my_secret: str): | ||
task = comp() | ||
task.set_caching_options(False) | ||
|
||
kubernetes.use_secret_as_volume( | ||
task, | ||
secret_name=my_secret, | ||
mount_path='/mnt/my_secret', | ||
) |
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,65 @@ | ||
# PIPELINE DEFINITION | ||
# Name: my-pipeline | ||
# Inputs: | ||
# my_secret: str | ||
components: | ||
comp-comp: | ||
executorLabel: exec-comp | ||
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.8.0'\ | ||
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\ | ||
$0\" \"$@\"\n" | ||
- sh | ||
- -ec | ||
- 'program_path=$(mktemp -d) | ||
printf "%s" "$0" > "$program_path/ephemeral_component.py" | ||
_KFP_RUNTIME=true python3 -m kfp.dsl.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.8 | ||
pipelineInfo: | ||
name: my-pipeline | ||
root: | ||
dag: | ||
tasks: | ||
comp: | ||
cachingOptions: | ||
enableCache: false | ||
componentRef: | ||
name: comp-comp | ||
taskInfo: | ||
name: comp | ||
inputDefinitions: | ||
parameters: | ||
my_secret: | ||
parameterType: STRING | ||
schemaVersion: 2.1.0 | ||
sdkVersion: kfp-2.8.0 | ||
--- | ||
platforms: | ||
kubernetes: | ||
deploymentSpec: | ||
executors: | ||
exec-comp: | ||
secretAsVolume: | ||
- mountPath: /mnt/my_secret | ||
optional: false | ||
secretName: '{{my_secret}}' |
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,18 @@ | ||
from kfp import dsl | ||
from kfp import kubernetes | ||
|
||
|
||
@dsl.component | ||
def comp(): | ||
pass | ||
|
||
@dsl.pipeline | ||
def my_pipeline(my_secret: str = 'some-default-secret'): | ||
task = comp() | ||
task.set_caching_options(False) | ||
|
||
kubernetes.use_secret_as_volume( | ||
task, | ||
secret_name=my_secret, | ||
mount_path='/mnt/my_secret', | ||
) |
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,67 @@ | ||
# PIPELINE DEFINITION | ||
# Name: my-pipeline | ||
# Inputs: | ||
# my_secret: str [Default: 'some-default-secret'] | ||
components: | ||
comp-comp: | ||
executorLabel: exec-comp | ||
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.8.0'\ | ||
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\ | ||
$0\" \"$@\"\n" | ||
- sh | ||
- -ec | ||
- 'program_path=$(mktemp -d) | ||
printf "%s" "$0" > "$program_path/ephemeral_component.py" | ||
_KFP_RUNTIME=true python3 -m kfp.dsl.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.8 | ||
pipelineInfo: | ||
name: my-pipeline | ||
root: | ||
dag: | ||
tasks: | ||
comp: | ||
cachingOptions: | ||
enableCache: false | ||
componentRef: | ||
name: comp-comp | ||
taskInfo: | ||
name: comp | ||
inputDefinitions: | ||
parameters: | ||
my_secret: | ||
defaultValue: some-default-secret | ||
isOptional: true | ||
parameterType: STRING | ||
schemaVersion: 2.1.0 | ||
sdkVersion: kfp-2.8.0 | ||
--- | ||
platforms: | ||
kubernetes: | ||
deploymentSpec: | ||
executors: | ||
exec-comp: | ||
secretAsVolume: | ||
- mountPath: /mnt/my_secret | ||
optional: false | ||
secretName: '{{my_secret}}' |
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,17 @@ | ||
from kfp import dsl | ||
from kfp import kubernetes | ||
|
||
|
||
@dsl.component | ||
def comp(): | ||
pass | ||
|
||
@dsl.pipeline | ||
def my_pipeline(): | ||
task = comp() | ||
|
||
kubernetes.use_secret_as_volume( | ||
task, | ||
secret_name='my-hardcoded-secret', | ||
mount_path='/mnt/my_secret', | ||
) |
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,59 @@ | ||
# PIPELINE DEFINITION | ||
# Name: my-pipeline | ||
components: | ||
comp-comp: | ||
executorLabel: exec-comp | ||
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.8.0'\ | ||
\ '--no-deps' 'typing-extensions>=3.7.4,<5; python_version<\"3.9\"' && \"\ | ||
$0\" \"$@\"\n" | ||
- sh | ||
- -ec | ||
- 'program_path=$(mktemp -d) | ||
printf "%s" "$0" > "$program_path/ephemeral_component.py" | ||
_KFP_RUNTIME=true python3 -m kfp.dsl.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.8 | ||
pipelineInfo: | ||
name: my-pipeline | ||
root: | ||
dag: | ||
tasks: | ||
comp: | ||
cachingOptions: | ||
enableCache: true | ||
componentRef: | ||
name: comp-comp | ||
taskInfo: | ||
name: comp | ||
schemaVersion: 2.1.0 | ||
sdkVersion: kfp-2.8.0 | ||
--- | ||
platforms: | ||
kubernetes: | ||
deploymentSpec: | ||
executors: | ||
exec-comp: | ||
secretAsVolume: | ||
- mountPath: /mnt/my_secret | ||
optional: false | ||
secretName: my-hardcoded-secret |
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,19 @@ | ||
from kfp import dsl | ||
from kfp import kubernetes | ||
|
||
|
||
@dsl.component | ||
def comp(): | ||
pass | ||
|
||
@dsl.pipeline | ||
def my_pipeline(): | ||
task = comp() | ||
|
||
my_secret = 'my-hardcoded-secret2' | ||
|
||
kubernetes.use_secret_as_volume( | ||
task, | ||
secret_name=my_secret, | ||
mount_path='/mnt/my_secret', | ||
) |
Oops, something went wrong.