-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aadesh Kulkarni
authored and
Aadesh Kulkarni
committed
Dec 31, 2023
1 parent
3d2a0ee
commit 5ac164f
Showing
8 changed files
with
152 additions
and
1 deletion.
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,2 @@ | ||
__pycache__ | ||
env |
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,11 @@ | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.orm import sessionmaker | ||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
URL_DATABASE = 'postgresql:https://postgres:test123@localhost:5432/sanchayai' | ||
|
||
engine = create_engine(URL_DATABASE) | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from fastapi import FastAPI, HTTPException, Depends | ||
from pydantic import BaseModel | ||
from typing import List, Annotated | ||
import models | ||
from database import engine, SessionLocal | ||
from sqlalchemy.orm import Session | ||
|
||
app = FastAPI() | ||
models.Base.metadata.create_all(bind=engine) | ||
|
||
def get_db(): | ||
db = SessionLocal() | ||
try: | ||
yield db | ||
finally: | ||
db.close() | ||
|
||
|
||
db_dependency = Annotated[Session, Depends(get_db)] | ||
|
||
|
||
@app.get("/_readyz") | ||
@app.get("/_healthz") | ||
def read_root(): | ||
return {"status": "ok"} | ||
|
||
|
||
class Needs(BaseModel): | ||
transcoding: bool | ||
subtitles: bool | ||
thumbnails: bool | ||
|
||
|
||
class Project(BaseModel): | ||
project: str | ||
videoURL: str | ||
needs: Needs | ||
|
||
|
||
@app.get("/projects") | ||
async def read_projects(db:db_dependency): | ||
result = db.query(models.Projects).all() | ||
return result | ||
|
||
@app.post("/generate-all") | ||
async def create_project(project:Project, db: db_dependency): | ||
# Step 1: Insert project into db | ||
db_project = models.Projects(project=project.project, videoURL=project.videoURL, needTranscoding=project.needs.transcoding, needSubtitles=project.needs.subtitles, needThumbnails=project.needs.thumbnails) | ||
db.add(db_project) | ||
db.commit() | ||
db.refresh(db_project) | ||
|
||
# Step 2: Generate transcoding | ||
|
||
# Step 3: Upload to bucket | ||
|
||
# Step 4: Update table with bucket | ||
return project |
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,18 @@ | ||
from sqlalchemy import Boolean, Column, Integer, String | ||
from database import Base | ||
|
||
class Projects(Base): | ||
__tablename__ = 'projects' | ||
|
||
id = Column(Integer, primary_key=True, index=True) | ||
userId = Column(String,index=True) | ||
project = Column(String, index=True) | ||
videoURL = Column(String, index=True) | ||
needTranscoding = Column(Boolean, default=False) | ||
needSubtitles = Column(Boolean, default=False) | ||
needThumbnails = Column(Boolean, default=False) | ||
transcodingURL = Column(String,default="") | ||
subtitlesURL = Column(String, default="") | ||
thumbnailsURL = Column(String, default="") | ||
createdAt = Column(String, default="") | ||
modifiedAt = Column(String, default="") |
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,26 @@ | ||
### Sanchay AI (Backend Server | Built using Python FastAPI) | ||
|
||
[Placeholder for more documentaiton] | ||
|
||
### Requirements: | ||
- Python3 | ||
- PostgreSQL DB | ||
|
||
### Installation: | ||
|
||
- Create a new Virtual Environment 'env' using `python3 -m venv env` | ||
- Activate the `env` Environment using `source env/bin/activate` | ||
- Install libraries using `pip install fastapi sqlalchemy psycopg2-binary uvicorn` or `pip install -r requirements.txt` | ||
- Create sanchayai DB and replace your connection string in /api/database.py (postgresql:https://postgres:test123@localhost:5432/sanchayai) | ||
|
||
### Run Project: | ||
|
||
- python3 run.py | ||
- On your browser: http:https://127.0.0.1:5000/docs | ||
|
||
|
||
Reference links: | ||
- https://youtu.be/398DuQbQJq0?si=dAW1-QT3bxgZ45Oq | ||
|
||
|
||
For any queries, add your doubts in the issues section and attach the `question` label to it. |
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,14 @@ | ||
annotated-types==0.6.0 | ||
anyio==4.2.0 | ||
click==8.1.7 | ||
fastapi==0.108.0 | ||
h11==0.14.0 | ||
idna==3.6 | ||
psycopg2-binary==2.9.9 | ||
pydantic==2.5.3 | ||
pydantic_core==2.14.6 | ||
sniffio==1.3.0 | ||
SQLAlchemy==2.0.24 | ||
starlette==0.32.0.post1 | ||
typing_extensions==4.9.0 | ||
uvicorn==0.25.0 |
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 @@ | ||
import uvicorn | ||
from main import app | ||
|
||
if __name__ == "__main__": | ||
uvicorn.run("main:app", port=5000, log_level="info") |
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 +1,18 @@ | ||
[{"title": "Introduction", "start": "00:00.000", "end": "00:29.840"}, {"title": "Working at a Web 3 Wallet", "start": "00:29.840", "end": "02:50.880"}, {"title": "Transition to AWS and Auto-Scaling", "start": "02:50.880", "end": "03:51.360"}, {"title": "NFT Mint Process", "start": "03:51.360", "end": "05:18.400"}, {"title": "Transition to Cryptocurrency Exchange", "start": "05:18.400", "end": "06:20.160"}, {"title": "Experiences with Rust and Finance Jargon", "start": "06:20.240", "end": "07:56.720"}, {"title": "React Native and Blockchain Indexing", "start": "07:56.720", "end": "09:39.280"}, {"title": "Monitoring Systems and Future Plans", "start": "09:39.280", "end": "10:45.120"}, {"title": "movement at this moment", "start": "10:45.120", "end": "10:53.520"}, {"title": "project in AI", "start": "10:53.520", "end": "11:03.280"}, {"title": "interest in fine-tuning models", "start": "11:03.280", "end": "11:14.800"}, {"title": "interest in decentralized finance", "start": "11:14.800", "end": "11:23.600"}, {"title": "interest in decentralized exchange", "start": "11:23.600", "end": "11:35.040"}, {"title": "interest in video streaming", "start": "11:39.120", "end": "12:18.160"}, {"title": "interest in scalable cloud execution engines", "start": "12:18.160", "end": "12:52.880"}, {"title": "concluding remarks", "start": "13:00.400", "end": "13:10.960"}] | ||
[ | ||
{ "title": "Introduction", "start": "00:00.000", "end": "00:29.840" }, | ||
{ "title": "Working at a Web 3 Wallet", "start": "00:29.840", "end": "02:50.880" }, | ||
{ "title": "Transition to AWS and Auto-Scaling", "start": "02:50.880", "end": "03:51.360" }, | ||
{ "title": "NFT Mint Process", "start": "03:51.360", "end": "05:18.400" }, | ||
{ "title": "Transition to Cryptocurrency Exchange", "start": "05:18.400", "end": "06:20.160" }, | ||
{ "title": "Experiences with Rust and Finance Jargon", "start": "06:20.240", "end": "07:56.720" }, | ||
{ "title": "React Native and Blockchain Indexing", "start": "07:56.720", "end": "09:39.280" }, | ||
{ "title": "Monitoring Systems and Future Plans", "start": "09:39.280", "end": "10:45.120" }, | ||
{ "title": "movement at this moment", "start": "10:45.120", "end": "10:53.520" }, | ||
{ "title": "project in AI", "start": "10:53.520", "end": "11:03.280" }, | ||
{ "title": "interest in fine-tuning models", "start": "11:03.280", "end": "11:14.800" }, | ||
{ "title": "interest in decentralized finance", "start": "11:14.800", "end": "11:23.600" }, | ||
{ "title": "interest in decentralized exchange", "start": "11:23.600", "end": "11:35.040" }, | ||
{ "title": "interest in video streaming", "start": "11:39.120", "end": "12:18.160" }, | ||
{ "title": "interest in scalable cloud execution engines", "start": "12:18.160", "end": "12:52.880" }, | ||
{ "title": "concluding remarks", "start": "13:00.400", "end": "13:10.960" } | ||
] |