Simple run simulation with schema parsing
This commit is contained in:
parent
2aedf84843
commit
51d49b743d
|
@ -2,24 +2,22 @@
|
|||
import typer
|
||||
|
||||
# Project Imports
|
||||
from Utilities.file_parser import ConfigurationFileParser
|
||||
from Utilities.Files.Json.simulation_config_parser import SimulationConfigParser
|
||||
from runner import run_simulation
|
||||
|
||||
|
||||
def main(
|
||||
# todo put in output format possible names (-f --output-format)
|
||||
output_format: str = typer.Argument("parquet"),
|
||||
output_format: str = typer.Option(..., "--output-format", "-f"),
|
||||
input_settings: str = typer.Option(..., "--input-settings", "-i"),
|
||||
output_file: str = typer.Option(..., "--output-file", "-o")
|
||||
):
|
||||
# Check config file
|
||||
parser = ConfigurationFileParser(input_settings)
|
||||
config = parser.read_content()
|
||||
parser = SimulationConfigParser(input_settings)
|
||||
parser.read_content()
|
||||
# Calls simulation with configuration
|
||||
run_simulation(output_format, input_settings, output_file)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
typer.run(main)
|
||||
|
||||
# Run simulation with arguments
|
||||
|
||||
pass
|
|
@ -1,4 +1,9 @@
|
|||
# Python Imports
|
||||
import os
|
||||
|
||||
# Project Imports
|
||||
from Utilities.env_variables import binary_path
|
||||
|
||||
|
||||
def run_simulation():
|
||||
pass
|
||||
def run_simulation(output_format, input_settings, output_file):
|
||||
os.system(binary_path + " -f " + output_format + " -i " + input_settings + " -o " + output_file)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
from Utilities import env_variables
|
||||
from Utilities.Files.Json.json_utils import read_json, validate_json
|
||||
|
||||
|
||||
class SimulationConfigParser:
|
||||
|
||||
def __init__(self, file_path):
|
||||
self._file_path = file_path
|
||||
self._configuration = None
|
||||
|
||||
def read_content(self):
|
||||
# Retrieve raw info
|
||||
json_configuration = read_json(self._file_path)
|
||||
|
||||
# Retrieve valid schema
|
||||
json_schema = read_json(env_variables.schema_path)
|
||||
|
||||
# Validate
|
||||
validate_json(json_configuration, json_schema)
|
||||
self._configuration = json_configuration
|
|
@ -0,0 +1,4 @@
|
|||
# Workaround while docker is not set up
|
||||
|
||||
binary_path = "C:/Users/Alberto/Desktop/Status/consensus-prototypes/target/release-opt/consensus-simulations.exe"
|
||||
schema_path = "../Utilities/Files/Schemas/configuration_schema.json"
|
Loading…
Reference in New Issue