-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathexport.py
44 lines (38 loc) · 1.41 KB
/
export.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
from pathlib import Path
GAE = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
# If it's a filepath, read the file. Otherwise, it'll be JSON
try:
Path(GAE).resolve(strict=True)
with open(GAE, "r") as f:
GAE = f.read()
except Exception as e:
pass
DB_PD = os.environ["POLICYENGINE_DB_PASSWORD"]
GITHUB_MICRODATA_TOKEN = os.environ["POLICYENGINE_GITHUB_MICRODATA_AUTH_TOKEN"]
ANTHROPIC_API_KEY = os.environ["ANTHROPIC_API_KEY"]
OPENAI_API_KEY = os.environ["OPENAI_API_KEY"]
HUGGING_FACE_TOKEN = os.environ["HUGGING_FACE_TOKEN"]
# Export GAE to to .gac.json and DB_PD to .dbpw in the current directory
with open(".gac.json", "w") as f:
f.write(GAE)
with open(".dbpw", "w") as f:
f.write(DB_PD)
# in gcp/compute_api/Dockerfile, replace .github_microdata_token with the contents of the file
for dockerfile_location in [
"gcp/policyengine_api/Dockerfile",
]:
with open(dockerfile_location, "r") as f:
dockerfile = f.read()
dockerfile = dockerfile.replace(
".github_microdata_token", GITHUB_MICRODATA_TOKEN
)
dockerfile = dockerfile.replace(
".anthropic_api_key", ANTHROPIC_API_KEY
)
dockerfile = dockerfile.replace(".openai_api_key", OPENAI_API_KEY)
dockerfile = dockerfile.replace(
".hugging_face_token", HUGGING_FACE_TOKEN
)
with open(dockerfile_location, "w") as f:
f.write(dockerfile)