-
Notifications
You must be signed in to change notification settings - Fork 2.1k
195 lines (162 loc) · 7.15 KB
/
force-hub-push.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Manual Hub Push
on:
workflow_dispatch:
inputs:
release_token:
description: 'Your release token'
required: true
triggered_by:
description: 'CD | TAG | MANUAL'
required: false
default: MANUAL
#on:
# pull_request:
jobs:
token-check:
runs-on: ubuntu-latest
steps:
- run: echo "success!"
if: "${{ github.event.inputs.release_token }} == ${{ env.release_token }}"
env:
release_token: ${{ secrets.CAS_RELEASE_TOKEN }}
hub-release:
needs: token-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set envs and versions
run: |
VCS_REF=${{ github.ref }}
echo "VCS_REF=$VCS_REF" >> $GITHUB_ENV
echo "Will push $VCS_REF"
CAS_VERSION=$(sed -n '/^__version__/p' ./server/clip_server/__init__.py | cut -d \' -f2)
V_CAS_VERSION=v${CAS_VERSION}
CAS_MINOR_VERSION=${CAS_VERSION%.*}
CAS_MAJOR_VERSION=${CAS_MINOR_VERSION%.*}
if [[ "${{ github.event.inputs.triggered_by }}" == "CD" ]]; then
# on every CD release
echo "TAG_ALIAS=\
-t latest \
" >> $GITHUB_ENV
echo "GPU_TAG_ALIAS=\
-t latest-gpu \
" >> $GITHUB_ENV
elif [[ "${{ github.event.inputs.triggered_by }}" == "TAG" ]]; then
# on every tag release
echo "TAG_ALIAS=\
-t latest \
-t ${CAS_VERSION} \
-t ${CAS_MINOR_VERSION} \
" >> $GITHUB_ENV
echo "GPU_TAG_ALIAS=\
-t latest-gpu \
-t ${CAS_VERSION}-gpu \
-t ${CAS_MINOR_VERSION}-gpu \
" >> $GITHUB_ENV
elif [[ "${{ github.event.inputs.triggered_by }}" == "MANUAL" ]]; then
# on every manual release
echo "TAG_ALIAS=\
-t ${CAS_VERSION} \
" >> $GITHUB_ENV
echo "GPU_TAG_ALIAS=\
-t ${CAS_VERSION}-gpu \
" >> $GITHUB_ENV
else
echo "TAG_ALIAS=\
-t latest \
" >> $GITHUB_ENV
echo "GPU_TAG_ALIAS=\
-t latest-gpu \
" >> $GITHUB_ENV
fi
echo "CAS_VERSION=${CAS_VERSION}" >> $GITHUB_ENV
- name: Prepare enviroment
run: |
python -m pip install --upgrade jina yq
- name: Push Torch Executor
id: push_torch_executor
run: |
# FIX the import issue
echo -e "\
__version__ = '$CAS_VERSION'
from .executors.clip_torch import CLIPEncoder\n\
" > server/clip_server/__init__.py
echo -e "\
jtype: CLIPEncoder\n\
metas:\n\
py_modules:\n\
- clip_server/__init__.py\n\
" > server/config.yml
echo -e "\
manifest_version: 1\n\
name: CLIPTorchEncoder\n\
description: Embed images and sentences into fixed-length vectors with CLIP\n\
url: https://github.com/jina-ai/clip-as-service\n\
keywords: [clip, clip-model, clip-as-service, pytorch]\n\
" > server/manifest.yml
python scripts/get-requirements.py "" server/requirements.txt
cp .github/README-exec/torch.readme.md server/README.md
exec_name=`yq -r .name server/manifest.yml`
echo executor name is $exec_name
cp Dockerfiles/base.Dockerfile server/Dockerfile
JINA_AUTH_TOKEN=${{secrets.JINAHUB_TOKEN}} jina hub push --force $exec_name --secret ${{secrets.TORCH_EXEC_SECRET}} server ${{env.TAG_ALIAS}}
cp Dockerfiles/cuda.Dockerfile server/Dockerfile
JINA_AUTH_TOKEN=${{secrets.JINAHUB_TOKEN}} jina hub push --force $exec_name --secret ${{secrets.TORCH_EXEC_SECRET}} server ${{env.GPU_TAG_ALIAS}}
- name: Push Onnx Executor
id: push_onnx_executor
run: |
# FIX the import issue
echo -e "\
__version__ = '$CAS_VERSION'
from .executors.clip_onnx import CLIPEncoder\n\
" > server/clip_server/__init__.py
echo -e "\
jtype: CLIPEncoder\n\
metas:\n\
py_modules:\n\
- clip_server/__init__.py\n\
" > server/config.yml
echo -e "\
manifest_version: 1\n\
name: CLIPOnnxEncoder\n\
description: Embed images and sentences into fixed-length vectors with CLIP\n\
url: https://github.com/jina-ai/clip-as-service\n\
keywords: [clip, clip-model, clip-as-service, onnx, onnx-runtime]\n\
" > server/manifest.yml
python scripts/get-requirements.py onnx server/requirements.txt
cp .github/README-exec/onnx.readme.md server/README.md
exec_name=`yq -r .name server/manifest.yml`
echo executor name is $exec_name
cp Dockerfiles/base.Dockerfile server/Dockerfile
sed -i 's/ARG BACKEND_TAG=torch/ARG BACKEND_TAG=onnx/g' server/Dockerfile
JINA_AUTH_TOKEN=${{secrets.JINAHUB_TOKEN}} jina hub push --force $exec_name --secret ${{secrets.ONNX_EXEC_SECRET}} server ${{env.TAG_ALIAS}}
cp Dockerfiles/cuda.Dockerfile server/Dockerfile
sed -i 's/ARG BACKEND_TAG=torch/ARG BACKEND_TAG=onnx/g' server/Dockerfile
JINA_AUTH_TOKEN=${{secrets.JINAHUB_TOKEN}} jina hub push --force $exec_name --secret ${{secrets.ONNX_EXEC_SECRET}} server ${{env.GPU_TAG_ALIAS}}
- name: Push TensorRT Executor
id: push_tensorrt_executor
run: |
# FIX the import issue
echo -e "\
__version__ = '$CAS_VERSION'
from .executors.clip_tensorrt import CLIPEncoder\n\
" > server/clip_server/__init__.py
echo -e "\
jtype: CLIPEncoder\n\
metas:\n\
py_modules:\n\
- clip_server/__init__.py\n\
" > server/config.yml
echo -e "\
manifest_version: 1\n\
name: CLIPTensorRTEncoder\n\
description: Embed images and sentences into fixed-length vectors with CLIP\n\
url: https://github.com/jina-ai/clip-as-service\n\
keywords: [clip, clip-model, clip-as-service, onnx, tensorrt]\n\
" > server/manifest.yml
python scripts/get-requirements.py tensorrt server/requirements.txt
cp Dockerfiles/tensorrt.Dockerfile server/Dockerfile
exec_name=`yq -r .name server/manifest.yml`
echo executor name is $exec_name
# FIXME: disable uploading at debugging
# JINA_AUTH_TOKEN=${{secrets.JINAHUB_TOKEN}} jina hub push --force $exec_name --secret ${{secrets.TENSORRT_EXEC_SECRET}} server ${{env.TAG_ALIAS}}