Skip to content

Commit 1063203

Browse files
committed
Feat : Added object path
1 parent a49bf8b commit 1063203

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

upstock/config.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,32 @@
1010
from supabase import create_client, Client
1111
from dataclasses import dataclass # create data class
1212

13-
# env load
14-
load_dotenv()
13+
@dataclass(frozen=True) # immutable
14+
class Config:
15+
# online
16+
supabase_url: str
17+
supabase_key: str
18+
bucket: str = 'sentiemnt_file' # supabase bucket name
19+
tbl_sentiment: str = 'news_sentiment' # table name
20+
source: str = 'finviz'
21+
tz_target: str = 'Asia/Seoul'
22+
23+
# local path
24+
sentiment_path: str = 'DataSets/upstock-sentiment-data.csv' # sentiment data
25+
tokenizer_path: str = 'SaveModel/upstock_sentiment_tokenizer.pickle'
26+
model_path: str = 'SaveModel/upstock_sentiment_model.keras'
27+
model_path_h5: str = 'SaveModel/upstock_sentiment_model.h5' # compatibility issue .h5
1528

16-
supabase_url = os.getenv('SupaBase_Url')
17-
supabase_key = os.getenv('SupaBase_Key')
29+
# 논문 근거
30+
model_pkl_path: str = 'SaveModel/upstock_sentiment_pkl.pkl' # import matplotlib.pyplot as plt
1831

19-
# connect sb sdk
20-
supabase: Client = create_client(
21-
supabase_url,
22-
supabase_key,
23-
)
24-
25-
# 경로
26-
sentiment_path = 'DataSets/upstock-sentiment-data.csv' # sentiment data
27-
tokenizer_path = 'SaveModel/upstock_sentiment_tokenizer.pickle'
28-
model_path = 'SaveModel/upstock_sentiment_model.keras'
29-
model_path_h5 = 'SaveModel/upstock_sentiment_model.h5' # compatibility issue .h5
30-
31-
# 논문 근거
32-
model_pkl_path = 'SaveModel/upstock_sentiment_pkl.pkl' # import matplotlib.pyplot as plt
32+
def load_config() -> Config:
33+
load_dotenv() # env load
34+
url = os.getenv('SUPABASE_URL')
35+
key = os.getenv('SUPABASE_KEY')
36+
if not url or not key:
37+
raise RuntimeError('Supabase URL, KEY Error')
38+
return Config(supabase_url=url, supabase_key=key)
3339

3440
# TEST
3541
# model.summary()

0 commit comments

Comments
 (0)