Package org.apache.sysds.api.mlcontext
Class Script
java.lang.Object
org.apache.sysds.api.mlcontext.Script
A Script object encapsulates a DML or PYDML script.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAll()Clear the script string, inputs, outputs, and symbol table.voidClear the inputs.voidclearIO()Clear the inputs and outputs, but not the symbol table.voidclearIOS()Clear the inputs, outputs, and symbol table.voidClear the outputs.voidClear the symbol table.Display the script input parameters.Display the script inputs.Display the script input variables.Display the script outputs.Display the script output variables.Display the script symbol table.execute()Execute the script and return the results as an MLResults object.Obtain an unmodifiable map of input matrix/frame metadata.Obtain an unmodifiable map of all input parameters ($).Obtain an unmodifiable map of all inputs (parameters ($) and variables).Obtain the input variable names as an unmodifiable set of strings.getName()Obtain the script name.Obtain the output variable names as an unmodifiable set of strings.Obtain the results of the script execution.Generate the script execution string, which adds read/load/write/save statements to the beginning and end of the script to execute.Obtain the script executor used by this Script.Obtain the script string.Obtain the symbol table, which is essentially aHashMap<String, Data>representing variables and their values.Register an input (parameter ($) or variable).Register an input (parameter ($) or variable) with optional matrix metadata.Pass a map of inputs to the script.Pass a Scala Map of inputs to the script.Pass a Scala Seq of inputs to the script.info()Display information about the script as a String.Register an output variable.Register output variables.Register output variables.Register output variables.results()Obtain the results of the script execution.Set the script name.voidsetResults(MLResults results) Set the results of the script execution.voidsetScriptExecutor(ScriptExecutor scriptExecutor) Set the ScriptExecutor used by this Script.setScriptString(String scriptString) Set the script string.toString()
-
Constructor Details
-
Script
public Script()Script constructor, which by default creates a DML script. -
Script
Script constructor, specifying the script content. By default, the script type is DML.- Parameters:
scriptString- the script content as a string
-
-
Method Details
-
getScriptString
Obtain the script string.- Returns:
- the script string
-
setScriptString
Set the script string.- Parameters:
scriptString- the script string- Returns:
thisScript object to allow chaining of methods
-
getInputVariables
Obtain the input variable names as an unmodifiable set of strings.- Returns:
- the input variable names
-
getOutputVariables
Obtain the output variable names as an unmodifiable set of strings.- Returns:
- the output variable names
-
getSymbolTable
Obtain the symbol table, which is essentially aHashMap<String, Data>representing variables and their values.- Returns:
- the symbol table
-
getInputs
Obtain an unmodifiable map of all inputs (parameters ($) and variables).- Returns:
- all inputs to the script
-
getInputMetadata
Obtain an unmodifiable map of input matrix/frame metadata.- Returns:
- input matrix/frame metadata
-
in
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
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
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
Obtain an unmodifiable map of all input parameters ($).- Returns:
- input parameters ($)
-
in
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
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
Register an output variable.- Parameters:
outputName- name of the output variable- Returns:
thisScript object to allow chaining of methods
-
out
Register output variables.- Parameters:
outputNames- names of the output variables- Returns:
thisScript object to allow chaining of methods
-
out
Register output variables.- Parameters:
outputNames- names of the output variables- Returns:
thisScript object to allow chaining of methods
-
out
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
Obtain the results of the script execution.- Returns:
- the results of the script execution.
-
getResults
Obtain the results of the script execution.- Returns:
- the results of the script execution.
-
setResults
Set the results of the script execution.- Parameters:
results- the results of the script execution.
-
getScriptExecutor
Obtain the script executor used by this Script.- Returns:
- the ScriptExecutor used by this Script.
-
setScriptExecutor
Set the ScriptExecutor used by this Script.- Parameters:
scriptExecutor- the script executor
-
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
-
toString
-
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
Display the script inputs.- Returns:
- the script inputs
-
displayOutputs
Display the script outputs.- Returns:
- the script outputs as a String
-
displayInputParameters
Display the script input parameters.- Returns:
- the script input parameters as a String
-
displayInputVariables
Display the script input variables.- Returns:
- the script input variables as a String
-
displayOutputVariables
Display the script output variables.- Returns:
- the script output variables as a String
-
displaySymbolTable
Display the script symbol table.- Returns:
- the script symbol table as a String
-
getName
Obtain the script name.- Returns:
- the script name
-
setName
Set the script name.- Parameters:
name- the script name- Returns:
thisScript object to allow chaining of methods
-
execute
Execute the script and return the results as an MLResults object.- Returns:
- results as an MLResults object
-