-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from SunbirdAI/asr-stt-inference
Integrate ASR/STT inference
- Loading branch information
Showing
27 changed files
with
288 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
ignore = D203, E402, F403, F405, W503, W605 | ||
exclude = .git,env,__pycache__,docs/source/conf.py,old,build,dist, *migrations*,env,venv,alembic | ||
max-complexity = 10 | ||
max-line-length = 119 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[settings] | ||
multi_line_output=3 | ||
include_trailing_comma=True | ||
force_grid_wrap=0 | ||
use_parentheses=True | ||
line_length=88 | ||
skip=env,migrations,alembic,venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.PHONY: lint-apply lint-check | ||
|
||
lint-check: | ||
@echo "Checking for lint errors..." | ||
flake8 . | ||
black --check . | ||
isort --check-only . | ||
|
||
lint-apply: | ||
@echo "apply linting ..." | ||
black . | ||
isort . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
from contextlib import contextmanager | ||
|
||
from sqlalchemy.orm import Session | ||
|
||
from app.database.db import SessionLocal | ||
from app.models import monitoring as models | ||
from app.schemas import monitoring as schemas | ||
from app.database.db import SessionLocal | ||
|
||
|
||
@contextmanager | ||
def auto_session(): | ||
sess = SessionLocal() | ||
try: | ||
yield sess | ||
sess.commit() | ||
except: | ||
except Exception: | ||
sess.rollback() | ||
finally: | ||
sess.close() | ||
|
||
|
||
def create_endpoint_log(log: schemas.EndpointLog): | ||
with auto_session() as sess: | ||
db_log = models.EndpointLog(username=log.username, endpoint=log.endpoint, time_taken=log.time_taken) | ||
db_log = models.EndpointLog( | ||
username=log.username, endpoint=log.endpoint, time_taken=log.time_taken | ||
) | ||
sess.add(db_log) | ||
|
||
|
||
def get_logs_by_username(db: Session, username: str): | ||
return db.query(models.EndpointLog).filter(models.EndpointLog.username == username).all() | ||
return ( | ||
db.query(models.EndpointLog) | ||
.filter(models.EndpointLog.username == username) | ||
.all() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import os | ||
|
||
from sqlalchemy.orm import declarative_base | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from dotenv import load_dotenv | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import declarative_base, sessionmaker | ||
|
||
load_dotenv() | ||
|
||
engine = create_engine(os.getenv('DATABASE_URL'), pool_size=20, max_overflow=0) | ||
engine = create_engine(os.getenv("DATABASE_URL"), pool_size=20, max_overflow=0) | ||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
Base = declarative_base() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from app.database.db import SessionLocal | ||
|
||
|
||
def get_db(): | ||
db = SessionLocal() | ||
try: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
import json | ||
import os | ||
|
||
import requests | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
|
||
url = f"https://europe-west1-aiplatform.googleapis.com/v1/projects/{os.getenv('PROJECT_ID')}/locations/europe-west1/endpoints/{os.getenv('ENDPOINT_ID')}:rawPredict" | ||
url = f"https://europe-west1-aiplatform.googleapis.com/v1/projects/{os.getenv('PROJECT_ID')}/locations/europe-west1/endpoints/{os.getenv('ENDPOINT_ID')}:rawPredict" # noqa E501 | ||
|
||
|
||
def inference_request(payload): | ||
token = os.popen('gcloud auth print-access-token').read().strip() | ||
headers = { | ||
"Authorization": f"Bearer {token}", | ||
"Content-Type": "application/json" | ||
} | ||
response = requests.request( | ||
"POST", | ||
url, | ||
headers=headers, | ||
data=json.dumps(payload) | ||
) | ||
token = os.popen("gcloud auth print-access-token").read().strip() | ||
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"} | ||
response = requests.request("POST", url, headers=headers, data=json.dumps(payload)) | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.