-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickstart.py
executable file
·78 lines (60 loc) · 2 KB
/
quickstart.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
import subprocess
from pathlib import Path
import textwrap
import venv
import sys
def main():
setup_venv()
setup_config()
initial_run()
remove_dummy_configs()
def setup_venv():
venvdir = Path('venv')
if venvdir.exists():
print('venv dir already exists; skipping venv setup', file=sys.stderr)
return
venv.create(venvdir, with_pip=True)
subprocess.check_call(['venv/bin/pip', 'install', '-r', 'requirements.in'])
subprocess.check_call(['venv/bin/jupytext-config', 'set-default-viewer'])
def setup_config():
confdir = Path('config')
if confdir.exists():
print('config dir already exists; skipping config setup', file=sys.stderr)
return
confdir.mkdir()
subprocess.check_call(['git', 'init'], cwd=confdir)
subprocess.check_call(
['git', 'commit', '--allow-empty', '-m', 'Initial commit'], cwd=confdir
)
with open('config/factor_modules.yaml', 'w') as f:
f.write(
textwrap.dedent(
"""\
- housing
- climate
"""
)
)
with open('config/locs.yaml', 'w') as f:
f.write(
textwrap.dedent(
"""\
new_york: [40.74864922773491, -73.98997143018362]
san_francisco: [37.77354825453357, -122.44098309231866]
seattle: [47.60743693357695, -122.33797497331248]
"""
)
)
# Write dummy values so we can do an initial run.
with open('config/value_of_good_weather_day.yaml', 'w') as f:
f.write('0')
with open('config/housing_marginal_utility_per_month.yaml', 'w') as f:
f.write('{1: 0, 2: 0, 3: 0, 4: 0, 5: 0}')
def initial_run():
subprocess.check_call(['./main.sh', 'summary'])
def remove_dummy_configs():
Path('config/value_of_good_weather_day.yaml').unlink()
Path('config/housing_marginal_utility_per_month.yaml').unlink()
if __name__ == '__main__':
main()