@@ -21,6 +21,7 @@ import (
2121 "testing"
2222
2323 . "github.com/onsi/gomega"
24+ . "github.com/opendatahub-io/distributed-workloads/tests/common"
2425 . "github.com/project-codeflare/codeflare-common/support"
2526
2627 v1 "k8s.io/api/core/v1"
@@ -33,7 +34,7 @@ func TestMnistSDK(t *testing.T) {
3334 userName := GetNotebookUserName (test )
3435 userToken := GetNotebookUserToken (test )
3536 jupyterNotebookConfigMapFileName := "mnist_kfto.ipynb"
36- mnist := readMnistScriptTemplate (test , "resources/kfto_sdk_mnist.py" )
37+ mnist := ParseAWSArgs (test , readFile ( test , "resources/kfto_sdk_mnist.py" ) )
3738
3839 // Create role binding with Namespace specific admin cluster role
3940 CreateUserRoleBindingWithClusterRole (test , userName , namespace .Name , "admin" )
@@ -45,8 +46,8 @@ func TestMnistSDK(t *testing.T) {
4546 "${namespace}" : namespace .Name ,
4647 }
4748
48- jupyterNotebook := string (ReadFile (test , "resources/mnist_kfto.ipynb" ))
49- requirements := ReadFile (test , "resources/requirements.txt" )
49+ jupyterNotebook := string (readFile (test , "resources/mnist_kfto.ipynb" ))
50+ requirements := readFile (test , "resources/requirements.txt" )
5051 for oldValue , newValue := range requiredChangesInNotebook {
5152 jupyterNotebook = strings .Replace (string (jupyterNotebook ), oldValue , newValue , - 1 )
5253 }
@@ -57,13 +58,21 @@ func TestMnistSDK(t *testing.T) {
5758 "requirements.txt" : requirements ,
5859 })
5960
61+ notebookCommand := []string {
62+ "bin/sh" ,
63+ "-c" ,
64+ "pip install papermill && papermill /opt/app-root/notebooks/{{.NotebookConfigMapFileName}}" +
65+ " /opt/app-root/src/mcad-out.ipynb -p namespace {{.Namespace}} -p openshift_api_url {{.OpenShiftApiUrl}}" +
66+ " -p kubernetes_user_bearer_token {{.KubernetesUserBearerToken}}" +
67+ " -p num_gpus {{ .NumGpus }} --log-output && sleep infinity" ,
68+ }
6069 // Create Notebook CR
61- createNotebook (test , namespace , userToken , config .Name , jupyterNotebookConfigMapFileName , 0 )
70+ CreateNotebook (test , namespace , userToken , notebookCommand , config .Name , jupyterNotebookConfigMapFileName , 0 )
6271
6372 // Gracefully cleanup Notebook
6473 defer func () {
65- deleteNotebook (test , namespace )
66- test .Eventually (listNotebooks (test , namespace ), TestTimeoutGpuProvisioning ).Should (HaveLen (0 ))
74+ DeleteNotebook (test , namespace )
75+ test .Eventually (ListNotebooks (test , namespace ), TestTimeoutGpuProvisioning ).Should (HaveLen (0 ))
6776 }()
6877
6978 // Make sure pytorch job is created
@@ -77,40 +86,3 @@ func TestMnistSDK(t *testing.T) {
7786 // TODO: write torch job logs?
7887 // time.Sleep(60 * time.Second)
7988}
80-
81- func readMnistScriptTemplate (test Test , filePath string ) []byte {
82- // Read the mnist.py from resources and perform replacements for custom values using go template
83- storage_bucket_endpoint , storage_bucket_endpoint_exists := GetStorageBucketDefaultEndpoint ()
84- storage_bucket_access_key_id , storage_bucket_access_key_id_exists := GetStorageBucketAccessKeyId ()
85- storage_bucket_secret_key , storage_bucket_secret_key_exists := GetStorageBucketSecretKey ()
86- storage_bucket_name , storage_bucket_name_exists := GetStorageBucketName ()
87- storage_bucket_mnist_dir , storage_bucket_mnist_dir_exists := GetStorageBucketMnistDir ()
88-
89- props := struct {
90- StorageBucketDefaultEndpoint string
91- StorageBucketDefaultEndpointExists bool
92- StorageBucketAccessKeyId string
93- StorageBucketAccessKeyIdExists bool
94- StorageBucketSecretKey string
95- StorageBucketSecretKeyExists bool
96- StorageBucketName string
97- StorageBucketNameExists bool
98- StorageBucketMnistDir string
99- StorageBucketMnistDirExists bool
100- }{
101- StorageBucketDefaultEndpoint : storage_bucket_endpoint ,
102- StorageBucketDefaultEndpointExists : storage_bucket_endpoint_exists ,
103- StorageBucketAccessKeyId : storage_bucket_access_key_id ,
104- StorageBucketAccessKeyIdExists : storage_bucket_access_key_id_exists ,
105- StorageBucketSecretKey : storage_bucket_secret_key ,
106- StorageBucketSecretKeyExists : storage_bucket_secret_key_exists ,
107- StorageBucketName : storage_bucket_name ,
108- StorageBucketNameExists : storage_bucket_name_exists ,
109- StorageBucketMnistDir : storage_bucket_mnist_dir ,
110- StorageBucketMnistDirExists : storage_bucket_mnist_dir_exists ,
111- }
112- template , err := files .ReadFile (filePath )
113- test .Expect (err ).NotTo (HaveOccurred ())
114-
115- return ParseTemplate (test , template , props )
116- }
0 commit comments