Skip to content

Commit

Permalink
feat: changed Stub to App and fix deploy modal workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
limcheekin committed Jul 12, 2024
1 parent 0042cf8 commit 3cfa906
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/deploy-modal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
cpu:
description: Specify a floating-point number of CPU cores, default to 2.0.
memory:
description: Specify minimum memory size required, default to 2048MB.
description: Specify minimum memory size required, default to 2048 MB.
timeout:
description: Specify execution timeout, default to 600 seconds.
keep_warm:
Expand Down Expand Up @@ -45,12 +45,15 @@ jobs:
- name: Install Python packages
run: pip install modal-client

- name: Set APP_NAME variable
run: |
APP_NAME=$(echo "${{ github.event.inputs.model_name }}" | cut -d'/' -f2 | tr '.' '-')
echo "APP_NAME=${APP_NAME}" >> $GITHUB_ENV
- name: Deploy FastAPI app
run: >
STUB=$(echo "${{ github.event.inputs.model_name }}" | cut -d'/' -f2 | tr '.' '-')
modal deploy open.text.embeddings.server.modal
run: modal deploy open.text.embeddings.server.modal

- name: Test FastAPI app
run: >
STUB=$(echo "${{ github.event.inputs.model_name }}" | cut -d'/' -f2 | tr '.' '-')
echo "https://${{ secrets.MODAL_USERNAME }}--$STUB/v1/embeddings"
APP=$(echo "${{ github.event.inputs.model_name }}" | cut -d'/' -f2 | tr '.' '-')
echo "https://${{ secrets.MODAL_USERNAME }}--$APP_NAME/v1/embeddings"
7 changes: 3 additions & 4 deletions open/text/embeddings/server/modal.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Modal Lab web app for open-text-embeddings.
from modal import Image, Stub, asgi_app
from modal import Image, App, asgi_app
import os

stub = Stub(os.environ["STUB"])
app = App(os.environ["APP_NAME"])

image = Image.from_dockerfile(
"Dockerfile-Modal", force_build=True
Expand All @@ -23,8 +23,7 @@ def fastapi_app():
from open.text.embeddings.server.app import create_app
import os
print("os.cpu_count()", os.cpu_count())
app = create_app()
return app
return create_app()


if __name__ == "__main__":
Expand Down

0 comments on commit 3cfa906

Please sign in to comment.