Simple run simulation with schema parsing

This commit is contained in:
Alberto 2022-09-29 19:13:16 +02:00
parent 2aedf84843
commit 51d49b743d
6 changed files with 37 additions and 10 deletions

View File

@ -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

View File

@ -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)

View 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

View File

@ -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"