-
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (85 loc) · 3.09 KB
/
job-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: job-deploy
on:
workflow_dispatch:
inputs:
target:
description: 'Deploy to (workstation or cluster)'
type: choice
required: true
default: 'workstation'
options:
- workstation
- cluster
command:
description: 'Command passed to docker compose'
required: true
default: 'scripts/sampler.py'
args:
description: 'Arguments passed to job script'
required: false
default: '-U http://mlflow:5000 --num_cpus 34 --memory 4'
jobs:
deploy2workstation:
name: Deploy to workstation
if: github.event.inputs.target == 'workstation'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Echo target
run: echo "Deploying to targeted machine - ${{ github.event.inputs.target }}"
- name: Rsync repo to workstation
uses: burnett01/[email protected]
with:
switches: -avzr --delete
remote_path: '~/projects/mbl'
remote_host: ${{ secrets.WORKSTATION_HOST }}
remote_user: ${{ secrets.USERNAME }}
remote_key: ${{ secrets.KEY }}
- name: Deploy built docker image to workstation
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.WORKSTATION_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd projects/mbl &&
docker compose run --service-ports -d mbl \
${{ github.event.inputs.command }} \
${{ github.event.inputs.args }}
- name: Prune dangling images
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.WORKSTATION_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
yes | docker system prune
#######################################################
deploy2cluster:
name: Deploy to cluster
if: github.event.inputs.target == 'cluster'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Echo target
run: echo "Deploying to targeted machine - ${{ github.event.inputs.target }}"
- name: Rsync repo to cluster
uses: burnett01/[email protected]
with:
switches: -avzr --delete
remote_path: '~/projects/mbl'
remote_host: ${{ secrets.CLUSTER_HOST }}
remote_user: ${{ secrets.USERNAME }}
remote_key: ${{ secrets.KEY }}
- name: Build singularity and run sampler
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.CLUSTER_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd projects/mbl &&
singularity build --fakeroot mbl.sif singularity.def &&
conda activate &&
nohup python scripts/sampler.py > foo.out 2> foo.err < /dev/null &
# singularity exec -B /etc/slurm,/etc/passwd,/run/munge,/usr/lib64,/usr/bin/squeue,/usr/bin/sbatch,/usr/bin/scancel --bind ~/data:/data mbl.sif python scripts/sampler.py