Skip to content

Commit

Permalink
subapp doesnt run startup, move to main
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecoconut committed Nov 17, 2022
1 parent 0529408 commit 11b4780
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
5 changes: 5 additions & 0 deletions sketch/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import faiss

from ..core import Portfolio, SketchPad
from ..examples.prompt_machine import database as database2
from ..examples.prompt_machine import setup_database as setup_database2
from ..metrics import strings_from_sketchpad_sketches
from . import auth, data, models
from .deps import *
Expand Down Expand Up @@ -91,11 +93,14 @@
async def database_connect():
await database.connect()
await data.setup_database(database)
await database2.connect()
await setup_database2(database2)


@app.on_event("shutdown")
async def database_disconnect():
await database.disconnect()
await database2.disconnect()


@app.on_event("startup")
Expand Down
13 changes: 1 addition & 12 deletions sketch/api/promptapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,13 @@

from fastapi import BackgroundTasks, FastAPI

from ..examples.prompt_machine import database, get_prompts_for_task_id, setup_database
from ..examples.prompt_machine import get_prompts_for_task_id
from .nbasql import get_data_for_question_prompt
from .search_based_answers import google_answer_to_question

promptApiApp = FastAPI(root_path="/prompt")


@promptApiApp.on_event("startup")
async def database_connect():
await database.connect()
await setup_database(database)


@promptApiApp.on_event("shutdown")
async def database_disconnect():
await database.disconnect()


class CallWithId:
def __init__(self, func, task_id):
self.func = func
Expand Down

0 comments on commit 11b4780

Please sign in to comment.