@@ -37,47 +37,27 @@ func TestMNISTPyTorchMCAD(t *testing.T) {
37
37
// Create a namespace
38
38
namespace := test .NewTestNamespace ()
39
39
40
- // MNIST training script
41
- mnist := & corev1.ConfigMap {
40
+ // Test configuration
41
+ config := & corev1.ConfigMap {
42
42
TypeMeta : metav1.TypeMeta {
43
43
APIVersion : corev1 .SchemeGroupVersion .String (),
44
44
Kind : "ConfigMap" ,
45
45
},
46
46
ObjectMeta : metav1.ObjectMeta {
47
- Name : "mnist" ,
47
+ Name : "mnist-mcad " ,
48
48
Namespace : namespace .Name ,
49
49
},
50
50
BinaryData : map [string ][]byte {
51
+ // pip requirements
52
+ "requirements.txt" : ReadFile (test , "mnist_pip_requirements.txt" ),
53
+ // MNIST training script
51
54
"mnist.py" : ReadFile (test , "mnist.py" ),
52
55
},
53
56
Immutable : Ptr (true ),
54
57
}
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 {})
79
59
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 )
81
61
82
62
// Batch Job
83
63
job := & batchv1.Job {
@@ -98,36 +78,22 @@ torchvision==0.12.0
98
78
{
99
79
Name : "job" ,
100
80
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" },
102
82
VolumeMounts : []corev1.VolumeMount {
103
83
{
104
- Name : "mnist" ,
105
- MountPath : "/test/job" ,
106
- },
107
- {
108
- Name : "requirements" ,
109
- MountPath : "/test/runtime" ,
84
+ Name : "test" ,
85
+ MountPath : "/test" ,
110
86
},
111
87
},
112
88
},
113
89
},
114
90
Volumes : []corev1.Volume {
115
91
{
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" ,
127
93
VolumeSource : corev1.VolumeSource {
128
94
ConfigMap : & corev1.ConfigMapVolumeSource {
129
95
LocalObjectReference : corev1.LocalObjectReference {
130
- Name : requirements .Name ,
96
+ Name : config .Name ,
131
97
},
132
98
},
133
99
},
0 commit comments