Commit ·
76a283e
1
Parent(s): 28a6437
Add logging and comment out unused code
Browse files13 unmodified lines141516171819202122232425101 unmodified lines12712812913013113213313413558 unmodified lines19419519619719819920020120220320420520620720820921021121221321421513 unmodified linesfrom starlette.responses import RedirectResponsefrom cashews import cachefrom datetime import timedeltacache.setup("mem://")app = FastAPI()logger = logging.get_logger(__name__)load_dotenv()HF_TOKEN = os.getenv("HF_TOKEN")101 unmodified linesmodel_path = hf_hub_download(repo_id,"model.bin",cache_dir="code/models",local_dir="code/models",local_dir_use_symlinks=False,)return fasttext.load_model(model_path)58 unmodified linesfiltered_dict = {k: v for k, v in predictions_by_lang.items() if k in keys_to_keep}return {"predictions": dict(valmap(get_mean_score, filtered_dict)),"pred": predictions,}# @app.get("/", response_class=HTMLResponse)# async def read_index():# html_content = Path("index.html").read_text()# return HTMLResponse(content=html_content)@app.get("/", include_in_schema=False)def root():return RedirectResponse(url="/docs")@app.get("/predict_dataset_language/{hub_id}")@cache(ttl=timedelta(minutes=10))async def predict_language(hub_id: str,13 unmodified lines1415161718192021222324252627101 unmodified lines12913013113213313413513613758 unmodified lines19619719819920020120220320420520620720820921013 unmodified linesfrom starlette.responses import RedirectResponsefrom cashews import cachefrom datetime import timedeltaimport loggingcache.setup("mem://")logger = logging.getLogger(__name__)app = FastAPI()# logger = logging.get_logger(__name__)load_dotenv()HF_TOKEN = os.getenv("HF_TOKEN")101 unmodified linesmodel_path = hf_hub_download(repo_id,"model.bin",# cache_dir="code/models",# local_dir="code/models",# local_dir_use_symlinks=False,)return fasttext.load_model(model_path)58 unmodified linesfiltered_dict = {k: v for k, v in predictions_by_lang.items() if k in keys_to_keep}return {"predictions": dict(valmap(get_mean_score, filtered_dict)),}@app.get("/", include_in_schema=False)def root():return RedirectResponse(url="/docs")@app.get("/predict_dataset_language/{hub_id:path}")@cache(ttl=timedelta(minutes=10))async def predict_language(hub_id: str,
main.py+7-12