-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (145 loc) · 5.38 KB
/
dev-env-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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: "Development Environment: Deploy"
on:
workflow_dispatch:
inputs:
machine:
description: 'Which machine to use'
required: true
default: 'local'
type: choice
options:
- m6a.xlarge
- m6a.2xlarge
- g4dn.2xlarge
- g4dn.xlarge
- local
image:
description: 'Production Environment'
required: true
default: 'ghcr.io/digital-defiance/sentiment-analysis-pipeline:main'
type: choice
options:
- ghcr.io/digital-defiance/sentiment-analysis-pipeline:main
docker_options:
required: true
description: 'Extra docker options'
default: '--user root'
type: choice
options:
- '--user root'
- '--user root --gpus all'
env:
AWS_REGION: eu-south-1
jobs:
start-runner:
runs-on: ubuntu-latest
name: "Provision infrastructure"
outputs:
label: ${{ steps.set-output.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
if: ${{ inputs.machine != 'local' }}
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
if: ${{ inputs.machine != 'local' }}
uses: digital-defiance/ec2-github-runner@feature/add-storage-option
with:
mode: start
root-volume-size: 50
iam-role-name: ec2-logs
pre-runner-script: | # sudo yum update -y && sudo yum install docker git libicu -y
sudo systemctl enable docker
sudo systemctl start docker
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
market-type: spot
ec2-image-id: ami-0450c19b7a7f6250d # ami-0d1e2ba0458f0cd7a
ec2-instance-type: ${{ inputs.machine }}
subnet-id: subnet-0fc7dea0969cca860
security-group-id: sg-0c4cc0c0be64f1b08
- shell: bash
name: "Get runner tag"
id: set-output
run: |
if [[ ${{ inputs.machine }} == "local" ]]; then
echo "label=local" >> $GITHUB_OUTPUT
else
echo "label=${{ steps.start-ec2-runner.outputs.label }}" >> $GITHUB_OUTPUT
fi
deploy-vscode:
name: Deploy development environment
timeout-minutes: 1500
needs:
- start-runner
runs-on: ${{ needs.start-runner.outputs.label }}
container:
image: ${{ inputs.image }}
options: ${{ inputs.docker_options }}
env:
RUST_BACKTRACE: "full"
LIBTORCH_USE_PYTORCH: "1"
LLMVC_ENVIRONMENT: "development"
MLFLOW_TRACKING_URI: ${{ secrets.MLFLOW_TRACKING_URL }}
MLFLOW_TRACKING_USERNAME: ${{ secrets.MLFLOW_USERNAME }}
MLFLOW_TRACKING_PASSWORD: ${{ secrets.MLFLOW_PASSWORD }}
steps:
# stuff to be moved to the production image
- run: pip install psycopg2-binary # required for mlflow to talk to postgres
- run: pip install mlflow
- run: pip install prefect-shell
# development dependencies and configuration
# required for rust to compile
- uses: actions/checkout@v4
- run: apt update
- run: apt install libssh-dev -y
- run: apt install pkg-config -y
- run: apt install curl -y
- uses: dtolnay/rust-toolchain@stable
- name: Find and set torch lib path
run: |
SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
TORCH_LIB_PATH="${SITE_PACKAGES}/torch/lib"
echo "LD_LIBRARY_PATH=$TORCH_LIB_PATH" >> $GITHUB_ENV
# development only
- run: pip install jurigged
- run: pip install pytest
- run: apt-get update && apt-get install -y procps
- run: git config --global user.email "mail@ruicampos.org"
- run: git config --global user.name "Rui Campos"
- run: git config --global --add safe.directory /__w/llm-voice-chat/llm-voice-chat
- run: git config pull.rebase false
- name: Login to prefect
run: yes | prefect cloud login --key ${{ secrets.PREFECT_API_KEY }} --workspace 'digital-defiance/default'
- name: Setup code CLI
run: |
curl -Lk 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output vscode_cli.tar.gz
tar -xf vscode_cli.tar.gz
- name: Serve VSCode
continue-on-error: true
run: ./code tunnel
stop-runner:
runs-on: ubuntu-latest
name: "Deprovision infrastructure"
needs:
- start-runner
- deploy-vscode
if: ${{ always() && inputs.machine != 'local' }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Stop EC2 runner
uses: digital-defiance/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}