use of org.apache.sysml.utils.Explain.ExplainType in project incubator-systemml by apache.
the class DMLScript method executeScript.
/**
* Single entry point for all public invocation alternatives (e.g.,
* main, executeScript, JaqlUdf etc)
*
* @param conf Hadoop configuration
* @param args arguments
* @return true if success, false otherwise
* @throws DMLException if DMLException occurs
* @throws ParseException if ParseException occurs
*/
public static boolean executeScript(Configuration conf, String[] args) throws DMLException {
//parse arguments and set execution properties
//keep old rtplatform
RUNTIME_PLATFORM oldrtplatform = rtplatform;
//keep old explain
ExplainType oldexplain = EXPLAIN;
Options options = createCLIOptions();
try {
DMLOptions dmlOptions = parseCLArguments(args, options);
// String[] scriptArgs = null; //optional script arguments
// boolean namedScriptArgs = false;
STATISTICS = dmlOptions.stats;
STATISTICS_COUNT = dmlOptions.statsCount;
USE_ACCELERATOR = dmlOptions.gpu;
FORCE_ACCELERATOR = dmlOptions.forceGPU;
EXPLAIN = dmlOptions.explainType;
ENABLE_DEBUG_MODE = dmlOptions.debug;
SCRIPT_TYPE = dmlOptions.scriptType;
rtplatform = dmlOptions.execMode;
String fnameOptConfig = dmlOptions.configFile;
boolean isFile = dmlOptions.filePath != null;
String fileOrScript = isFile ? dmlOptions.filePath : dmlOptions.script;
boolean help = dmlOptions.help;
if (help) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("systemml", options);
return true;
}
if (dmlOptions.clean) {
cleanSystemMLWorkspace();
return true;
}
//set log level
if (!ENABLE_DEBUG_MODE)
setLoggingProperties(conf);
//Step 2: prepare script invocation
if (isFile && StringUtils.endsWithIgnoreCase(fileOrScript, ".pydml")) {
SCRIPT_TYPE = ScriptType.PYDML;
}
String dmlScriptStr = readDMLScript(isFile, fileOrScript);
Map<String, String> argVals = dmlOptions.argVals;
DML_FILE_PATH_ANTLR_PARSER = dmlOptions.filePath;
//Step 3: invoke dml script
printInvocationInfo(fileOrScript, fnameOptConfig, argVals);
if (ENABLE_DEBUG_MODE) {
// inner try loop is just to isolate the debug exception, which will allow to manage the bugs from debugger v/s runtime
launchDebugger(dmlScriptStr, fnameOptConfig, argVals, SCRIPT_TYPE);
} else {
execute(dmlScriptStr, fnameOptConfig, argVals, args, SCRIPT_TYPE);
}
} catch (AlreadySelectedException e) {
System.err.println("Mutually exclusive options were selected. " + e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("systemml", options);
return false;
} catch (org.apache.commons.cli.ParseException e) {
System.err.println(e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("systemml", options);
} catch (ParseException pe) {
throw pe;
} catch (DMLScriptException e) {
//rethrow DMLScriptException to propagate stop call
throw e;
} catch (Exception ex) {
LOG.error("Failed to execute DML script.", ex);
throw new DMLException(ex);
} finally {
//reset runtime platform and visualize flag
rtplatform = oldrtplatform;
EXPLAIN = oldexplain;
}
return true;
}
use of org.apache.sysml.utils.Explain.ExplainType in project incubator-systemml by apache.
the class ScriptExecutor method setExplainLevel.
/**
* Set the level of program explanation that should be displayed if explain
* is set to true.
*
* @param explainLevel
* the level of program explanation
*/
public void setExplainLevel(ExplainLevel explainLevel) {
this.explainLevel = explainLevel;
if (explainLevel == null) {
DMLScript.EXPLAIN = ExplainType.NONE;
} else {
ExplainType explainType = explainLevel.getExplainType();
DMLScript.EXPLAIN = explainType;
}
}
use of org.apache.sysml.utils.Explain.ExplainType in project incubator-systemml by apache.
the class ScriptExecutor method showExplanation.
/**
* Output a description of the program to standard output.
*/
protected void showExplanation() {
if (!explain)
return;
try {
ExplainType explainType = (explainLevel != null) ? explainLevel.getExplainType() : ExplainType.RUNTIME;
System.out.println(Explain.explain(dmlProgram, runtimeProgram, explainType));
} catch (Exception e) {
throw new MLContextException("Exception occurred while explaining dml program", e);
}
}
Aggregations