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

Load performance test pipelines from files #796

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 sdk/python/kfp_tekton/compiler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def compile_pyfile(pyfile, function_name, output_path, type_check, tekton_pipeli
_compile_pipeline_function(pipeline_funcs, function_name, output_path, type_check, tekton_pipeline_conf)
finally:
del sys.path[0]
sys.modules.pop(os.path.splitext(filename)[0])
Copy link
Member Author

@ckadner ckadner Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Python caches previsously loaded modules, this change was required to allow using the compile_pyfile() method multiple times within the same Python process and enable loading different pipeline scripts from files with the same ("module") name, i.e. we have multiple condition.py samples.

Without this change, we would get these errors:

ValueError trying to compile /Users/ckadner/PycharmProjects/kfp-tekton_ckadner/samples/flip-coin/condition.py: A function with @dsl.pipeline decorator is required in the py file.
ValueError trying to compile /Users/ckadner/PycharmProjects/kfp-tekton_ckadner/samples/flip-coin-custom-task/condition.py: A function with @dsl.pipeline decorator is required in the py file.

See: https://stackoverflow.com/questions/32234156/how-to-unimport-a-python-module-which-is-already-imported/57891909#57891909



def main():
Expand Down
39 changes: 39 additions & 0 deletions sdk/python/tests/perf_test_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2021 kubeflow.org
#
# 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.

# pipelines to be loaded in performance_test.py
# relative paths are assumed to be relative to the project root
pipeline_scripts:
# - name: "Sequential"
# path: "sdk/python/tests/compiler/testdata/sequential.py"
# - name: "Flip-Coin-testdata"
# path: "sdk/python/tests/compiler/testdata/condition.py"
# - name: "Retry"
# path: "sdk/python/tests/compiler/testdata/retry.py"
# - name: "Loop-Static"
# path: "sdk/python/tests/compiler/testdata/loop_static.py"
# - name: "Conditions-and-Loops"
# path: "sdk/python/tests/compiler/testdata/conditions_and_loops.py"
# - name: "With-item-Nested"
# path: "sdk/python/tests/compiler/testdata/withitem_nested.py"
# - name: "Condition-and-recur"
# path: "sdk/python/tests/compiler/testdata/cond_recur.py"
- name: "Flip-Coin-samples"
path: "samples/flip-coin/condition.py" # condition with simple python
ckadner marked this conversation as resolved.
Show resolved Hide resolved
- name: "Flip-Coin-Custom-Task"
path: "samples/flip-coin-custom-task/condition.py" # custom task condition with simple python
- path: "samples/lightweight-component/calc_pipeline.py" # python in script with package install
- path: "samples/trusted-ai/trusted-ai.py" # long-running python component with S3 file passing
- path: "samples/nested-loops/withitem_nested.py" # nested loop pipelines, many CRDs
# - path: "sdk/python/tests/compiler/testdata/cond_recur.yaml" # never finishes, calling itself 42 times recursively, controller cannot estimate duration
Loading