Search in sources :

Example 1 with ScriptExecutor

use of org.apache.sysml.api.mlcontext.ScriptExecutor in project incubator-systemml by apache.

the class MLContextTest method testCustomExecutionStepPYDML.

@Test
public void testCustomExecutionStepPYDML() {
    System.out.println("MLContextTest - custom execution step PYDML");
    String testString = "custom execution step";
    setExpectedStdOut(testString);
    Script script = new Script("print('" + testString + "')", org.apache.sysml.api.mlcontext.ScriptType.PYDML);
    ScriptExecutor scriptExecutor = new ScriptExecutor() {

        @Override
        protected void showExplanation() {
        }
    };
    ml.execute(script, scriptExecutor);
}
Also used : Script(org.apache.sysml.api.mlcontext.Script) ScriptExecutor(org.apache.sysml.api.mlcontext.ScriptExecutor) Test(org.junit.Test)

Example 2 with ScriptExecutor

use of org.apache.sysml.api.mlcontext.ScriptExecutor in project systemml by apache.

the class GenerateClassesForMLContext method dmlProgramFromScriptFilePath.

/**
 * Create a DMLProgram from a script file.
 *
 * @param scriptFilePath
 *            the path to a script file
 * @return the DMLProgram generated by the script file
 */
public static DMLProgram dmlProgramFromScriptFilePath(String scriptFilePath) {
    String scriptString = fileToString(scriptFilePath);
    Script script = new Script(scriptString);
    ScriptExecutor se = new ScriptExecutor() {

        @Override
        public MLResults execute(Script script) {
            setup(script);
            parseScript();
            return null;
        }
    };
    se.execute(script);
    DMLProgram dmlProgram = se.getDmlProgram();
    return dmlProgram;
}
Also used : Script(org.apache.sysml.api.mlcontext.Script) DMLScript(org.apache.sysml.api.DMLScript) DMLProgram(org.apache.sysml.parser.DMLProgram) ScriptExecutor(org.apache.sysml.api.mlcontext.ScriptExecutor)

Example 3 with ScriptExecutor

use of org.apache.sysml.api.mlcontext.ScriptExecutor in project systemml by apache.

the class MLContextTest method testCustomExecutionStepPYDML.

@Test
public void testCustomExecutionStepPYDML() {
    System.out.println("MLContextTest - custom execution step PYDML");
    String testString = "custom execution step";
    setExpectedStdOut(testString);
    Script script = new Script("print('" + testString + "')", org.apache.sysml.api.mlcontext.ScriptType.PYDML);
    ScriptExecutor scriptExecutor = new ScriptExecutor() {

        @Override
        protected void showExplanation() {
        }
    };
    ml.execute(script, scriptExecutor);
}
Also used : Script(org.apache.sysml.api.mlcontext.Script) ScriptExecutor(org.apache.sysml.api.mlcontext.ScriptExecutor) Test(org.junit.Test)

Example 4 with ScriptExecutor

use of org.apache.sysml.api.mlcontext.ScriptExecutor in project incubator-systemml by apache.

the class MLContextTest method testCustomExecutionStepDML.

@Test
public void testCustomExecutionStepDML() {
    System.out.println("MLContextTest - custom execution step DML");
    String testString = "custom execution step";
    setExpectedStdOut(testString);
    Script script = new Script("print('" + testString + "');", org.apache.sysml.api.mlcontext.ScriptType.DML);
    ScriptExecutor scriptExecutor = new ScriptExecutor() {

        @Override
        protected void showExplanation() {
        }
    };
    ml.execute(script, scriptExecutor);
}
Also used : Script(org.apache.sysml.api.mlcontext.Script) ScriptExecutor(org.apache.sysml.api.mlcontext.ScriptExecutor) Test(org.junit.Test)

Example 5 with ScriptExecutor

use of org.apache.sysml.api.mlcontext.ScriptExecutor in project incubator-systemml by apache.

the class GenerateClassesForMLContext method dmlProgramFromScriptFilePath.

/**
 * Create a DMLProgram from a script file.
 *
 * @param scriptFilePath
 *            the path to a script file
 * @return the DMLProgram generated by the script file
 */
public static DMLProgram dmlProgramFromScriptFilePath(String scriptFilePath) {
    String scriptString = fileToString(scriptFilePath);
    Script script = new Script(scriptString);
    ScriptExecutor se = new ScriptExecutor() {

        @Override
        public MLResults execute(Script script) {
            setup(script);
            parseScript();
            return null;
        }
    };
    se.execute(script);
    DMLProgram dmlProgram = se.getDmlProgram();
    return dmlProgram;
}
Also used : Script(org.apache.sysml.api.mlcontext.Script) DMLScript(org.apache.sysml.api.DMLScript) DMLProgram(org.apache.sysml.parser.DMLProgram) ScriptExecutor(org.apache.sysml.api.mlcontext.ScriptExecutor)

Aggregations

Script (org.apache.sysml.api.mlcontext.Script)6 ScriptExecutor (org.apache.sysml.api.mlcontext.ScriptExecutor)6 Test (org.junit.Test)4 DMLScript (org.apache.sysml.api.DMLScript)2 DMLProgram (org.apache.sysml.parser.DMLProgram)2