@@ -37,47 +37,27 @@ func TestMNISTPyTorchMCAD(t *testing.T) {
3737 // Create a namespace
3838 namespace := test .NewTestNamespace ()
3939
40- // MNIST training script
41- mnist := & corev1.ConfigMap {
40+ // Test configuration
41+ config := & corev1.ConfigMap {
4242 TypeMeta : metav1.TypeMeta {
4343 APIVersion : corev1 .SchemeGroupVersion .String (),
4444 Kind : "ConfigMap" ,
4545 },
4646 ObjectMeta : metav1.ObjectMeta {
47- Name : "mnist" ,
47+ Name : "mnist-mcad " ,
4848 Namespace : namespace .Name ,
4949 },
5050 BinaryData : map [string ][]byte {
51+ // pip requirements
52+ "requirements.txt" : ReadFile (test , "mnist_pip_requirements.txt" ),
53+ // MNIST training script
5154 "mnist.py" : ReadFile (test , "mnist.py" ),
5255 },
5356 Immutable : Ptr (true ),
5457 }
55- mnist , err := test .Client ().Core ().CoreV1 ().ConfigMaps (namespace .Name ).Create (test .Ctx (), mnist , metav1.CreateOptions {})
56- test .Expect (err ).NotTo (HaveOccurred ())
57- test .T ().Logf ("Created ConfigMap %s/%s successfully" , mnist .Namespace , mnist .Name )
58-
59- // pip requirements
60- requirements := & corev1.ConfigMap {
61- TypeMeta : metav1.TypeMeta {
62- APIVersion : corev1 .SchemeGroupVersion .String (),
63- Kind : "ConfigMap" ,
64- },
65- ObjectMeta : metav1.ObjectMeta {
66- Name : "requirements" ,
67- Namespace : namespace .Name ,
68- },
69- BinaryData : map [string ][]byte {
70- "requirements.txt" : []byte (`
71- pytorch_lightning==1.5.10
72- torchmetrics==0.9.1
73- torchvision==0.12.0
74- ` ),
75- },
76- Immutable : Ptr (true ),
77- }
78- requirements , err = test .Client ().Core ().CoreV1 ().ConfigMaps (namespace .Name ).Create (test .Ctx (), requirements , metav1.CreateOptions {})
58+ config , err := test .Client ().Core ().CoreV1 ().ConfigMaps (namespace .Name ).Create (test .Ctx (), config , metav1.CreateOptions {})
7959 test .Expect (err ).NotTo (HaveOccurred ())
80- test .T ().Logf ("Created ConfigMap %s/%s successfully" , requirements .Namespace , requirements .Name )
60+ test .T ().Logf ("Created ConfigMap %s/%s successfully" , config .Namespace , config .Name )
8161
8262 // Batch Job
8363 job := & batchv1.Job {
@@ -98,36 +78,22 @@ torchvision==0.12.0
9878 {
9979 Name : "job" ,
10080 Image : "pytorch/pytorch:1.11.0-cuda11.3-cudnn8-runtime" ,
101- Command : []string {"/bin/sh" , "-c" , "pip install -r /test/runtime/ requirements.txt && torchrun /test/job /mnist.py" },
81+ Command : []string {"/bin/sh" , "-c" , "pip install -r /test/requirements.txt && torchrun /test/mnist.py" },
10282 VolumeMounts : []corev1.VolumeMount {
10383 {
104- Name : "mnist" ,
105- MountPath : "/test/job" ,
106- },
107- {
108- Name : "requirements" ,
109- MountPath : "/test/runtime" ,
84+ Name : "test" ,
85+ MountPath : "/test" ,
11086 },
11187 },
11288 },
11389 },
11490 Volumes : []corev1.Volume {
11591 {
116- Name : "mnist" ,
117- VolumeSource : corev1.VolumeSource {
118- ConfigMap : & corev1.ConfigMapVolumeSource {
119- LocalObjectReference : corev1.LocalObjectReference {
120- Name : mnist .Name ,
121- },
122- },
123- },
124- },
125- {
126- Name : "requirements" ,
92+ Name : "test" ,
12793 VolumeSource : corev1.VolumeSource {
12894 ConfigMap : & corev1.ConfigMapVolumeSource {
12995 LocalObjectReference : corev1.LocalObjectReference {
130- Name : requirements .Name ,
96+ Name : config .Name ,
13197 },
13298 },
13399 },
0 commit comments