-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): add set_env_variable for Pipeline task (#6919)
* feat(sdk): add set_env_variable * release notes * enable test * fix test * fix test * address comments
- Loading branch information
Showing
8 changed files
with
118 additions
and
102 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
170 changes: 83 additions & 87 deletions
170
sdk/python/kfp/v2/compiler_cli_tests/test_data/pipeline_with_env.json
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 |
---|---|---|
@@ -1,98 +1,94 @@ | ||
{ | ||
"pipelineSpec": { | ||
"components": { | ||
"comp-print-env": { | ||
"executorLabel": "exec-print-env" | ||
"components": { | ||
"comp-print-env": { | ||
"executorLabel": "exec-print-env" | ||
}, | ||
"comp-print-env-op": { | ||
"executorLabel": "exec-print-env-op" | ||
} | ||
}, | ||
"defaultPipelineRoot": "dummy_root", | ||
"deploymentSpec": { | ||
"executors": { | ||
"exec-print-env": { | ||
"container": { | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"set -e -x\necho \"$ENV2\"\necho \"$ENV3\"\n" | ||
], | ||
"env": [ | ||
{ | ||
"name": "ENV2", | ||
"value": "val2" | ||
}, | ||
{ | ||
"name": "ENV3", | ||
"value": "val3" | ||
} | ||
], | ||
"image": "alpine" | ||
} | ||
}, | ||
"comp-print-env-op": { | ||
"executorLabel": "exec-print-env-op" | ||
"exec-print-env-op": { | ||
"container": { | ||
"args": [ | ||
"--executor_input", | ||
"{{$}}", | ||
"--function_to_execute", | ||
"print_env_op" | ||
], | ||
"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==1.8.9' && \"$0\" \"$@\"\n", | ||
"sh", | ||
"-ec", | ||
"program_path=$(mktemp -d)\nprintf \"%s\" \"$0\" > \"$program_path/ephemeral_component.py\"\npython3 -m kfp.v2.components.executor_main --component_module_path \"$program_path/ephemeral_component.py\" \"$@\"\n", | ||
"\nimport kfp\nfrom kfp.v2 import dsl\nfrom kfp.v2.dsl import *\nfrom typing import *\n\ndef print_env_op():\n import os\n print(os.environ['ENV1'])\n\n" | ||
], | ||
"env": [ | ||
{ | ||
"name": "ENV1", | ||
"value": "val1" | ||
} | ||
], | ||
"image": "python:3.7" | ||
} | ||
} | ||
}, | ||
"deploymentSpec": { | ||
"executors": { | ||
"exec-print-env": { | ||
"container": { | ||
"command": [ | ||
"sh", | ||
"-c", | ||
"set -e -x\necho \"$ENV2\"\necho \"$ENV3\"\n" | ||
], | ||
"env": [ | ||
{ | ||
"name": "ENV2", | ||
"value": "val2" | ||
}, | ||
{ | ||
"name": "ENV3", | ||
"value": "val3" | ||
} | ||
], | ||
"image": "alpine" | ||
} | ||
}, | ||
"pipelineInfo": { | ||
"name": "pipeline-with-env" | ||
}, | ||
"root": { | ||
"dag": { | ||
"tasks": { | ||
"print-env": { | ||
"cachingOptions": { | ||
"enableCache": true | ||
}, | ||
"componentRef": { | ||
"name": "comp-print-env" | ||
}, | ||
"taskInfo": { | ||
"name": "print-env" | ||
} | ||
}, | ||
"exec-print-env-op": { | ||
"container": { | ||
"args": [ | ||
"--executor_input", | ||
"{{$}}", | ||
"--function_to_execute", | ||
"print_env_op" | ||
], | ||
"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==1.8.6' && \"$0\" \"$@\"\n", | ||
"sh", | ||
"-ec", | ||
"program_path=$(mktemp -d)\nprintf \"%s\" \"$0\" > \"$program_path/ephemeral_component.py\"\npython3 -m kfp.v2.components.executor_main --component_module_path \"$program_path/ephemeral_component.py\" \"$@\"\n", | ||
"\nimport kfp\nfrom kfp.v2 import dsl\nfrom kfp.v2.dsl import *\nfrom typing import *\n\ndef print_env_op():\n import os\n print(os.environ['ENV1'])\n\n" | ||
], | ||
"env": [ | ||
{ | ||
"name": "ENV1", | ||
"value": "val1" | ||
} | ||
], | ||
"image": "python:3.7" | ||
} | ||
} | ||
} | ||
}, | ||
"pipelineInfo": { | ||
"name": "pipeline-with-env" | ||
}, | ||
"root": { | ||
"dag": { | ||
"tasks": { | ||
"print-env": { | ||
"cachingOptions": { | ||
"enableCache": true | ||
}, | ||
"componentRef": { | ||
"name": "comp-print-env" | ||
}, | ||
"taskInfo": { | ||
"name": "print-env" | ||
} | ||
"print-env-op": { | ||
"cachingOptions": { | ||
"enableCache": true | ||
}, | ||
"print-env-op": { | ||
"cachingOptions": { | ||
"enableCache": true | ||
}, | ||
"componentRef": { | ||
"name": "comp-print-env-op" | ||
}, | ||
"taskInfo": { | ||
"name": "print-env-op" | ||
} | ||
"componentRef": { | ||
"name": "comp-print-env-op" | ||
}, | ||
"taskInfo": { | ||
"name": "print-env-op" | ||
} | ||
} | ||
} | ||
}, | ||
"schemaVersion": "2.1.0", | ||
"sdkVersion": "kfp-1.8.6" | ||
} | ||
}, | ||
"runtimeConfig": { | ||
"gcsOutputDirectory": "dummy_root" | ||
} | ||
"schemaVersion": "2.1.0", | ||
"sdkVersion": "kfp-1.8.9" | ||
} |
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ def print_env_op(): | |
implementation: | ||
container: | ||
image: alpine | ||
command: | ||
commands: | ||
- sh | ||
- -c | ||
- | | ||
|
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