Skip to content

Commit 910ea05

Browse files
Reflect Poetry changes
1 parent c5724bb commit 910ea05

File tree

5 files changed

+116
-41
lines changed

5 files changed

+116
-41
lines changed

.github/workflows/e2e_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
run: |
9393
export CODEFLARE_TEST_TIMEOUT_SHORT=1m
9494
export CODEFLARE_TEST_TIMEOUT_MEDIUM=5m
95-
export CODEFLARE_TEST_TIMEOUT_LONG=10m
95+
export CODEFLARE_TEST_TIMEOUT_LONG=15m
9696
9797
export CODEFLARE_TEST_OUTPUT_DIR=${{ env.TEMP_DIR }}
9898
echo "CODEFLARE_TEST_OUTPUT_DIR=${CODEFLARE_TEST_OUTPUT_DIR}" >> $GITHUB_ENV

copyscript.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# command to be ran on local host and not in the pod
4+
# kubectl apply -f temp-pod.yaml
5+
# kubectl cp ./ default/temp-pod4:/mnt
6+
7+
8+
9+
echo "starting"
10+
namespace=$1
11+
# podname=$(kubectl get pods -n "${namespace}" -o custom-columns=:metadata.name | grep "^sdk")
12+
# kubectl cp ./ ${namespace}/${podname}:/codeflare-sdk
13+
14+
# kubectl cp ./ ${namespace}/temp-pod:/mnt
15+
16+
sleep 60
17+
18+
# Get the name of the pod starting with 'sdk' and its status
19+
read podname podstatus <<< $(kubectl get pods -n "${namespace}" -o custom-columns=:metadata.name,:status.phase | grep "^sdk" | awk '{print $1, $2}')
20+
21+
echo "$podname, $podstatus, $namespace"
22+
23+
# Check if the pod is found and is in 'Running' status
24+
if [[ -n "$podname" && "$podstatus" == "Running" ]]; then
25+
echo "Pod ${podname} is running. Proceeding to copy files."
26+
kubectl cp ../.././ "${namespace}/${podname}:/codeflare-sdk"
27+
else
28+
echo "Pod not found or not running."
29+
exit 1
30+
fi

tests/e2e/install-codeflare-sdk.sh

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
#!/bin/bash
22

3+
# Generate zip file beforehand
4+
# tar -czvf root-dir.tar.gz --exclude='.git' --exclude='.github' --exclude='.pytest_cache' ./
5+
6+
# Create temp-pod to contain the zip file
7+
# kubectl apply -f temp-pod.yaml
8+
9+
# Copy the zip file to the temp-pod:/mnt
10+
# kubectl cp root-dir.tar.gz temp-pod:/mnt
11+
12+
# Run a shell in the temp-pod
13+
# kubectl exec -it temp-pod -- /bin/sh
14+
15+
# Unzip the zip file
16+
# tar -xzvf /mnt/root-dir.tar.gz -C /mnt
17+
18+
# Not necessary as the PVC is mounted to /codeflare-sdk
19+
# mv /mnt/* /codeflare-sdk/
20+
21+
## Copy files from temp-pod /mnt into the codeflare-sdk volume mount in this other pod.
22+
# kubectl cp default/temp-pod:/mnt codeflare-sdk
23+
24+
25+
cd ..
26+
327
# Install Poetry and configure virtualenvs
428
pip install poetry
529
poetry config virtualenvs.create false
630

7-
# Clone the CodeFlare SDK repository
8-
echo "first ls"
9-
ls
10-
pip uninstall codeflare-sdk
11-
echo "install codeflare sdk"
12-
pip install codeflare_sdk-0.0.0.dev0-py3-none-any.whl
13-
echo "second ls"
14-
ls
15-
# git clone --branch main https://github.com/project-codeflare/codeflare-sdk.git
16-
# cd codeflare-sdk
17-
18-
# # Lock dependencies and install them
19-
# poetry lock --no-update
20-
# poetry install --with test,docs
21-
22-
# Return to the previous directory
23-
# cd ..
31+
cd codeflare-sdk
32+
33+
# Lock dependencies and install them
34+
poetry lock --no-update
35+
poetry install --with test,docs
36+
37+
# Return to the workdir
38+
cd ..
39+
cd workdir

tests/e2e/mnist_raycluster_sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
done = False
6969
time = 0
70-
timeout = 300
70+
timeout = 500
7171
while not done:
7272
status = job.status()
7373
if is_terminal(status.state):

tests/e2e/mnist_raycluster_sdk_test.go

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package e2e
1818

