mirror of
https://github.com/logos-blockchain/logos-blockchain-simulations.git
synced 2026-02-26 08:03:13 +00:00
build_cases: duplicate configs
This commit is contained in:
parent
93edafe0e7
commit
cdb831a47b
47
build_cases.py
Normal file
47
build_cases.py
Normal file
@ -0,0 +1,47 @@
|
||||
import os
|
||||
import csv
|
||||
import json
|
||||
import random
|
||||
import shutil
|
||||
from build_config import build_config
|
||||
|
||||
def build_case(overlay, committees, nodes, config_name, max_view=1, network='default'):
|
||||
build_config(overlay, committees, nodes, config_name, max_view, network)
|
||||
# rename the runs with same configs
|
||||
if os.path.exists(f"../configs/{config_name}.json"):
|
||||
tail = random.randint(1, 10000)
|
||||
modified_name = f"{config_name}_{tail}"
|
||||
os.rename(f"{config_name}.json", f"{modified_name}.json")
|
||||
with open(f"{modified_name}.json", "r+") as f:
|
||||
data = json.load(f)
|
||||
data["stream_settings"]["path"] = f"{modified_name}.json"
|
||||
f.seek(0)
|
||||
json.dump(data, f)
|
||||
f.truncate()
|
||||
print((config_name, modified_name))
|
||||
config_name = modified_name
|
||||
shutil.move(f"{config_name}.json", "../configs/")
|
||||
|
||||
def build_cases(csv_path):
|
||||
with open(csv_path, 'r') as csv_file:
|
||||
reader = csv.reader(csv_file)
|
||||
for row in reader:
|
||||
overlay_type, node_count, committees, desc = row
|
||||
if overlay_type == "overlay":
|
||||
continue
|
||||
config_name = f"{overlay_type}_{node_count}_{committees}"
|
||||
# build_case(overlay_type, committees, node_count, f"{config_name}_view_1_default")
|
||||
# build_case(overlay_type, committees, node_count, f"{config_name}_view_10_default", max_view="5")
|
||||
# build_case(overlay_type, committees, node_count, f"{config_name}_view_10_optimistic", max_view="5", network="optimistic")
|
||||
# build_case(overlay_type, committees, node_count, f"{config_name}_view_10_pessimistic", max_view="5", network="pessimistic")
|
||||
build_case(overlay_type, committees, node_count, f"{config_name}_view_10_nolat", max_view="10", network="nolat")
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: python generate_configs.py <path_to_csv_file>")
|
||||
sys.exit(1)
|
||||
|
||||
csv_path = sys.argv[1]
|
||||
build_cases(csv_path)
|
||||
|
||||
48
run.sh
Normal file
48
run.sh
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
#for i in "10 100 200 300 400 500 600 700 800 900 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000"
|
||||
prefix="compare"
|
||||
for p in 0.8 0.5 #0.1 0.01 0.001 0.0001
|
||||
do
|
||||
dir="compare_"$p"/"
|
||||
mkdir -p $dir
|
||||
echo "overlay,nodes,committees_or_depth,description" > $dir$prefix"_"$p".csv"
|
||||
for i in 10 50 100 250 500 #750 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 12000 1400
|
||||
do
|
||||
python3 build_tests.py --num-nodes $i --failure-threshold $p >> $dir$prefix"_"$p".csv"
|
||||
echo "num-nodes = $i, failure-threshold = $p"
|
||||
done
|
||||
done
|
||||
|
||||
|
||||
|
||||
for p in 0.8 0.5 0.1 0.01 0.001 0.0001
|
||||
do
|
||||
dir="compare_"$p"/"
|
||||
cd $dir
|
||||
mkdir configs output scripts
|
||||
cp ../*.py scripts
|
||||
cd scripts
|
||||
ln -s ../../config_builder/
|
||||
python3 build_cases.py ../$prefix"_"$p".csv"
|
||||
cd ..
|
||||
python3 scripts/run_configs.py configs/
|
||||
rm -rf scripts
|
||||
cd ..
|
||||
echo "config gen ($p) done.."
|
||||
done
|
||||
|
||||
|
||||
|
||||
for p in 0.8 0.5 #0.1 0.01 0.001 0.0001
|
||||
do
|
||||
|
||||
dir="compare_"$p"/"
|
||||
cd $dir
|
||||
pwd
|
||||
ls -l output/*.json | awk '{print $9}' > json_files
|
||||
sed -e s/\.json//g -i json_files
|
||||
for i in `cat json_files`
|
||||
do
|
||||
mv output/$i.json output/$i.csv
|
||||
done
|
||||
done
|
||||
@ -1,14 +1,25 @@
|
||||
import os
|
||||
import csv
|
||||
import json
|
||||
import random
|
||||
import shutil
|
||||
from build_config import build_config
|
||||
|
||||
def build_case(overlay, committees, nodes, config_name, max_view=1, network='default'):
|
||||
build_config(overlay, committees, nodes, config_name, max_view, network)
|
||||
# rename the runs with same configs
|
||||
if os.path.exists(f"../configs/{config_name}.json"):
|
||||
os.rename(f"{config_name}.json", f"{config_name}1.json")
|
||||
config_name=f"{config_name}1"
|
||||
print(config_name)
|
||||
tail = random.randint(1, 10000)
|
||||
modified_name = f"{config_name}_{tail}"
|
||||
os.rename(f"{config_name}.json", f"{modified_name}.json")
|
||||
with open(f"{modified_name}.json", "r+") as f:
|
||||
data = json.load(f)
|
||||
data["stream_settings"]["path"] = f"{modified_name}.json"
|
||||
f.seek(0)
|
||||
json.dump(data, f)
|
||||
f.truncate()
|
||||
print((config_name, modified_name))
|
||||
config_name = modified_name
|
||||
shutil.move(f"{config_name}.json", "../configs/")
|
||||
|
||||
def build_cases(csv_path):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user