Package org.apache.sysds.api.mlcontext
Class MLContext
java.lang.Object
org.apache.sysds.api.mlcontext.MLContext
- All Implemented Interfaces:
ConfigurableAPI
The MLContext API offers programmatic access to SystemDS on Spark from
languages such as Scala, Java, and Python.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe different types of execution environments supported by SystemDS.static enumThe different explain levels supported by SystemDS.classUsed internally by MLContextProxy. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMLContext(org.apache.spark.api.java.JavaSparkContext javaSparkContext) Create an MLContext based on a JavaSparkContext for interaction with SystemDS on Spark.MLContext(org.apache.spark.SparkContext sparkContext) Create an MLContext based on a SparkContext for interaction with SystemDS on Spark.MLContext(org.apache.spark.sql.SparkSession spark) Create an MLContext based on a SparkSession for interaction with SystemDS on Spark. -
Method Summary
Modifier and TypeMethodDescriptionObtain the SystemDS jar file build time.voidclose()Closes the mlcontext, which includes the cleanup of static and local state as well as scratch space and buffer pool cleanup.Execute a DML or PYDML Script.execute(Script script, ScriptExecutor scriptExecutor) Execute a DML or PYDML Script object using a ScriptExecutor.static MLContextRetrieve the currently active MLContext.Obtain the current execution environment.Used internally by MLContextProxy.org.apache.spark.sql.SparkSessionObtain the SparkSession associated with this MLContext.intObtain the maximum number of heavy hitters that are printed out as part of the statistics.info()Obtain information about the project such as version and build time from the manifest in the SystemDS jar file.booleanWhether or not an explanation of the DML/PYDML program should be output to standard output.booleanWhether or not the "force" GPU mode is enabled.booleanisGPU()Whether or not the GPU mode is enabled.booleanWhether or not the default ScriptExecutor should be initialized before execution.booleanObtain whether or not all values should be maintained in the symbol table after execution.booleanWhether or not statistics of the DML/PYDML program execution should be output to standard output.voidReset configuration settings to default settings.voidSet SystemDS configuration based on a configuration file.voidsetConfigProperty(String propertyName, String propertyValue) Set configuration property, such assetConfigProperty("sysds.localtmpdir", "/tmp/systemds").voidsetExecutionScript(Script executionScript) Sets the script that is being executedvoidsetExecutionType(MLContext.ExecutionType executionType) Set the execution environment.voidsetExplain(boolean explain) Whether or not an explanation of the DML/PYDML program should be output to standard output.voidsetExplainLevel(String explainLevel) Set the level of program explanation that should be displayed if explain is set to true.voidsetExplainLevel(MLContext.ExplainLevel explainLevel) Set the level of program explanation that should be displayed if explain is set to true.voidsetForceGPU(boolean enable) Whether or not to explicitly "force" the usage of GPU.voidsetGPU(boolean enable) Whether or not to use (an available) GPU on the driver node.voidsetInitBeforeExecution(boolean initBeforeExecution) Whether or not the default ScriptExecutor should be initialized before execution.voidsetLineage(boolean lineage) Set whether or not lineage should be tracedvoidSet type of lineage-based reuse caching and enable lineage tracingvoidsetMaintainSymbolTable(boolean maintainSymbolTable) Set whether or not all values should be maintained in the symbol table after execution.voidsetStatistics(boolean statistics) Whether or not statistics of the DML/PYDML program execution should be output to standard output.voidsetStatisticsMaxHeavyHitters(int maxHeavyHitters) Sets the maximum number of heavy hitters that are printed out as part of the statistics.version()Obtain the SystemDS version number.
-
Field Details
-
welcomePrint
public static boolean welcomePrintWelcome message
-
-
Constructor Details
-
MLContext
public MLContext(org.apache.spark.sql.SparkSession spark) Create an MLContext based on a SparkSession for interaction with SystemDS on Spark.- Parameters:
spark- SparkSession
-
MLContext
public MLContext(org.apache.spark.SparkContext sparkContext) Create an MLContext based on a SparkContext for interaction with SystemDS on Spark.- Parameters:
sparkContext- SparkContext
-
MLContext
public MLContext(org.apache.spark.api.java.JavaSparkContext javaSparkContext) Create an MLContext based on a JavaSparkContext for interaction with SystemDS on Spark.- Parameters:
javaSparkContext- JavaSparkContext
-
-
Method Details
-
getActiveMLContext
Retrieve the currently active MLContext. This is used internally by SystemDS via MLContextProxy.- Returns:
- the active MLContext
-
resetConfig
public void resetConfig()Description copied from interface:ConfigurableAPIReset configuration settings to default settings.- Specified by:
resetConfigin interfaceConfigurableAPI
-
setConfigProperty
Description copied from interface:ConfigurableAPISet configuration property, such assetConfigProperty("sysds.localtmpdir", "/tmp/systemds").- Specified by:
setConfigPropertyin interfaceConfigurableAPI- Parameters:
propertyName- property namepropertyValue- property value
-
execute
Execute a DML or PYDML Script.- Parameters:
script- The DML or PYDML Script object to execute.- Returns:
- the results as a MLResults object
-
execute
Execute a DML or PYDML Script object using a ScriptExecutor. The ScriptExecutor class can be extended to allow the modification of the default execution pathway.- Parameters:
script- the DML or PYDML Script objectscriptExecutor- the ScriptExecutor that defines the script execution pathway- Returns:
- the results as a MLResults object
-
setExecutionScript
Sets the script that is being executed- Parameters:
executionScript- script that is being executed
-
setConfig
Set SystemDS configuration based on a configuration file.- Parameters:
configFilePath- path to the configuration file
-
getSparkSession
public org.apache.spark.sql.SparkSession getSparkSession()Obtain the SparkSession associated with this MLContext.- Returns:
- the SparkSession associated with this MLContext.
-
isExplain
public boolean isExplain()Whether or not an explanation of the DML/PYDML program should be output to standard output.- Returns:
trueif explanation should be output,falseotherwise
-
setExplain
public void setExplain(boolean explain) Whether or not an explanation of the DML/PYDML program should be output to standard output.- Parameters:
explain-trueif explanation should be output,falseotherwise
-
setLineage
public void setLineage(boolean lineage) Set whether or not lineage should be traced- Parameters:
lineage-trueif lineage should be traced,falseotherwise
-
setLineage
Set type of lineage-based reuse caching and enable lineage tracing- Parameters:
reuse- reuse cache type to use
-
isMaintainSymbolTable
public boolean isMaintainSymbolTable()Obtain whether or not all values should be maintained in the symbol table after execution.- Returns:
trueif all values should be maintained in the symbol table,falseotherwise
-
setMaintainSymbolTable
public void setMaintainSymbolTable(boolean maintainSymbolTable) Set whether or not all values should be maintained in the symbol table after execution.- Parameters:
maintainSymbolTable-trueif all values should be maintained in the symbol table,falseotherwise
-
setExplainLevel
Set the level of program explanation that should be displayed if explain is set to true.- Parameters:
explainLevel- the level of program explanation
-
setExplainLevel
Set the level of program explanation that should be displayed if explain is set to true.- Parameters:
explainLevel- string denoting program explanation
-
setGPU
public void setGPU(boolean enable) Whether or not to use (an available) GPU on the driver node. If a GPU is not available, and the GPU mode is set, SystemDS will crash when the program is run.- Parameters:
enable- true if needs to be enabled, false otherwise
-
setForceGPU
public void setForceGPU(boolean enable) Whether or not to explicitly "force" the usage of GPU. If a GPU is not available, and the GPU mode is set or if available memory on GPU is less, SystemDS will crash when the program is run.- Parameters:
enable- true if needs to be enabled, false otherwise
-
isGPU
public boolean isGPU()Whether or not the GPU mode is enabled.- Returns:
- true if enabled, false otherwise
-
isForceGPU
public boolean isForceGPU()Whether or not the "force" GPU mode is enabled.- Returns:
- true if enabled, false otherwise
-
getInternalProxy
Used internally by MLContextProxy.- Returns:
- InternalProxy object used by MLContextProxy
-
isStatistics
public boolean isStatistics()Whether or not statistics of the DML/PYDML program execution should be output to standard output.- Returns:
trueif statistics should be output,falseotherwise
-
setStatistics
public void setStatistics(boolean statistics) Whether or not statistics of the DML/PYDML program execution should be output to standard output.- Parameters:
statistics-trueif statistics should be output,falseotherwise
-
setStatisticsMaxHeavyHitters
public void setStatisticsMaxHeavyHitters(int maxHeavyHitters) Sets the maximum number of heavy hitters that are printed out as part of the statistics.- Parameters:
maxHeavyHitters- maximum number of heavy hitters to print
-
close
public void close()Closes the mlcontext, which includes the cleanup of static and local state as well as scratch space and buffer pool cleanup. Note that the spark context is not explicitly closed to allow external reuse. -
info
Obtain information about the project such as version and build time from the manifest in the SystemDS jar file.- Returns:
- information about the project
-
version
Obtain the SystemDS version number.- Returns:
- the SystemDS version number
-
buildTime
Obtain the SystemDS jar file build time.- Returns:
- the SystemDS jar file build time
-
getStatisticsMaxHeavyHitters
public int getStatisticsMaxHeavyHitters()Obtain the maximum number of heavy hitters that are printed out as part of the statistics.- Returns:
- maximum number of heavy hitters to print
-
isInitBeforeExecution
public boolean isInitBeforeExecution()Whether or not the default ScriptExecutor should be initialized before execution.- Returns:
trueif ScriptExecutor should be initialized before execution,falseotherwise
-
setInitBeforeExecution
public void setInitBeforeExecution(boolean initBeforeExecution) Whether or not the default ScriptExecutor should be initialized before execution.- Parameters:
initBeforeExecution-trueif ScriptExecutor should be initialized before execution,falseotherwise
-
getExecutionType
Obtain the current execution environment.- Returns:
- the execution environment
-
setExecutionType
Set the execution environment.- Parameters:
executionType- the execution environment
-