1919
import (
20+
"bytes"
21+
"os/exec"
2022
"testing"
2123

2224
. "github.com/onsi/gomega"
@@ -51,8 +53,6 @@ func TestMNISTRayClusterSDK(t *testing.T) {
5153
"requirements.txt": ReadFile(test, "mnist_pip_requirements.txt"),
5254
// MNIST training script
5355
"mnist.py": ReadFile(test, "mnist.py"),
54-
// SDK Wheel File
55-
"codeflare_sdk-0.0.0.dev0-py3-none-any.whl": ReadWhlFile(test, "codeflare_sdk-0.0.0.dev0-py3-none-any.whl"),
5656
// codeflare-sdk installation script
5757
"install-codeflare-sdk.sh": ReadFile(test, "install-codeflare-sdk.sh"),
5858
})
@@ -113,6 +113,30 @@ func TestMNISTRayClusterSDK(t *testing.T) {
113113
BackoffLimit: Ptr(int32(0)),
114114
Template: corev1.PodTemplateSpec{
115115
Spec: corev1.PodSpec{
116+
Volumes: []corev1.Volume{
117+
{
118+
Name: "test",
119+
VolumeSource: corev1.VolumeSource{
120+
ConfigMap: &corev1.ConfigMapVolumeSource{
121+
LocalObjectReference: corev1.LocalObjectReference{
122+
Name: config.Name,
123+
},
124+
},
125+
},
126+
},
127+
{
128+
Name: "codeflare-sdk",
129+
VolumeSource: corev1.VolumeSource{
130+
EmptyDir: &corev1.EmptyDirVolumeSource{},
131+
},
132+
},
133+
{
134+
Name: "workdir",
135+
VolumeSource: corev1.VolumeSource{
136+
EmptyDir: &corev1.EmptyDirVolumeSource{},
137+
},
138+
},
139+
},
116140
Containers: []corev1.Container{
117141
{
118142
Name: "test",
@@ -123,13 +147,20 @@ func TestMNISTRayClusterSDK(t *testing.T) {
123147
{Name: "PYTHONUSERBASE", Value: "/workdir"},
124148
{Name: "RAY_IMAGE", Value: GetRayImage()},
125149
},
126-
Command: []string{"/bin/sh", "-c", "cp /test/* . && chmod +x install-codeflare-sdk.sh && ./install-codeflare-sdk.sh && python mnist_raycluster_sdk.py" + " " + namespace.Name},
127-
// Command: []string{"/bin/sh", "-c", "pip install /test/codeflare_sdk-0.0.0.dev0-py3-none-any.whl && cp /test/* . && python mnist_raycluster_sdk.py" + " " + namespace.Name},
150+
Command: []string{
151+
"/bin/sh", "-c",
152+
"while [ ! -f /codeflare-sdk/pyproject.toml ]; do sleep 1; done; " +
153+
"cp /test/* . && chmod +x install-codeflare-sdk.sh && ./install-codeflare-sdk.sh && python mnist_raycluster_sdk.py " + namespace.Name,
154+
},
128155
VolumeMounts: []corev1.VolumeMount{
129156
{
130157
Name: "test",
131158
MountPath: "/test",
132159
},
160+
{
161+
Name: "codeflare-sdk",
162+
MountPath: "/codeflare-sdk",
163+
},
133164
{
134165
Name: "workdir",
135166
MountPath: "/workdir",
@@ -148,24 +179,6 @@ func TestMNISTRayClusterSDK(t *testing.T) {
148179
},
149180
},
150181
},
151-
Volumes: []corev1.Volume{
152-
{
153-
Name: "test",
154-
VolumeSource: corev1.VolumeSource{
155-
ConfigMap: &corev1.ConfigMapVolumeSource{
156-
LocalObjectReference: corev1.LocalObjectReference{
157-
Name: config.Name,
158-
},
159-
},
160-
},
161-
},
162-
{
163-
Name: "workdir",
164-
VolumeSource: corev1.VolumeSource{
165-
EmptyDir: &corev1.EmptyDirVolumeSource{},
166-
},
167-
},
168-
},
169182
RestartPolicy: corev1.RestartPolicyNever,
170183
ServiceAccountName: sa.Name,
171184
},
@@ -194,6 +207,22 @@ func TestMNISTRayClusterSDK(t *testing.T) {
194207
test.Expect(err).NotTo(HaveOccurred())
195208
test.T().Logf("Created Job %s/%s successfully", job.Namespace, job.Name)
196209

210+
go func() {
211+
scriptName := "../.././copyscript.sh"
212+
cmd := exec.Command(scriptName, namespace.Name)
213+
214+
var stdoutBuf, stderrBuf bytes.Buffer
215+
cmd.Stdout = &stdoutBuf
216+
cmd.Stderr = &stderrBuf
217+
218+
// Run the script
219+
if err := cmd.Run(); err != nil {
220+
t.Logf("STDOUT: %s", stdoutBuf.String())
221+
t.Logf("STDERR: %s", stderrBuf.String())
222+
t.Logf("Failed to run the script: %v", err)
223+
}
224+
}()
225+
197226
test.T().Logf("Waiting for Job %s/%s to complete", job.Namespace, job.Name)
198227
test.Eventually(Job(test, job.Namespace, job.Name), TestTimeoutLong).Should(
199228
Or(

0 commit comments

Comments
 (0)