diff --git a/.github/workflows/web3-prod.yaml b/.github/workflows/web3-prod.yaml new file mode 100644 index 0000000..40aa782 --- /dev/null +++ b/.github/workflows/web3-prod.yaml @@ -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 diff --git a/.github/workflows/web3-staging.yaml b/.github/workflows/web3-staging.yaml new file mode 100644 index 0000000..9bcf097 --- /dev/null +++ b/.github/workflows/web3-staging.yaml @@ -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 diff --git a/eve/tools/replicate_tool.py b/eve/tools/replicate_tool.py index 73420dc..73d82f2 100644 --- a/eve/tools/replicate_tool.py +++ b/eve/tools/replicate_tool.py @@ -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