Skip to content

Commit

Permalink
add read/write test component
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-mccarthy committed Nov 23, 2022
1 parent ee85d11 commit f2d84ae
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2022 The Kubeflow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import dsl
from kfp.dsl import Artifact
from kfp.dsl import ContainerSpec
from kfp.dsl import Output


@dsl.container_component
def container_with_placeholder_in_fstring(
output_artifact: Output[Artifact],
text1: str = 'text!',
):
return ContainerSpec(
image='python:3.7',
command=[
'my_program',
f'prefix-{text1}',
f'{output_artifact.uri}/0',
])


if __name__ == '__main__':
from kfp import compiler
compiler.Compiler().compile(
pipeline_func=container_with_placeholder_in_fstring,
package_path=__file__.replace('.py', '.yaml'))
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
components:
comp-container-with-placeholder-in-fstring:
executorLabel: exec-container-with-placeholder-in-fstring
inputDefinitions:
parameters:
text1:
defaultValue: text!
parameterType: STRING
outputDefinitions:
artifacts:
output_artifact:
artifactType:
schemaTitle: system.Artifact
schemaVersion: 0.0.1
deploymentSpec:
executors:
exec-container-with-placeholder-in-fstring:
container:
command:
- my_program
- prefix-{{$.inputs.parameters['text1']}}
- '{{$.outputs.artifacts[''output_artifact''].uri}}/0'
image: python:3.7
pipelineInfo:
name: container-with-placeholder-in-fstring
root:
dag:
tasks:
container-with-placeholder-in-fstring:
cachingOptions:
enableCache: true
componentRef:
name: comp-container-with-placeholder-in-fstring
inputs:
parameters:
text1:
componentInputParameter: text1
taskInfo:
name: container-with-placeholder-in-fstring
inputDefinitions:
parameters:
text1:
defaultValue: text!
parameterType: STRING
schemaVersion: 2.1.0
sdkVersion: kfp-2.0.0-beta.6
3 changes: 3 additions & 0 deletions sdk/python/test_data/test_data_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ components:
- module: container_with_if_placeholder
name: container_with_if_placeholder
execute: false
- module: container_with_placeholder_in_fstring
name: container_with_placeholder_in_fstring
execute: false
v1_components:
test_data_dir: sdk/python/test_data/v1_component_yaml
read: true
Expand Down

0 comments on commit f2d84ae

Please sign in to comment.