Package weka.knowledgeflow.steps
Class BaseStep
- java.lang.Object
-
- weka.knowledgeflow.steps.BaseStep
-
- All Implemented Interfaces:
java.io.Serializable,BaseStepExtender,Step
- Direct Known Subclasses:
AlterRelationName,Appender,BaseSimpleDataVisualizer,Block,BoundaryPlotter,ClassAssigner,ClassifierPerformanceEvaluator,ClassValuePicker,ClustererPerformanceEvaluator,CrossValidationFoldMaker,DataGrid,DataVisualizer,Dummy,ExecuteProcess,FlowByExpression,GetDataFromResult,ImageSaver,ImageViewer,IncrementalClassifierEvaluator,InstanceStreamToBatchMaker,Job,Join,MakeResourceIntensive,MemoryBasedDataSource,ModelPerformanceChart,Note,PredictionAppender,SendToPerspective,SerializedModelSaver,SetPropertiesFromEnvironment,SetVariables,Sorter,StorePropertiesInEnvironment,StripChart,SubstringLabeler,SubstringReplacer,TestSetMaker,TextSaver,TextViewer,TrainingSetMaker,TrainTestSplitMaker,WekaAlgorithmWrapper,WriteDataToResult,WriteWekaLog
public abstract class BaseStep extends java.lang.Object implements Step, BaseStepExtender, java.io.Serializable
Base class for implementations of Step to use. Provides handy functions that automatically setup the step's name and "about" info, provide access to the step's StepManager and for resolving environment variables.- Version:
- $Revision: $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BaseStep()Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringenvironmentSubstitute(java.lang.String source)Substitute the values of environment variables in the given stringjava.lang.StringgetCustomEditorForStep()Return the fully qualified name of a custom editor component (JComponent) to use for editing the properties of the step.DefaultsgetDefaultSettings()Get default settings for the step (if any).java.util.Map<java.lang.String,java.lang.String>getInteractiveViewers()When running in a graphical execution environment a step can make one or more popup Viewer components available.java.util.Map<java.lang.String,StepInteractiveViewer>getInteractiveViewersImpls()An alternative to getStepInteractiveViewers that returns a Map of instantiated StepInteractiveViewer objects.java.lang.StringgetName()Get the name of this stepStepManagergetStepManager()Get the step manager for this stepjava.lang.StringglobalInfo()Attempt to get default "about" information for this step by grabbing the toolTip from the KFStep annotation.booleanisResourceIntensive()Get whether this step is resource intensive (cpu/memory) or not.booleanisStopRequested()Convenience method that callsStepManager.isStopRequested()InstancesoutputStructureForConnectionType(java.lang.String connectionName)If possible, get the output structure for the named connection type as a header-only set of instances.InstancesoutputStructureForConnectionType(java.lang.String connectionName, Environment env)If possible, get the output structure for the named connection type as a header-only set of instances.voidprocessIncoming(Data data)Process an incoming data payload (if the step accepts incoming connections)voidsetName(java.lang.String name)Set the name of this stepvoidsetStepIsResourceIntensive(boolean isResourceIntensive)Set whether this step is resource intensive (cpu/memory) or not.voidsetStepManager(StepManager manager)Set the step manager for this stepvoidsetStepMustRunSingleThreaded(boolean mustRunSingleThreaded)Set whether this step must run single threaded.voidstart()Start processing.booleanstepMustRunSingleThreaded()Get whether this step must run single threaded.voidstop()Request that processing be stopped.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface weka.knowledgeflow.steps.BaseStepExtender
getIncomingConnectionTypes, getOutgoingConnectionTypes, stepInit
-
Methods inherited from interface weka.knowledgeflow.steps.Step
getIncomingConnectionTypes, getOutgoingConnectionTypes, stepInit
-
-
-
-
Method Detail
-
globalInfo
public java.lang.String globalInfo()
Attempt to get default "about" information for this step by grabbing the toolTip from the KFStep annotation.- Returns:
- a default "about" info string if this step uses the KFStep annotation and null otherwise. Subclasses should override to provide more comprehensive about info
-
getStepManager
@NotPersistable public StepManager getStepManager()
Get the step manager for this step- Specified by:
getStepManagerin interfaceStep- Returns:
- the step manager for this step
-
setStepManager
public void setStepManager(StepManager manager)
Set the step manager for this step- Specified by:
setStepManagerin interfaceStep- Parameters:
manager- the step manager to use
-
setStepIsResourceIntensive
@ProgrammaticProperty public void setStepIsResourceIntensive(boolean isResourceIntensive)
Set whether this step is resource intensive (cpu/memory) or not. This affects which executor service is used to execute the step's processing.- Parameters:
isResourceIntensive- true if this step is resource intensive.
-
isResourceIntensive
public boolean isResourceIntensive()
Get whether this step is resource intensive (cpu/memory) or not.- Returns:
- true if this step is resource intensive
-
setStepMustRunSingleThreaded
@ProgrammaticProperty public void setStepMustRunSingleThreaded(boolean mustRunSingleThreaded)
Set whether this step must run single threaded. I.e. on an executor service which has only one worker thread, thus effectively preventing more than one copy of the step executing at any one time.- Parameters:
mustRunSingleThreaded- true if the step must run single threaded
-
stepMustRunSingleThreaded
public boolean stepMustRunSingleThreaded()
Get whether this step must run single threaded. I.e. on an executor service which has only one worker thread, thus effectively preventing more than one copy of the step executing at any one time.- Returns:
- true if the step must run single threaded
-
getName
public java.lang.String getName()
Get the name of this step
-
setName
@ProgrammaticProperty public void setName(java.lang.String name)
Set the name of this step
-
start
public void start() throws WekaExceptionStart processing. Subclasses should override this method if they can act as a start point in a flow.- Specified by:
startin interfaceBaseStepExtender- Specified by:
startin interfaceStep- Throws:
WekaException- if a problem occurs
-
stop
public void stop()
Request that processing be stopped. Subclasses should callisStopRequested()periodically to see if they should stop processing.
-
outputStructureForConnectionType
public Instances outputStructureForConnectionType(java.lang.String connectionName) throws WekaException
If possible, get the output structure for the named connection type as a header-only set of instances. Can return null if the specified connection type is not representable as Instances or cannot be determined at present.- Specified by:
outputStructureForConnectionTypein interfaceStep- Parameters:
connectionName- the name of the connection type to get the output structure for- Returns:
- the output structure as a header-only Instances object
- Throws:
WekaException- if a problem occurs
-
outputStructureForConnectionType
public Instances outputStructureForConnectionType(java.lang.String connectionName, Environment env) throws WekaException
If possible, get the output structure for the named connection type as a header-only set of instances. Can return null if the specified connection type is not representable as Instances or cannot be determined at present.- Specified by:
outputStructureForConnectionTypein interfaceStep- Parameters:
connectionName- the name of the connection type to get the output structure forenv- Environment variables- Returns:
- the output structure as a header-only Instances object
- Throws:
WekaException- if a problem occurs
-
processIncoming
public void processIncoming(Data data) throws WekaException
Process an incoming data payload (if the step accepts incoming connections)- Specified by:
processIncomingin interfaceBaseStepExtender- Specified by:
processIncomingin interfaceStep- Parameters:
data- the payload to process- Throws:
WekaException- if a problem occurs
-
getCustomEditorForStep
public java.lang.String getCustomEditorForStep()
Return the fully qualified name of a custom editor component (JComponent) to use for editing the properties of the step. This method can return null, in which case the system will dynamically generate an editor using the GenericObjectEditor- Specified by:
getCustomEditorForStepin interfaceStep- Returns:
- the fully qualified name of a step editor component
-
getInteractiveViewers
public java.util.Map<java.lang.String,java.lang.String> getInteractiveViewers()
When running in a graphical execution environment a step can make one or more popup Viewer components available. These might be used to display results, graphics etc. Returning null indicates that the step has no such additional graphical views. The map returned by this method should be keyed by action name (e.g. "View results"), and values should be fully qualified names of the corresponding StepInteractiveView implementation. Furthermore, the contents of this map can (and should) be dependent on whether a particular viewer should be made available - i.e. if execution hasn't occurred yet, or if a particular incoming connection type is not present, then it might not be possible to view certain results. Viewers can implement StepInteractiveView directly (in which case they need to extends JPanel), or extends the AbstractInteractiveViewer class. The later extends JPanel, uses a BorderLayout, provides a "Close" button and a method to add additional buttons.- Specified by:
getInteractiveViewersin interfaceStep- Returns:
- a map of viewer component names, or null if this step has no graphical views
-
getInteractiveViewersImpls
public java.util.Map<java.lang.String,StepInteractiveViewer> getInteractiveViewersImpls()
An alternative to getStepInteractiveViewers that returns a Map of instantiated StepInteractiveViewer objects. Generally, getInteractiveViewers() is the preferred mechanism to specify any interactive viewers, as it does not require Steps to import and instantiate GUI classes. However, in some cases it might be unavoidable (e.g. Groovy script compilation involves custom classloaders), in these cases this method can be used instead.- Specified by:
getInteractiveViewersImplsin interfaceStep- Returns:
- a map of instantiated instances of StepInteractiveViewers
-
getDefaultSettings
public Defaults getDefaultSettings()
Get default settings for the step (if any). Returning null indicates that the step has no user-editable defaults.- Specified by:
getDefaultSettingsin interfaceStep- Returns:
- the default settings
-
isStopRequested
public boolean isStopRequested()
Convenience method that callsStepManager.isStopRequested()- Returns:
- true if the execution environment has requested processing to stop
-
environmentSubstitute
public java.lang.String environmentSubstitute(java.lang.String source)
Substitute the values of environment variables in the given string- Parameters:
source- the source string to substitute in- Returns:
- the source string with all known environment variables resolved
-
-