Spaces:
Sleeping
Sleeping
yuki.tsutsumi
commited on
Commit
•
c4a6b98
1
Parent(s):
46beb03
[update]本番と開発環境の切り分けの仕組みを導入。
Browse files- .env.example +1 -0
- src/aws/s3.py +3 -1
- src/forms/change_request.py +26 -1
- src/forms/change_request_history.py +13 -1
.env.example
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
OPENAI_API_KEY=XXX
|
2 |
PINECONE_API_KEY=YYY
|
3 |
AWS_ACCESS_KEY_ID=ZZZ
|
|
|
1 |
+
ENV=development
|
2 |
OPENAI_API_KEY=XXX
|
3 |
PINECONE_API_KEY=YYY
|
4 |
AWS_ACCESS_KEY_ID=ZZZ
|
src/aws/s3.py
CHANGED
@@ -10,7 +10,9 @@ from src.utils import setup_logger
|
|
10 |
logger = setup_logger(__name__)
|
11 |
|
12 |
trial_bucket_name = "pharma-doc-trials"
|
13 |
-
|
|
|
|
|
14 |
csv_extension = ".csv"
|
15 |
err_msg_file_is_not_csv = "指定したファイルはcsvではありません。"
|
16 |
|
|
|
10 |
logger = setup_logger(__name__)
|
11 |
|
12 |
trial_bucket_name = "pharma-doc-trials"
|
13 |
+
base_change_request_history_file_path_in_trial_bucket = (
|
14 |
+
"bankyo/change_request_history.csv"
|
15 |
+
)
|
16 |
csv_extension = ".csv"
|
17 |
err_msg_file_is_not_csv = "指定したファイルはcsvではありません。"
|
18 |
|
src/forms/change_request.py
CHANGED
@@ -10,7 +10,7 @@ from dotenv import load_dotenv
|
|
10 |
from openai import OpenAI
|
11 |
from pinecone import Pinecone
|
12 |
|
13 |
-
from src.aws.s3 import
|
14 |
from src.aws.s3 import get_client as get_s3_client
|
15 |
from src.aws.s3 import (
|
16 |
get_csv_as_pd_dataframe_from_s3,
|
@@ -503,6 +503,19 @@ def change_request_form() -> None:
|
|
503 |
bucket_name = "pharma-doc-trials"
|
504 |
|
505 |
s3_client = get_s3_client()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
data = get_csv_as_pd_dataframe_from_s3(
|
507 |
s3_client, bucket_name, change_request_history_file_path_in_trial_bucket
|
508 |
)
|
@@ -595,6 +608,18 @@ def save_change_request_history(
|
|
595 |
) -> None:
|
596 |
s3_client = get_s3_client()
|
597 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
df = get_csv_as_pd_dataframe_from_s3(
|
599 |
s3_client,
|
600 |
trial_bucket_name,
|
|
|
10 |
from openai import OpenAI
|
11 |
from pinecone import Pinecone
|
12 |
|
13 |
+
from src.aws.s3 import base_change_request_history_file_path_in_trial_bucket
|
14 |
from src.aws.s3 import get_client as get_s3_client
|
15 |
from src.aws.s3 import (
|
16 |
get_csv_as_pd_dataframe_from_s3,
|
|
|
503 |
bucket_name = "pharma-doc-trials"
|
504 |
|
505 |
s3_client = get_s3_client()
|
506 |
+
env = os.environ["ENV"]
|
507 |
+
if env != "production":
|
508 |
+
file_name, file_extension = os.path.splitext(
|
509 |
+
base_change_request_history_file_path_in_trial_bucket
|
510 |
+
)
|
511 |
+
change_request_history_file_path_in_trial_bucket = (
|
512 |
+
f"{file_name}_{env}{file_extension}"
|
513 |
+
)
|
514 |
+
else:
|
515 |
+
change_request_history_file_path_in_trial_bucket = (
|
516 |
+
base_change_request_history_file_path_in_trial_bucket
|
517 |
+
)
|
518 |
+
|
519 |
data = get_csv_as_pd_dataframe_from_s3(
|
520 |
s3_client, bucket_name, change_request_history_file_path_in_trial_bucket
|
521 |
)
|
|
|
608 |
) -> None:
|
609 |
s3_client = get_s3_client()
|
610 |
try:
|
611 |
+
env = os.environ["ENV"]
|
612 |
+
if env != "production":
|
613 |
+
file_name, file_extension = os.path.splitext(
|
614 |
+
base_change_request_history_file_path_in_trial_bucket
|
615 |
+
)
|
616 |
+
change_request_history_file_path_in_trial_bucket = (
|
617 |
+
f"{file_name}_{env}{file_extension}"
|
618 |
+
)
|
619 |
+
else:
|
620 |
+
change_request_history_file_path_in_trial_bucket = (
|
621 |
+
base_change_request_history_file_path_in_trial_bucket
|
622 |
+
)
|
623 |
df = get_csv_as_pd_dataframe_from_s3(
|
624 |
s3_client,
|
625 |
trial_bucket_name,
|
src/forms/change_request_history.py
CHANGED
@@ -3,7 +3,7 @@ import os
|
|
3 |
import streamlit as st
|
4 |
|
5 |
from src.aws.s3 import (
|
6 |
-
|
7 |
get_client,
|
8 |
get_csv_as_pd_dataframe_from_s3,
|
9 |
trial_bucket_name,
|
@@ -14,6 +14,18 @@ from src.forms.change_request import change_request_history_file_path
|
|
14 |
def change_request_history() -> None:
|
15 |
s3_client = get_client()
|
16 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
data = get_csv_as_pd_dataframe_from_s3(
|
18 |
s3_client,
|
19 |
trial_bucket_name,
|
|
|
3 |
import streamlit as st
|
4 |
|
5 |
from src.aws.s3 import (
|
6 |
+
base_change_request_history_file_path_in_trial_bucket,
|
7 |
get_client,
|
8 |
get_csv_as_pd_dataframe_from_s3,
|
9 |
trial_bucket_name,
|
|
|
14 |
def change_request_history() -> None:
|
15 |
s3_client = get_client()
|
16 |
try:
|
17 |
+
env = os.environ["ENV"]
|
18 |
+
if env != "production":
|
19 |
+
file_name, file_extension = os.path.splitext(
|
20 |
+
base_change_request_history_file_path_in_trial_bucket
|
21 |
+
)
|
22 |
+
change_request_history_file_path_in_trial_bucket = (
|
23 |
+
f"{file_name}_{env}{file_extension}"
|
24 |
+
)
|
25 |
+
else:
|
26 |
+
change_request_history_file_path_in_trial_bucket = (
|
27 |
+
base_change_request_history_file_path_in_trial_bucket
|
28 |
+
)
|
29 |
data = get_csv_as_pd_dataframe_from_s3(
|
30 |
s3_client,
|
31 |
trial_bucket_name,
|