Skip to content

Commit 3ec916e

Browse files
committed
Updating files.
1 parent dc89349 commit 3ec916e

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

mastering-carol/batch-data-app/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Import necessary libraries
22
import pandas as pd
33
import os
4+
import json
45

56
from sklearn.impute import SimpleImputer
67
from sklearn.model_selection import train_test_split
@@ -23,6 +24,15 @@
2324
app = Apps(carol)
2425
settings = app.get_settings()
2526

27+
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "./application_default_credentials.json"
28+
29+
if not os.path.exists(os.environ["GOOGLE_APPLICATION_CREDENTIALS"]):
30+
service_account = settings['g_serviceaccount']
31+
with open(os.environ["GOOGLE_APPLICATION_CREDENTIALS"], "w") as json_file:
32+
json.dump(json.loads(service_account), json_file, indent=4)
33+
else:
34+
logging.info('using the standard file for Google SA.')
35+
2636
os.environ["OPENAI_ORGANIZATION"] = settings['openai_organization']
2737
os.environ["OPENAI_API_KEY"] = settings['openai_api_key']
2838

mastering-carol/online-data-app/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
app = Apps(carol)
2525
settings = app.get_settings()
2626

27-
# if not os.path.exists(os.environ["GOOGLE_APPLICATION_CREDENTIALS"]):
28-
# service_account = settings['g_serviceaccount']
29-
# with open(os.environ["GOOGLE_APPLICATION_CREDENTIALS"], "w") as json_file:
30-
# json.dump(json.loads(service_account), json_file, indent=4)
31-
# else:
32-
# logging.info('using the standard file for Google SA.')
27+
if not os.path.exists(os.environ["GOOGLE_APPLICATION_CREDENTIALS"]):
28+
service_account = settings['g_serviceaccount']
29+
with open(os.environ["GOOGLE_APPLICATION_CREDENTIALS"], "w") as json_file:
30+
json.dump(json.loads(service_account), json_file, indent=4)
31+
else:
32+
logging.info('using the standard file for Google SA.')
3333

3434
os.environ["OPENAI_ORGANIZATION"] = settings['openai_organization']
3535
os.environ["OPENAI_API_KEY"] = settings['openai_api_key']

0 commit comments

Comments
 (0)