forked from red-hat-data-services/ods-ci
-
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.
Merge branch 'master' into fix/macos-mktemp
- Loading branch information
Showing
20 changed files
with
837 additions
and
67 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
8 changes: 8 additions & 0 deletions
8
...ources/Files/pipeline-samples/v2/pip_index_url/configmap-ds-pipeline-custom-env-vars.yaml
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,8 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: ds-pipeline-custom-env-vars | ||
namespace: my-project | ||
data: | ||
pip_index_url: 'https://pypi.org/simple' | ||
pip_trusted_host: pypi.org |
50 changes: 50 additions & 0 deletions
50
ods_ci/tests/Resources/Files/pipeline-samples/v2/pip_index_url/hello_world_pip_index_url.py
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,50 @@ | ||
"""Hello world pipeline for pip_index_url clusters | ||
This is an example of setting pip_index_url in a pipeline task | ||
obtaining the value from a ConfigMap, in order to be able to run | ||
the pipeline in a pip_index_url environment. | ||
The pipeline reads the values from a ConfigMap (ds-pipeline-custom-env-vars) | ||
and creates the environment variables PIP_INDEX_URL and PIP_TRUSTED_HOST | ||
in the pipeline task. | ||
Note: when compiling the pipeline, the resulting yaml file only uses | ||
PIP_INDEX_URL (this is a limitation of kfp 2.7.0). We need to manually | ||
modify the yaml file to use PIP_TRUSTED_HOST. | ||
""" | ||
from kfp import compiler, dsl | ||
from kfp import kubernetes | ||
|
||
common_base_image = "registry.redhat.io/ubi8/python-39@sha256:3523b184212e1f2243e76d8094ab52b01ea3015471471290d011625e1763af61" | ||
|
||
|
||
@dsl.component(base_image=common_base_image, | ||
pip_index_urls=['$PIP_INDEX_URL']) | ||
def print_message(message: str): | ||
import os | ||
"""Prints a message""" | ||
print("------------------------------------------------------------------") | ||
print(message) | ||
print('pip_index_url:' + os.environ['PIP_INDEX_URL']) | ||
print('pip_trusted_host:' + os.environ['PIP_TRUSTED_HOST']) | ||
print("------------------------------------------------------------------") | ||
|
||
|
||
@dsl.pipeline(name="hello-world-pipeline", description="Pipeline that prints a hello message") | ||
def hello_world_pipeline(message: str = "Hello world"): | ||
print_message_task = print_message(message=message) | ||
print_message_task.set_caching_options(False) | ||
|
||
kubernetes.use_config_map_as_env(print_message_task, | ||
config_map_name='ds-pipeline-custom-env-vars', | ||
config_map_key_to_env={'pip_index_url': 'PIP_INDEX_URL'}) | ||
|
||
kubernetes.use_config_map_as_env(print_message_task, | ||
config_map_name='ds-pipeline-custom-env-vars', | ||
config_map_key_to_env={'pip_trusted_host': 'PIP_TRUSTED_HOST'}) | ||
|
||
|
||
if __name__ == "__main__": | ||
compiler.Compiler().compile(hello_world_pipeline, | ||
package_path=__file__.replace(".py", "_compiled.yaml")) |
85 changes: 85 additions & 0 deletions
85
...Resources/Files/pipeline-samples/v2/pip_index_url/hello_world_pip_index_url_compiled.yaml
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,85 @@ | ||
# PIPELINE DEFINITION | ||
# Name: hello-world-pipeline | ||
# Description: Pipeline that prints a hello message | ||
# Inputs: | ||
# message: str [Default: 'Hello world'] | ||
components: | ||
comp-print-message: | ||
executorLabel: exec-print-message | ||
inputDefinitions: | ||
parameters: | ||
message: | ||
parameterType: STRING | ||
deploymentSpec: | ||
executors: | ||
exec-print-message: | ||
container: | ||
args: | ||
- --executor_input | ||
- '{{$}}' | ||
- --function_to_execute | ||
- print_message | ||
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 --index-url $PIP_INDEX_URL\ | ||
\ --trusted-host $PIP_TRUSTED_HOST 'kfp==2.7.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 print_message(message: str):\n import os\n \"\"\"Prints\ | ||
\ a message\"\"\"\n print(\"------------------------------------------------------------------\"\ | ||
)\n print(message)\n print('pip_index_url:' + os.environ['PIP_INDEX_URL'])\n\ | ||
\ print('pip_trusted_host:' + os.environ['PIP_TRUSTED_HOST'])\n print(\"\ | ||
------------------------------------------------------------------\")\n\n" | ||
image: registry.redhat.io/ubi8/python-39@sha256:3523b184212e1f2243e76d8094ab52b01ea3015471471290d011625e1763af61 | ||
pipelineInfo: | ||
description: Pipeline that prints a hello message | ||
name: hello-world-pipeline | ||
root: | ||
dag: | ||
tasks: | ||
print-message: | ||
cachingOptions: {} | ||
componentRef: | ||
name: comp-print-message | ||
inputs: | ||
parameters: | ||
message: | ||
componentInputParameter: message | ||
taskInfo: | ||
name: print-message | ||
inputDefinitions: | ||
parameters: | ||
message: | ||
defaultValue: Hello world | ||
isOptional: true | ||
parameterType: STRING | ||
schemaVersion: 2.1.0 | ||
sdkVersion: kfp-2.7.0 | ||
--- | ||
platforms: | ||
kubernetes: | ||
deploymentSpec: | ||
executors: | ||
exec-print-message: | ||
configMapAsEnv: | ||
- configMapName: ds-pipeline-custom-env-vars | ||
keyToEnv: | ||
- configMapKey: pip_index_url | ||
envVar: PIP_INDEX_URL | ||
- configMapName: ds-pipeline-custom-env-vars | ||
keyToEnv: | ||
- configMapKey: pip_trusted_host | ||
envVar: PIP_TRUSTED_HOST |
Oops, something went wrong.