Package weka.knowledgeflow.steps
Class BaseStep
java.lang.Object
weka.knowledgeflow.steps.BaseStep
- All Implemented Interfaces:
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
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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionenvironmentSubstitute(String source) Substitute the values of environment variables in the given stringReturn the fully qualified name of a custom editor component (JComponent) to use for editing the properties of the step.Get default settings for the step (if any).When running in a graphical execution environment a step can make one or more popup Viewer components available.An alternative to getStepInteractiveViewers that returns a Map of instantiated StepInteractiveViewer objects.getName()Get the name of this stepGet the step manager for this stepAttempt to get default "about" information for this step by grabbing the toolTip from the KFStep annotation.booleanGet whether this step is resource intensive (cpu/memory) or not.booleanConvenience method that callsStepManager.isStopRequested()outputStructureForConnectionType(String connectionName) If possible, get the output structure for the named connection type as a header-only set of instances.outputStructureForConnectionType(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)voidSet 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.booleanGet 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, waitMethods inherited from interface weka.knowledgeflow.steps.BaseStepExtender
getIncomingConnectionTypes, getOutgoingConnectionTypes, stepInitMethods inherited from interface weka.knowledgeflow.steps.Step
getIncomingConnectionTypes, getOutgoingConnectionTypes, stepInit
-
Constructor Details
-
BaseStep
public BaseStep()Constructor
-
-
Method Details
-
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
Get the step manager for this step- Specified by:
getStepManagerin interfaceStep- Returns:
- the step manager for this step
-
setStepManager
Set the step manager for this step- Specified by:
setStepManagerin interfaceStep- Parameters:
manager- the step manager to use
-
setStepIsResourceIntensive
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
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
Get the name of this step -
setName
Set the name of this step -
start
Start 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
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(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
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
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
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
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
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
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
-