-
Notifications
You must be signed in to change notification settings - Fork 105
94 lines (79 loc) · 2.7 KB
/
ci.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: replicate-ci
on:
pull_request:
branches:
- main
jobs:
push:
runs-on: ubuntu-latest
env:
BASE_MODEL: 'stability-ai/sdxl'
STAGING_MODEL: 'replicate-internal/official-sdxl-staging'
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: what changed
id: what-changed
run: |
FILES_CHANGED=$(git diff --name-only --diff-filter=AMR origin/main HEAD | xargs)
echo "FILES_CHANGED=$FILES_CHANGED" >> $GITHUB_ENV
if echo "$FILES_CHANGED" | grep -q 'cog.yaml'; then
echo "cog-push=true" >> $GITHUB_OUTPUT
else
echo "cog-push=false" >> $GITHUB_OUTPUT
fi
if ${{ contains(github.event.head_commit.message, '[cog build]') }}; then
echo "cog-push=true" >> $GITHUB_OUTPUT
fi
# if cog.yaml changes - cog build and push. else - yolo build and push!
- name: did-it-tho
env:
COG_PUSH: ${{ steps.what-changed.outputs.cog-push }}
run: |
echo "cog push?: $COG_PUSH"
echo "changed files: $FILES_CHANGED"
- name: setup-cog
if: steps.what-changed.outputs.cog-push == 'true'
uses: replicate/[email protected]
with:
token: ${{ secrets.REPLICATE_API_TOKEN }}
install-cuda: false
cog-version: "v0.8.6"
- name: cog-build
if: steps.what-changed.outputs.cog-push == 'true'
run: |
cog build --use-cuda-base-image=false
- name: cog-push
if: steps.what-changed.outputs.cog-push == 'true'
env:
REPLICATE_API_TOKEN: ${{secrets.REPLICATE_API_TOKEN}}
run: |
cog push --use-cuda-base-image=false r8.im/"$STAGING_MODEL"
- name: install-yolo
if: steps.what-changed.outputs.cog-push == 'false'
run: |
sudo curl -o /usr/local/bin/yolo -L "https://github.com/replicate/yolo/releases/latest/download/yolo_$(uname -s)_$(uname -m)"
sudo chmod +x /usr/local/bin/yolo
- name: yolo-push
if: steps.what-changed.outputs.cog-push == 'false'
env:
REPLICATE_API_TOKEN: ${{secrets.REPLICATE_API_TOKEN}}
SENTRY_DSN: ${{secrets.SENTRY_DSN}}
run: |
echo "pushing changes from $BASE_MODEL to $STAGING_MODEL"
echo "changed files: $FILES_CHANGED"
yolo push --base $BASE_MODEL --dest $STAGING_MODEL $FILES_CHANGED
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: install python test deps
run: |
pip install -r requirements_test.txt
- name: test model
env:
REPLICATE_API_TOKEN: ${{secrets.REPLICATE_API_TOKEN}}
TEST_ENV: 'staging'
run: |
pytest tests/test_predict.py