Package org.apache.sysds.api.mlcontext
Class Script
- java.lang.Object
-
- org.apache.sysds.api.mlcontext.Script
-
public class Script extends Object
A Script object encapsulates a DML or PYDML script.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAll()Clear the script string, inputs, outputs, and symbol table.voidclearInputs()Clear the inputs.voidclearIO()Clear the inputs and outputs, but not the symbol table.voidclearIOS()Clear the inputs, outputs, and symbol table.voidclearOutputs()Clear the outputs.voidclearSymbolTable()Clear the symbol table.StringdisplayInputParameters()Display the script input parameters.StringdisplayInputs()Display the script inputs.StringdisplayInputVariables()Display the script input variables.StringdisplayOutputs()Display the script outputs.StringdisplayOutputVariables()Display the script output variables.StringdisplaySymbolTable()Display the script symbol table.MLResultsexecute()Execute the script and return the results as an MLResults object.Map<String,Metadata>getInputMetadata()Obtain an unmodifiable map of input matrix/frame metadata.Map<String,Object>getInputParameters()Obtain an unmodifiable map of all input parameters ($).Map<String,Object>getInputs()Obtain an unmodifiable map of all inputs (parameters ($) and variables).Set<String>getInputVariables()Obtain the input variable names as an unmodifiable set of strings.StringgetName()Obtain the script name.Set<String>getOutputVariables()Obtain the output variable names as an unmodifiable set of strings.MLResultsgetResults()Obtain the results of the script execution.StringgetScriptExecutionString()Generate the script execution string, which adds read/load/write/save statements to the beginning and end of the script to execute.ScriptExecutorgetScriptExecutor()Obtain the script executor used by this Script.StringgetScriptString()Obtain the script string.LocalVariableMapgetSymbolTable()Obtain the symbol table, which is essentially aHashMap<String, Data>representing variables and their values.Scriptin(String name, Object value)Register an input (parameter ($) or variable).Scriptin(String name, Object value, Metadata metadata)Register an input (parameter ($) or variable) with optional matrix metadata.Scriptin(Map<String,Object> inputs)Pass a map of inputs to the script.Scriptin(scala.collection.Map<String,?> inputs)Pass a Scala Map of inputs to the script.Scriptin(scala.collection.Seq<Object> inputs)Pass a Scala Seq of inputs to the script.Stringinfo()Display information about the script as a String.Scriptout(String outputName)Register an output variable.Scriptout(String... outputNames)Register output variables.Scriptout(List<String> outputNames)Register output variables.Scriptout(scala.collection.Seq<String> outputNames)Register output variables.MLResultsresults()Obtain the results of the script execution.ScriptsetName(String name)Set the script name.voidsetResults(MLResults results)Set the results of the script execution.voidsetScriptExecutor(ScriptExecutor scriptExecutor)Set the ScriptExecutor used by this Script.ScriptsetScriptString(String scriptString)Set the script string.StringtoString()
-
-
-
Constructor Detail
-
Script
public Script()
Script constructor, which by default creates a DML script.
-
Script
public Script(String scriptString)
Script constructor, specifying the script content. By default, the script type is DML.- Parameters:
scriptString- the script content as a string
-
-
Method Detail
-
getScriptString
public String getScriptString()
Obtain the script string.- Returns:
- the script string
-
setScriptString
public Script setScriptString(String scriptString)
Set the script string.- Parameters:
scriptString- the script string- Returns:
thisScript object to allow chaining of methods
-
getInputVariables
public Set<String> getInputVariables()
Obtain the input variable names as an unmodifiable set of strings.- Returns:
- the input variable names
-
getOutputVariables
public Set<String> getOutputVariables()
Obtain the output variable names as an unmodifiable set of strings.- Returns:
- the output variable names
-
getSymbolTable
public LocalVariableMap getSymbolTable()
Obtain the symbol table, which is essentially aHashMap<String, Data>representing variables and their values.- Returns:
- the symbol table
-
getInputs
public Map<String,Object> getInputs()
Obtain an unmodifiable map of all inputs (parameters ($) and variables).- Returns:
- all inputs to the script
-
getInputMetadata
public Map<String,Metadata> getInputMetadata()
Obtain an unmodifiable map of input matrix/frame metadata.- Returns:
- input matrix/frame metadata
-
in
public Script in(Map<String,Object> inputs)
Pass a map of inputs to the script.- Parameters:
inputs- map of inputs (parameters ($) and variables).- Returns:
thisScript object to allow chaining of methods
-
in
public Script in(scala.collection.Map<String,?> inputs)
Pass a Scala Map of inputs to the script.Note that the
Mapvalue type is not explicitly specified on this method because[String, Any]can't be recognized on the Java side sinceAnydoesn't have an equivalent in the Java class hierarchy (scala.Anyis a superclass ofscala.AnyRef, which is equivalent tojava.lang.Object). Therefore, specifyingscala.collection.Map<String, Object>as an input parameter to this Java method is not encompassing enough and would require types such as ascala.Doubleto be cast usingasInstanceOf[AnyRef].- Parameters:
inputs- Scala Map of inputs (parameters ($) and variables).- Returns:
thisScript object to allow chaining of methods
-
in
public Script in(scala.collection.Seq<Object> inputs)
Pass a Scala Seq of inputs to the script. The inputs are either two-value or three-value tuples, where the first value is the variable name, the second value is the variable value, and the third optional value is the metadata.- Parameters:
inputs- Scala Seq of inputs (parameters ($) and variables).- Returns:
thisScript object to allow chaining of methods
-
getInputParameters
public Map<String,Object> getInputParameters()
Obtain an unmodifiable map of all input parameters ($).- Returns:
- input parameters ($)
-
in
public Script in(String name, Object value)
Register an input (parameter ($) or variable).- Parameters:
name- name of the inputvalue- value of the input- Returns:
thisScript object to allow chaining of methods
-
in
public Script in(String name, Object value, Metadata metadata)
Register an input (parameter ($) or variable) with optional matrix metadata.- Parameters:
name- name of the inputvalue- value of the inputmetadata- optional matrix/frame metadata- Returns:
thisScript object to allow chaining of methods
-
out
public Script out(String outputName)
Register an output variable.- Parameters:
outputName- name of the output variable- Returns:
thisScript object to allow chaining of methods
-
out
public Script out(String... outputNames)
Register output variables.- Parameters:
outputNames- names of the output variables- Returns:
thisScript object to allow chaining of methods
-
out
public Script out(scala.collection.Seq<String> outputNames)
Register output variables.- Parameters:
outputNames- names of the output variables- Returns:
thisScript object to allow chaining of methods
-
out
public Script out(List<String> outputNames)
Register output variables.- Parameters:
outputNames- names of the output variables- Returns:
thisScript object to allow chaining of methods
-
clearIOS
public void clearIOS()
Clear the inputs, outputs, and symbol table.
-
clearIO
public void clearIO()
Clear the inputs and outputs, but not the symbol table.
-
clearAll
public void clearAll()
Clear the script string, inputs, outputs, and symbol table.
-
clearInputs
public void clearInputs()
Clear the inputs.
-
clearOutputs
public void clearOutputs()
Clear the outputs.
-
clearSymbolTable
public void clearSymbolTable()
Clear the symbol table.
-
results
public MLResults results()
Obtain the results of the script execution.- Returns:
- the results of the script execution.
-
getResults
public MLResults getResults()
Obtain the results of the script execution.- Returns:
- the results of the script execution.
-
setResults
public void setResults(MLResults results)
Set the results of the script execution.- Parameters:
results- the results of the script execution.
-
getScriptExecutor
public ScriptExecutor getScriptExecutor()
Obtain the script executor used by this Script.- Returns:
- the ScriptExecutor used by this Script.
-
setScriptExecutor
public void setScriptExecutor(ScriptExecutor scriptExecutor)
Set the ScriptExecutor used by this Script.- Parameters:
scriptExecutor- the script executor
-
getScriptExecutionString
public String getScriptExecutionString()
Generate the script execution string, which adds read/load/write/save statements to the beginning and end of the script to execute.- Returns:
- the script execution string
-
info
public String info()
Display information about the script as a String. This consists of the script type, inputs, outputs, input parameters, input variables, output variables, the symbol table, the script string, and the script execution string.- Returns:
- information about this script as a String
-
displayInputs
public String displayInputs()
Display the script inputs.- Returns:
- the script inputs
-
displayOutputs
public String displayOutputs()
Display the script outputs.- Returns:
- the script outputs as a String
-
displayInputParameters
public String displayInputParameters()
Display the script input parameters.- Returns:
- the script input parameters as a String
-
displayInputVariables
public String displayInputVariables()
Display the script input variables.- Returns:
- the script input variables as a String
-
displayOutputVariables
public String displayOutputVariables()
Display the script output variables.- Returns:
- the script output variables as a String
-
displaySymbolTable
public String displaySymbolTable()
Display the script symbol table.- Returns:
- the script symbol table as a String
-
getName
public String getName()
Obtain the script name.- Returns:
- the script name
-
setName
public Script setName(String name)
Set the script name.- Parameters:
name- the script name- Returns:
thisScript object to allow chaining of methods
-
execute
public MLResults execute()
Execute the script and return the results as an MLResults object.- Returns:
- results as an MLResults object
-
-