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

Support disconnected environment for Pipeline SDK tests #1730

Merged
merged 1 commit into from
Aug 21, 2024
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
38 changes: 35 additions & 3 deletions ods_ci/libs/DataSciencePipelinesKfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import json
import os
import sys
import tempfile
import time

from DataSciencePipelinesAPI import DataSciencePipelinesAPI
from kfp import compiler
from kfp.client import Client
from robotlibcore import keyword

Expand Down Expand Up @@ -89,7 +91,17 @@ def delete_run(self, run_id):

@keyword
def create_run_from_pipeline_func(
self, user, pwd, project, source_code, fn, pipeline_params={}, current_path=None, route_name="ds-pipeline-dspa"
self,
user,
pwd,
project,
source_code,
fn,
pipeline_params={},
current_path=None,
route_name="ds-pipeline-dspa",
pip_index_url=None,
pip_trusted_host=None,
):
print(f"pipeline_params: {pipeline_params}")
client, api = self.get_client(user, pwd, project, route_name)
Expand All @@ -101,7 +113,7 @@ def create_run_from_pipeline_func(
if current_path is None:
current_path = os.getcwd()
my_source = self.import_souce_code(f"{current_path}/tests/Resources/Files/pipeline-samples/v2/{source_code}")
pipeline = getattr(my_source, fn)
pipeline_func = getattr(my_source, fn)

# pipeline_params
# there are some special keys to retrieve argument values dynamically
Expand All @@ -118,7 +130,27 @@ def create_run_from_pipeline_func(

# create_run_from_pipeline_func will compile the code
# if you need to see the yaml, for debugging purpose, call: TektonCompiler().compile(pipeline, f'{fn}.yaml')
result = client.create_run_from_pipeline_func(pipeline_func=pipeline, arguments=pipeline_params)
with tempfile.TemporaryDirectory() as tmpdir:
pipeline_package_path = os.path.join(tmpdir, "pipeline.yaml")
compiler.Compiler().compile(
pipeline_func=pipeline_func,
package_path=pipeline_package_path,
)

if pip_index_url is not None:
assert pip_trusted_host is not None
with open(pipeline_package_path, "r") as file:
file_content = file.read()
file_content = file_content.replace(
"python3 -m pip install",
f"python3 -m pip install --index-url {pip_index_url} --trusted-host {pip_trusted_host}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @diegolovison , could we remove --trusted-host {pip_trusted_host}?
We would like to cover also self-signed certs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. This is related to kubeflow/pipelines#10720

)
with open(pipeline_package_path, "w") as file:
file.write(file_content)

result = client.create_run_from_pipeline_package(
pipeline_file=pipeline_package_path, arguments=pipeline_params
)
# easy to debug and double check failures
print(result)
return result.run_id
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ End To End Pipeline Workflow Using Kfp
IF ${ray} == ${TRUE}
Setup Kueue Resources ${project} cluster-queue-user resource-flavor-user local-queue-user
END
# The run_robot_test.sh is sending the --variablefile ${TEST_VARIABLES_FILE} which may contain the `PIP_INDEX_URL`
# and `PIP_TRUSTED_HOST` variables, e.g. for disconnected testing.
${pip_index_url} = Get Variable Value ${PIP_INDEX_URL} ${NONE}
${pip_trusted_host} = Get Variable Value ${PIP_TRUSTED_HOST} ${NONE}
Log pip_index_url = ${pip_index_url} / pip_trusted_host = ${pip_trusted_host}
${run_id} Create Run From Pipeline Func ${username} ${password} ${project}
... ${python_file} ${method_name} pipeline_params=${pipeline_params}
... ${python_file} ${method_name} pipeline_params=${pipeline_params} pip_index_url=${pip_index_url}
... pip_trusted_host=${pip_trusted_host}
${run_status} Check Run Status ${run_id} timeout=500
Should Be Equal As Strings ${run_status} SUCCEEDED Pipeline run doesn't have a status that means success. Check the logs
Remove Pipeline Project ${project}
Expand Down
Loading