Skip to content

Commit d03c3bb

Browse files
committed
volume specific sidecar job
1 parent eff8abb commit d03c3bb

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Diff for: gmx-wrap2.sh

+14-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ img=cerit.io/ljocha/gromacs:2023-2-plumed-2-9-afed-pytorch-model-cv-2
77

88
input=$(cat -)
99

10-
# XXX: cwd root of the volue only
10+
# XXX: cwd root of the volume only
11+
gmxjob=asmsa-gmx-$$
1112

1213
if [ -z "$DOCKER_WORKDIR" ]; then
1314
pvcid=$(df . | tail -1 | cut -f1 -d ' ' | sed 's/^.*pvc-/pvc-/')
@@ -16,17 +17,23 @@ if [ -z "$DOCKER_WORKDIR" ]; then
1617
mnt=$(df . | tail -1 | cut -f7 -d ' ')
1718
DIR=$(realpath --relative-base $mnt $PWD)
1819

19-
kubectl get job/asmsa-gmx 2>/dev/null >/dev/null || kubectl apply -f - >&2 <<EOF
20+
if [ -f $mnt/.gmxjob ]; then
21+
gmxjob=$(cat $mnt/.gmxjob)
22+
else
23+
echo $gmxjob >$mnt/.gmxjob
24+
fi
25+
26+
kubectl get job/$gmxjob 2>/dev/null >/dev/null || kubectl apply -f - >&2 <<EOF
2027
apiVersion: batch/v1
2128
kind: Job
2229
metadata:
23-
name: asmsa-gmx
30+
name: $gmxjob
2431
spec:
2532
backoffLimit: 0
2633
template:
2734
metadata:
2835
labels:
29-
job: asmsa-gmx
36+
job: $gmxjob
3037
spec:
3138
restartPolicy: Never
3239
securityContext: # Pod security context
@@ -35,7 +42,7 @@ spec:
3542
seccompProfile:
3643
type: RuntimeDefault
3744
containers:
38-
- name: asmsa-gmx
45+
- name: $gmxjob
3946
image: $img
4047
workingDir: /mnt/
4148
command: [ 'sleep', 'inf' ]
@@ -72,8 +79,8 @@ EOF
7279
kcmd="$kcmd '$c'"
7380
done
7481

75-
kubectl wait --for=condition=ready pod -l job=asmsa-gmx >&2
76-
kubectl exec job/asmsa-gmx -- bash -c "$kcmd <<<\"$input\""
82+
kubectl wait --for=condition=ready pod -l job=$gmxjob >&2
83+
kubectl exec job/$gmxjob -- bash -c "$kcmd <<<\"$input\""
7784
else
7885
docker run -i --gpus all -v $DOCKER_WORKDIR:/work -w /work -u $(id -u) $img gmx "$@" <<<"$input"
7986
fi

0 commit comments

Comments
 (0)