Repository navigation
Expand file tree
/
Copy pathmodal.custom_python_block.deploy.yml
More file actions
90 lines (88 loc) · 3.99 KB
/
Copy pathmodal.custom_python_block.deploy.yml
File metadata and controls
90 lines (88 loc) · 3.99 KB
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
name: Deploy Modal App serving custom python block
permissions:
contents: read
on:
# workflow_run:
# workflows: ["Publish Wheels to PyPi"]
# types: [completed]
workflow_dispatch:
inputs:
inference_version:
type: string
description: "inference version to deploy (e.g., 1.5.0)"
required: true
targets:
type: choice
description: "Region target(s) for the webexec app (fans out to each)"
options:
- us,eu
- us
- eu
default: us,eu
stage:
type: choice
description: "Which Roboflow project the app talks to"
options:
- staging
- prod
default: staging
jobs:
# Build the deploy matrix from the chosen targets. Both regions live in the SAME
# Modal workspace ($MODAL_WORKSPACE_NAME); they differ only by Modal environment +
# region knobs, so one deploy credential covers both.
# us -> env `main` (workspace default), any cloud in region `us` (not pinned to one
# cloud region: aws/us-east-1 capacity exhaustion stranded preempted executors)
# eu -> env `eu`, gcp + region eu, routed eu-west -> roboflow-eu--...eu-west.modal.run
# `stage` picks the Roboflow project the deployed app talks to, per region.
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.gen.outputs.matrix }}
steps:
- id: gen
env:
TARGETS: ${{ github.event.inputs.targets || 'us,eu' }}
STAGE: ${{ github.event.inputs.stage || 'staging' }}
run: |
inc='[]'
IFS=',' read -ra TS <<< "$TARGETS"
for t in "${TS[@]}"; do
case "$t:$STAGE" in
us:staging) inc=$(jq -c '. + [{"target":"us","environment":"main","cloud":"","region":"us","routing_region":"","project":"roboflow-staging","app_name":"webexec-roboflow-staging"}]' <<< "$inc") ;;
us:prod) inc=$(jq -c '. + [{"target":"us","environment":"main","cloud":"","region":"us","routing_region":"","project":"roboflow-platform","app_name":"webexec-roboflow-platform"}]' <<< "$inc") ;;
eu:staging) inc=$(jq -c '. + [{"target":"eu","environment":"eu","cloud":"gcp","region":"eu","routing_region":"eu-west","project":"roboflow-staging","app_name":"webexec-roboflow-eu-staging"}]' <<< "$inc") ;;
eu:prod) inc=$(jq -c '. + [{"target":"eu","environment":"eu","cloud":"gcp","region":"eu","routing_region":"eu-west","project":"roboflow-platform","app_name":"webexec-roboflow-eu-platform"}]' <<< "$inc") ;;
*) echo "unsupported target/stage combination: $t:$STAGE" >&2; exit 1 ;;
esac
done
echo "matrix={\"include\":$inc}" >> "$GITHUB_OUTPUT"
deploy:
needs: setup
name: deploy ${{ matrix.app_name }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: python3 -m pip install modal packaging pydantic python-dotenv requests rich starlette structlog
- name: Deploy webexec (${{ matrix.target }} -> Modal env ${{ matrix.environment }}, project ${{ matrix.project }})
env:
WEBEXEC_MODAL_APP_NAME: ${{ matrix.app_name }}
MODAL_WORKSPACE_NAME: ${{ secrets.MODAL_WORKSPACE_NAME }}
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID_FOR_DEPLOYMENT }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET_FOR_DEPLOYMENT }}
INFERENCE_VERSION: ${{ github.event.inputs.inference_version }}
MODAL_ENVIRONMENT: ${{ matrix.environment }}
WEBEXEC_MODAL_CLOUD: ${{ matrix.cloud }}
WEBEXEC_MODAL_REGION: ${{ matrix.region }}
WEBEXEC_MODAL_ROUTING_REGION: ${{ matrix.routing_region }}
working-directory: modal
run: python3 deploy_modal_app.py