Skip to content

Commit

Permalink
putting all together
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroaltobelli23 committed Nov 14, 2024
1 parent 412afdf commit 8431213
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 75 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/deploy_heroku.yml

This file was deleted.

57 changes: 53 additions & 4 deletions data/workflow.yml → .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ jobs:
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --platform linux/amd64 -f deploy/Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
Create-API-Endpoint:
runs-on: ubuntu-latest
needs: Amazon-ECR-Image
Expand Down Expand Up @@ -94,6 +93,56 @@ jobs:
- name: Run pytest
run: pytest tests/test_predict.py
Deploy-EC2-Webpage:
runs-on: ubuntu-22.04
needs: [Create-API-Endpoint, Run-Tests]
steps:
- uses: actions/checkout@v4
- uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ vars.HEROKU_APP_NAME }}
heroku_email: ${{ vars.HEROKU_EMAIL }}
appdir: "app"
env:
HD_ENDPOINT: ${{ needs.Create-API-Endpoint.outputs.api_endpoint }}
HD_AWS_REGION: ${{ secrets.AWS_REGION }}
deploy-docs:
runs-on: ubuntu-latest
needs: Run-Tests

permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Get pip cache dir
id: pip-cache
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: python -m pip install -r ./requirements.txt

- name: Build documentation
working-directory: ./docs
run: make html

- name: Deploy
uses: peaceiris/actions-gh-pages@v4
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
13 changes: 10 additions & 3 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import numpy as np
import cv2
import random
from dotenv import load_dotenv
import os

load_dotenv()

def draw_bbox(img,boxes):

Expand All @@ -26,8 +30,7 @@ def draw_bbox(img,boxes):
return img


def main():
endpoint = "https://9kq6eqv1bh.execute-api.us-east-2.amazonaws.com/predict"
def main(endpoint):
with open("index.md") as f:
st.markdown(f.read())

Expand Down Expand Up @@ -56,4 +59,8 @@ def main():
return None

if __name__=="__main__":
main()
endpoint = os.getenv("ENDPOINT","default_endpoint")+"/predict"
region = os.getenv("AWS_REGION")

endpoint = endpoint.replace("REGION",region)
main(endpoint)
3 changes: 2 additions & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
streamlit
requests
numpy
opencv-python-headless
opencv-python-headless
python-dotenv
49 changes: 0 additions & 49 deletions data/deploy_docs.yml

This file was deleted.

0 comments on commit 8431213

Please sign in to comment.