Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(api-web3-stage) #59

Merged
merged 8 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading