forked from gitcoinco/gitcoin_cadcad_model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_simulation.py
34 lines (25 loc) · 950 Bytes
/
run_simulation.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
import cloudpickle
from env_config import PICKLE_PATH, RUN_PARAMS
import os
import click
@click.command()
@click.option('--n', default=None, help="Number of timesteps to process ('all' for doing everything)")
@click.option('--compute_qf', default=None, help="Compute QF. This can be computationally expensive (yes/no)")
def main(n: str, compute_qf: str):
params = {**RUN_PARAMS}
if n is not None:
params['GITCOIN_TIMESTEPS'] = n
if compute_qf is not None:
params['GITCOIN_COMPUTE_QF'] = compute_qf
for (key, value) in params.items():
os.environ[key] = value
print("Preparing simulation")
from model_gitcoin.run import run
print("Run simuation")
result = run()
print(f"Simulation executed! Pickling result to {PICKLE_PATH}")
with open(PICKLE_PATH, 'wb') as fid:
cloudpickle.dump(result, fid)
print("Results pickled sucessfuly")
if __name__ == '__main__':
main()