mirror of
https://github.com/logos-co/SimulationsFramework.git
synced 2025-02-22 10:48:17 +00:00
Changed input configuration to have just one file from the volume, and one argument from the user
This commit is contained in:
parent
c73b520a10
commit
48fe494666
1
src/configuration_settings.json
Executable file
1
src/configuration_settings.json
Executable file
@ -0,0 +1 @@
|
||||
{"consensus_settings": {"snow_ball": {"quorum_size": 14, "sample_size": 20, "decision_threshold": 20}}, "distribution": {"yes": 0.6, "no": 0.4, "none": 0.0}, "byzantine_settings": {"total_size": 10000, "distribution": {"honest": 1.0, "infantile": 0.0, "random": 0.0, "omniscient": 0.0}}, "wards": [{"time_to_finality": {"ttf_threshold": 1}}], "network_modifiers": [{"random_drop": {"drop_rate": 0.01}}], "seed": 18042022}
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"arguments": {"output-format": "csv", "output-file": "test"},
|
||||
"simulation": {
|
||||
"consensus_settings": {
|
||||
"snow_ball": {
|
||||
|
@ -1,5 +1,10 @@
|
||||
# Workaround while docker is not set up
|
||||
|
||||
# binary_path = "wsl /mnt/d/Projects/status/Rust/consensus-research/target/release-opt/snow-family"
|
||||
binary_name = "snow-family"
|
||||
schema_path = "../utilities/files/schemas/snow_family_configuration_schema.json"
|
||||
binary_path = "wsl /mnt/d/Projects/status/Rust/consensus-research/target/release-opt/snow-family"
|
||||
# binary_path = "snow-family"
|
||||
# input_settings = "/app/config_example.json"
|
||||
input_settings = "simulation_runner/config_example.json"
|
||||
configuration_settings = "configuration_settings.json"
|
||||
arguments_schema_path = "utilities/files/schemas/arguments_schema.json"
|
||||
configuration_schema_path = "utilities/files/schemas/snow_family_configuration_schema.json"
|
||||
|
||||
|
@ -3,13 +3,18 @@ import json
|
||||
import jsonschema
|
||||
|
||||
|
||||
def read_json(file_path):
|
||||
def read_json(file_path: str) -> dict:
|
||||
with open(file_path, "r") as file:
|
||||
json_content = json.load(file)
|
||||
|
||||
return json_content
|
||||
|
||||
|
||||
def validate_json(json_content, json_schema):
|
||||
def write_json(info: dict, file_path: str):
|
||||
with open(file_path, "w") as file:
|
||||
json.dump(info, file)
|
||||
|
||||
|
||||
def validate_json(json_content: dict, json_schema: dict):
|
||||
jsonschema.validate(instance=json_content, schema=json_schema)
|
||||
|
||||
|
@ -1,20 +1,32 @@
|
||||
# Project Imports
|
||||
from src.utilities import env_variables
|
||||
from src.utilities.files.json.json_utils import read_json, validate_json
|
||||
|
||||
|
||||
class SimulationConfigParser:
|
||||
_file_path: str
|
||||
|
||||
def __init__(self, file_path):
|
||||
def __init__(self, file_path: str):
|
||||
self._file_path = file_path
|
||||
self._configuration = None
|
||||
|
||||
def read_content(self):
|
||||
def read_content(self) -> tuple[dict, dict, dict]:
|
||||
# Retrieve raw info
|
||||
json_configuration = read_json(self._file_path)
|
||||
|
||||
# Retrieve valid schema
|
||||
json_schema = read_json(env_variables.schema_path)
|
||||
# Split two parts
|
||||
arguments_config = json_configuration["arguments"]
|
||||
simulation_config = json_configuration["simulation"]
|
||||
# plotter_config = json_configuration["plotter"]
|
||||
|
||||
# Retrieve valid schemas
|
||||
arguments_json_schema = read_json(env_variables.arguments_schema_path)
|
||||
config_json_schema = read_json(env_variables.configuration_schema_path)
|
||||
# plotter_json_schema = read_json(env_variables.plotter_schema_path)
|
||||
|
||||
# Validate
|
||||
validate_json(json_configuration, json_schema)
|
||||
self._configuration = json_configuration
|
||||
validate_json(arguments_config, arguments_json_schema)
|
||||
validate_json(simulation_config, config_json_schema)
|
||||
# validate_json(plotter_config, plotter_json_schema)
|
||||
|
||||
# return simulation_config, plotter_config
|
||||
return arguments_config, simulation_config, {}
|
||||
|
7
src/utilities/files/schemas/arguments_schema.json
Executable file
7
src/utilities/files/schemas/arguments_schema.json
Executable file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"output-format": {"type": "string", "enum" : ["parquet", "csv", "json"]},
|
||||
"output-file": {"type": "string"}
|
||||
}
|
||||
}
|
0
src/utilities/files/schemas/plotter_schema.json
Executable file
0
src/utilities/files/schemas/plotter_schema.json
Executable file
Loading…
x
Reference in New Issue
Block a user