Commit 151cb09f authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

add new sub command to VadereConsole.java to allow ci script to run single scenario files

parent ff1c7a9f
Pipeline #64355 failed with stages
in 2 minutes and 21 seconds
......@@ -55,7 +55,7 @@ def run_scenario_files_with_vadere_console(scenario_files, vadere_console="Vader
wall_time_start = time.time()
# Use timout feature, check return value and capture stdout/stderr to a PIPE (use completed_process.stdout to get it).
completed_process = subprocess.run(args=["java", "-enableassertions", "-jar", vadere_console, scenario_file, output_dir],
completed_process = subprocess.run(args=["java", "-enableassertions", "-jar", vadere_console, "scenario-run", "-f", scenario_file, " -o",output_dir],
timeout=scenario_timeout_in_sec,
check=True,
stdout=subprocess.PIPE,
......@@ -89,4 +89,3 @@ if __name__ == "__main__":
exit(1)
else:
exit(0)
package org.vadere.simulator.entrypoints;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.log4j.Logger;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.ScenarioRun;
import java.nio.file.Path;
import java.nio.file.Paths;
public class ScenarioRunSubCommand implements SubCommandRunner{
private final static Logger logger = Logger.getLogger(ScenarioRunSubCommand.class);
@Override
public void run(Namespace ns, ArgumentParser parser) {
Path outputDir = Paths.get(ns.getString("output-dir"));
if (!outputDir.toFile().exists()){
if ( ! outputDir.toFile().mkdirs() ) {
logger.error("Could not create all necessary directories: " + outputDir.toFile().toString());
System.exit(-1);
} else {
logger.info("Created output directory: " + outputDir.toAbsolutePath().toFile().toString());
}
} else {
logger.info("Use output directory: " + outputDir.toAbsolutePath().toFile().toString());
}
Path scenarioFile = Paths.get(ns.getString("scenario-file"));
if (!scenarioFile.toFile().exists() || !scenarioFile.toFile().isFile()){
logger.error("scenario-file does not exist, is not a regular file or you do not have read permissions: "
+ scenarioFile.toFile().toString());
System.exit(-1);
}
try {
Scenario scenario = ScenarioFactory.createScenarioWithScenarioFilePath(scenarioFile);
new ScenarioRun(scenario, outputDir.toFile().toString() , null).run();
} catch (Exception e){
logger.error(e);
System.exit(-1);
}
}
}
......@@ -67,6 +67,23 @@ public class VadereConsole {
.dest("scenario-file")
.help("Name of Scenario file");
// Run Scenario
Subparser scenarioRun = subparsers
.addParser("scenario-run")
.help("Run scenario without a project")
.setDefault("func", new ScenarioRunSubCommand());
scenarioRun.addArgument("--output-dir", "-o")
.required(false)
.setDefault("output")
.dest("output-dir") // set name in namespace
.type(String.class)
.help("Supply differernt output directory path to use.");
scenarioRun.addArgument("--scenario-file", "-f")
.required(true)
.type(String.class)
.dest("scenario-file")
.help("Scenario files to run");
// Run SUQ
Subparser suqRun = subparsers
......@@ -85,7 +102,7 @@ public class VadereConsole {
.required(true)
.type(String.class)
.dest("scenario-file")
.help("List of scenario files to run");
.help("Scenario files to run");
// Run Migration Assistant
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment