Skip to content

Commit e25ce49

Browse files
committed
Ray and Pipelines integration test
1 parent b7f8664 commit e25ce49

File tree

4 files changed

+118
-5
lines changed

4 files changed

+118
-5
lines changed

ods_ci/libs/DataSciencePipelinesAPI.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ def get_default_storage(self):
310310
break
311311
return storage_class['metadata']['name']
312312

313+
def get_openshift_server(self):
314+
return self.run_oc('oc whoami --show-server=true')[0].replace('\n', '')
315+
316+
def get_openshift_token(self):
317+
return self.run_oc('oc whoami --show-token=true')[0].replace('\n', '')
318+
313319
def run_oc(self, command):
314320
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
315321
output, error = process.communicate()

ods_ci/libs/DataSciencePipelinesKfpTekton.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ def kfp_tekton_create_run_from_pipeline_func(
111111
result = client.create_run_from_pipeline_func(
112112
pipeline_func=pipeline, arguments={
113113
'mlpipeline_minio_artifact_secret': mlpipeline_minio_artifact_secret["data"],
114-
'bucket_name': bucket_name
114+
'bucket_name': bucket_name,
115+
'openshift_server': self.api.get_openshift_server(),
116+
'openshift_token': self.api.get_openshift_token()
115117
}
116118
)
117119
# easy to debug and double check failures
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
from kfp import components, dsl
2+
from ods_ci.libs.DataSciencePipelinesKfpTekton import DataSciencePipelinesKfpTekton
3+
4+
5+
def ray_fn(openshift_server:str, openshift_token:str) -> int:
6+
from codeflare_sdk.cluster.cluster import Cluster, ClusterConfiguration
7+
from codeflare_sdk.cluster.auth import TokenAuthentication
8+
import ray
9+
10+
print('before login')
11+
auth = TokenAuthentication(
12+
token=openshift_token,
13+
server=openshift_server,
14+
skip_tls=True
15+
)
16+
auth_return = auth.login()
17+
print(f'auth_return: "{auth_return}"')
18+
print('after login')
19+
cluster = Cluster(ClusterConfiguration(
20+
name='raytest',
21+
# namespace must exist, and it is the same from 432__data-science-pipelines-tekton.robot
22+
namespace='pipelineskfptekton1',
23+
num_workers=1,
24+
head_cpus='500m',
25+
min_memory=1,
26+
max_memory=1,
27+
num_gpus=0,
28+
image="quay.io/project-codeflare/ray:latest-py39-cu118",
29+
instascale=False
30+
))
31+
# workaround for https://github.com/project-codeflare/codeflare-sdk/pull/412
32+
cluster_file_name = '/opt/app-root/src/.codeflare/appwrapper/raytest.yaml'
33+
# Read in the file
34+
with open(cluster_file_name, 'r') as file:
35+
filedata = file.read()
36+
37+
# Replace the target string
38+
filedata = filedata.replace('busybox:1.28', 'quay.io/project-codeflare/busybox:latest')
39+
40+
# Write the file out again
41+
with open(cluster_file_name, 'w') as file:
42+
file.write(filedata)
43+
# end workaround
44+
45+
# always clean the resources
46+
cluster.down()
47+
print(cluster.status())
48+
cluster.up()
49+
cluster.wait_ready()
50+
print(cluster.status())
51+
print(cluster.details())
52+
53+
ray_dashboard_uri = cluster.cluster_dashboard_uri()
54+
ray_cluster_uri = cluster.cluster_uri()
55+
print(ray_dashboard_uri)
56+
print(ray_cluster_uri)
57+
58+
# before proceeding make sure the cluster exists and the uri is not empty
59+
assert ray_cluster_uri, "Ray cluster needs to be started and set before proceeding"
60+
61+
# reset the ray context in case there's already one.
62+
ray.shutdown()
63+
# establish connection to ray cluster
64+
ray.init(address=ray_cluster_uri)
65+
print("Ray cluster is up and running: ", ray.is_initialized())
66+
67+
@ray.remote
68+
def train_fn():
69+
return 100
70+
71+
result = ray.get(train_fn.remote())
72+
assert 100 == result
73+
ray.shutdown()
74+
cluster.down()
75+
auth.logout()
76+
return result
77+
78+
79+
@dsl.pipeline(
80+
name="Ray Integration Test",
81+
description="Ray Integration Test",
82+
)
83+
def ray_integration(openshift_server, openshift_token):
84+
ray_op = components.create_component_from_func(
85+
ray_fn, base_image=DataSciencePipelinesKfpTekton.base_image,
86+
packages_to_install=['codeflare-sdk']
87+
)
88+
ray_op(openshift_server, openshift_token)

ods_ci/tests/Tests/400__ods_dashboard/430__data_science_pipelines/432__data-science-pipelines-tekton.robot

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,20 @@ ${PROJECT_NAME}= pipelineskfptekton1
2020

2121

2222
*** Test Cases ***
23-
Verify Ods Users Can Create And Run A Data Science Pipeline Using The Kfp_tekton Python Package
23+
Verify Ods Users Can Create And Run A Data Science Pipeline Using The kfp_tekton Python Package
2424
[Documentation] Creates, runs pipelines with regular user. Double check the pipeline result and clean
2525
... the pipeline resources.
2626
[Tags] Sanity
2727
... Tier1
2828
... ODS-2203
29-
30-
End To End Pipeline Workflow Using Kfp_tekton
29+
End To End Pipeline Workflow Using Kfp Tekton
3130
... username=${TEST_USER.USERNAME}
3231
... password=${TEST_USER.PASSWORD}
3332
... project=${PROJECT_NAME}
3433
... python_file=flip_coin.py
3534
... method_name=flipcoin_pipeline
3635
... status_check_timeout=440
37-
End To End Pipeline Workflow Using Kfp_tekton
36+
End To End Pipeline Workflow Using Kfp Tekton
3837
... username=${TEST_USER.USERNAME}
3938
... password=${TEST_USER.PASSWORD}
4039
... project=${PROJECT_NAME}
@@ -44,6 +43,24 @@ Verify Ods Users Can Create And Run A Data Science Pipeline Using The Kfp_tekton
4443
[Teardown] Remove Pipeline Project ${PROJECT_NAME}
4544

4645

46+
Verify Ods Users Can Create And Run A Data Science Pipeline With Ray Using The kfp_tekton Python Package
47+
[Documentation] Creates, runs pipelines with regular user. Double check the pipeline result and clean
48+
... the pipeline resources.
49+
[Tags] Sanity
50+
... Tier1
51+
... ODS-2541
52+
Skip If Component Is Not Enabled ray
53+
Skip If Component Is Not Enabled codeflare
54+
End To End Pipeline Workflow Using Kfp Tekton
55+
... username=${TEST_USER.USERNAME}
56+
... password=${TEST_USER.PASSWORD}
57+
... project=${PROJECT_NAME}
58+
... python_file=ray_integration.py
59+
... method_name=ray_integration
60+
... status_check_timeout=440
61+
[Teardown] Remove Pipeline Project ${PROJECT_NAME}
62+
63+
4764
*** Keywords ***
4865
# robocop: disable:line-too-long
4966
End To End Pipeline Workflow Using Kfp Tekton

0 commit comments

Comments
 (0)