From 9d1605bc2a2a8ab2a28b4935e789f525feb878fb Mon Sep 17 00:00:00 2001 From: dev-abuke Date: Tue, 25 Jun 2024 12:43:20 +0300 Subject: [PATCH] feat: allow cors origin all --- 0.5.1 | 35 +++++++++++++++++++++++++++++++++++ backend/main.py | 14 +++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 0.5.1 diff --git a/0.5.1 b/0.5.1 new file mode 100644 index 0000000..0493645 --- /dev/null +++ b/0.5.1 @@ -0,0 +1,35 @@ +Collecting nixtla + Downloading nixtla-0.5.1-py3-none-any.whl.metadata (4.8 kB) +Requirement already satisfied: httpx in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from nixtla) (0.27.0) +Requirement already satisfied: pandas in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from nixtla) (2.2.2) +Requirement already satisfied: pydantic in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from nixtla) (2.7.4) +Requirement already satisfied: requests in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from nixtla) (2.32.3) +Collecting tenacity (from nixtla) + Downloading tenacity-8.4.1-py3-none-any.whl.metadata (1.2 kB) +Collecting utilsforecast>=0.1.7 (from nixtla) + Downloading utilsforecast-0.1.11-py3-none-any.whl.metadata (7.4 kB) +Requirement already satisfied: numpy in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from utilsforecast>=0.1.7->nixtla) (1.26.4) +Requirement already satisfied: packaging in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from utilsforecast>=0.1.7->nixtla) (24.1) +Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from pandas->nixtla) (2.9.0.post0) +Requirement already satisfied: pytz>=2020.1 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from pandas->nixtla) (2024.1) +Requirement already satisfied: tzdata>=2022.7 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from pandas->nixtla) (2024.1) +Requirement already satisfied: anyio in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from httpx->nixtla) (4.4.0) +Requirement already satisfied: certifi in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from httpx->nixtla) (2024.6.2) +Requirement already satisfied: httpcore==1.* in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from httpx->nixtla) (1.0.5) +Requirement already satisfied: idna in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from httpx->nixtla) (3.7) +Requirement already satisfied: sniffio in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from httpx->nixtla) (1.3.1) +Requirement already satisfied: h11<0.15,>=0.13 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from httpcore==1.*->httpx->nixtla) (0.14.0) +Requirement already satisfied: annotated-types>=0.4.0 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from pydantic->nixtla) (0.7.0) +Requirement already satisfied: pydantic-core==2.18.4 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from pydantic->nixtla) (2.18.4) +Requirement already satisfied: typing-extensions>=4.6.1 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from pydantic->nixtla) (4.12.2) +Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from requests->nixtla) (3.3.2) +Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from requests->nixtla) (2.2.2) +Requirement already satisfied: six>=1.5 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from python-dateutil>=2.8.2->pandas->nixtla) (1.16.0) +Requirement already satisfied: exceptiongroup>=1.0.2 in c:\users\user\downloads\ten_academy\week9\scalable_backtesting_infrastructure_for_crypto_trading\backtest\lib\site-packages (from anyio->httpx->nixtla) (1.2.1) +Downloading nixtla-0.5.1-py3-none-any.whl (71 kB) + ---------------------------------------- 71.4/71.4 kB 561.5 kB/s eta 0:00:00 +Downloading utilsforecast-0.1.11-py3-none-any.whl (40 kB) + ---------------------------------------- 40.6/40.6 kB 978.0 kB/s eta 0:00:00 +Downloading tenacity-8.4.1-py3-none-any.whl (27 kB) +Installing collected packages: tenacity, utilsforecast, nixtla +Successfully installed nixtla-0.5.1 tenacity-8.4.1 utilsforecast-0.1.11 diff --git a/backend/main.py b/backend/main.py index 7b46573..c4a6d7e 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,5 +1,6 @@ from typing import List from fastapi import FastAPI, Depends, HTTPException +from fastapi.middleware.cors import CORSMiddleware from sqlalchemy.orm import Session, joinedload from sqlalchemy.exc import IntegrityError import pandas as pd @@ -9,7 +10,7 @@ from .auth import router as auth_router from kafka_topic.kafka_config import get_kafka_producer, SCENE_TOPIC, RESULT_TOPIC, get_kafka_consumer -from backend.utils.backtest import run_backtest +from scripts.backtesting.main import run_backtest from backend.utils.init_data import initialize_data get_db = database.get_db @@ -21,6 +22,17 @@ app = FastAPI() +# allow all origins +origins = ["*"] + +app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + @app.on_event("startup") # TODO update the code with lifespan dependency def start_kafka_consumer(): threading.Thread(target=consume_scene_parameters).start()