Skip to content

Commit

Permalink
Merge pull request #59 from edenartlab/web3-staging
Browse files Browse the repository at this point in the history
Feat(api-web3-stage)
  • Loading branch information
genekogan authored Jan 13, 2025
2 parents 51204d8 + d6712f9 commit b7e98aa
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/web3-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy to Modal Web3-Production

on:
push:
branches:
- main
pull_request:
types: [closed]
branches:
- main

jobs:
deploy:
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true))
runs-on: ubuntu-latest
env:
DB: WEB3-PROD

steps:
- name: Checkout workflows repo
uses: actions/checkout@v4
with:
repository: edenartlab/workflows
path: workflows

- name: Checkout main repo
uses: actions/checkout@v4
with:
path: eve

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install the latest version of rye
uses: eifinger/setup-rye@v4

- name: Install dependencies
working-directory: eve
run: rye sync

- name: Configure Modal token
working-directory: eve
run: rye run modal token set --token-id ${{ secrets.MODAL_TOKEN_ID }} --token-secret ${{ secrets.MODAL_TOKEN_SECRET }}

- name: Deploy to Modal
working-directory: eve
run: rye run modal deploy ./eve/api/api.py
49 changes: 49 additions & 0 deletions .github/workflows/web3-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy to Modal Web3-Staging

on:
push:
branches:
- staging
pull_request:
types: [closed]
branches:
- staging

jobs:
deploy:
if: github.ref == 'refs/heads/staging' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true))
runs-on: ubuntu-latest
env:
DB: WEB3-STAGE

steps:
- name: Checkout workflows repo
uses: actions/checkout@v4
with:
repository: edenartlab/workflows
path: workflows

- name: Checkout main repo
uses: actions/checkout@v4
with:
path: eve

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install the latest version of rye
uses: eifinger/setup-rye@v4

- name: Install dependencies
working-directory: eve
run: rye sync

- name: Configure Modal token
working-directory: eve
run: rye run modal token set --token-id ${{ secrets.MODAL_TOKEN_ID }} --token-secret ${{ secrets.MODAL_TOKEN_SECRET }}

- name: Deploy to Modal
working-directory: eve
run: rye run modal deploy ./eve/api/api.py
10 changes: 8 additions & 2 deletions eve/tools/replicate_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,14 @@ async def _create_prediction(self, args: dict, webhook=True):
return prediction

def get_webhook_url():
env = "api-prod" if os.getenv("DB") == "PROD" else "api-stage"
dev = "-dev" if os.getenv("DB") == "STAGE" and os.getenv("MODAL_SERVE") == "1" else ""
env = {
"PROD": "api-prod",
"STAGE": "api-stage",
"WEB3-PROD": "api-web3-prod",
"WEB3-STAGE": "api-web3-stage"
}.get(os.getenv("DB"), "api-web3-stage")
dev = "-dev" if os.getenv("DB") in ["WEB3-STAGE", "STAGE"] and os.getenv("MODAL_SERVE") == "1" else ""

webhook_url = f"https://edenartlab--{env}-fastapi-app{dev}.modal.run/update"
return webhook_url

Expand Down

0 comments on commit b7e98aa

Please sign in to comment.