Class AlgorithmProfileHelper
java.lang.Object
eu.qualimaster.easy.extension.internal.AlgorithmProfileHelper
Support for creating on-demand pipelines for algorithm profiling.
- Author:
- Holger Eichelberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInformation describing a new profile pipeline. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringstatic final Stringstatic final Stringprivate static final String[]static final Stringstatic final Stringstatic final Stringprivate static final Stringprivate static final String[]private static final String[]static final Stringprivate static final String[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddImports(net.ssehub.easy.varModel.model.Project source, String[] imports, net.ssehub.easy.varModel.model.Project target, net.ssehub.easy.varModel.model.Project... furtherImports) Adds the given imports totarget.private static List<net.ssehub.easy.varModel.model.IFreezable> addTopLevelValues(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project source, net.ssehub.easy.varModel.model.Project target, String... exclude) Adds top level values configured forsourcetotarget.private static Object[]createDataSourceParameters(net.ssehub.easy.varModel.model.Project cfgProject) Creates the default adaptable parameters for a data source.private static net.ssehub.easy.varModel.model.DecisionVariableDeclarationcreateDecisionVariable(String name, net.ssehub.easy.varModel.model.datatypes.IDatatype type, net.ssehub.easy.varModel.model.Project target, Object... values) Creates a decision variable declaration.static net.ssehub.easy.varModel.model.FreezeBlockcreateFreezeBlock(List<net.ssehub.easy.varModel.model.IFreezable> freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType) Creates a freeze block forprojectand adds it toproject.private static net.ssehub.easy.varModel.model.FreezeBlockcreateFreezeBlock(net.ssehub.easy.varModel.model.IFreezable[] freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType) Creates a freeze block forprojectand adds it toproject.private static net.ssehub.easy.varModel.model.ProjectcreateInfrastructureCfg(net.ssehub.easy.varModel.confModel.Configuration config, net.ssehub.easy.varModel.model.Project pipelines, net.ssehub.easy.varModel.model.Project cfgInfra, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar) Creates the InfrastructureCfg IVML project.private static net.ssehub.easy.varModel.model.ProjectcreateNewRoot(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName) Creates a new QM model root leaving the real one as it is.private static net.ssehub.easy.varModel.model.ProjectcreatePipelinesCfg(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project pip, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar) Creates the PipelinesCfg IVML project.createProfilePipeline(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName, net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor source) Profiles the given algorithm.private static net.ssehub.easy.varModel.model.ProjectcreateQm(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project infra) Creates the top-level QM project.private static net.ssehub.easy.varModel.model.ProjectcreateQmProject(String name, net.ssehub.easy.varModel.model.Project typeFallback) Creates a project with basic settings for QM.private static net.ssehub.easy.varModel.cst.ConstraintSyntaxTreecreateRefToTuple(net.ssehub.easy.varModel.model.DecisionVariableDeclaration var, String slotName, int index) Creates an expression accessing theindexelement ofslotNameinvar.private static voidextractDataArtifact(File file, File base) Extracts the data artifact tobase.static voidextractProfilingArtifact(String artifactSpec, String name, File base) Extracts the profiling artifact.static FilegetControlFile(File base) Just returns a file instance pointing to the control file.static FilegetDataFile(File base) Just returns a file instance pointing to the data file.private static net.ssehub.easy.varModel.model.values.ValueReturns (a copy) of the value of theslotinvar.private static net.ssehub.easy.varModel.model.DecisionVariableDeclarationsetPipelines(net.ssehub.easy.varModel.model.Project prj, String varName, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipeline) Sets the givenpipelineas value in thevarNameofprj.
-
Field Details
-
PARAM_HDFS_DATAFILE
- See Also:
-
PARAM_DATAFILE
- See Also:
-
PARAM_REPLAYSPEED
- See Also:
-
SRC_NAME
- See Also:
-
FAM_NAME
- See Also:
-
DATASRC_NAME
- See Also:
-
PIPELINE_IMPORTS
-
PIPELINES_IMPORTS
-
INFRASTRUCTURE_IMPORTS
-
TOP_IMPORTS
-
PIP_VERSION
- See Also:
-
DATA_FILE
- See Also:
-
CTL_FILE
- See Also:
-
-
Constructor Details
-
AlgorithmProfileHelper
public AlgorithmProfileHelper()
-
-
Method Details
-
createProfilePipeline
public static AlgorithmProfileHelper.ProfileData createProfilePipeline(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName, net.ssehub.easy.instantiation.core.model.vilTypes.IProjectDescriptor source) throws net.ssehub.easy.instantiation.core.model.common.VilException Profiles the given algorithm. Create a specific pipeline with data source, specific family holding only the test algorithm. Stores data and control file intosource.- Parameters:
config- the configuration to be used as basis for creating a profiling pipelinepipelineName- the name of the pipeline to be created (must be a valid Java identifier)familyName- the name of the family to testalgorithmName- the name of the algorithm withinfamilyto testsource- the source project descriptor, also to be used as target folder for instantiation (the folder may be empty)- Returns:
- pipeline information
- Throws:
net.ssehub.easy.instantiation.core.model.common.VilException- in case of model query problems, model management problems, CST errors, unmatching IVML values or VIL execution errors
-
getDataFile
Just returns a file instance pointing to the data file.- Parameters:
base- the base folder- Returns:
- the file instance (regardless whether it exists)
-
getControlFile
Just returns a file instance pointing to the control file.- Parameters:
base- the base folder- Returns:
- the file instance (regardless whether it exists)
-
extractProfilingArtifact
public static void extractProfilingArtifact(String artifactSpec, String name, File base) throws net.ssehub.easy.instantiation.core.model.common.VilException Extracts the profiling artifact.- Parameters:
artifactSpec- the artifact specificationname- the logical name of the artifactbase- the base folder where to extract to- Throws:
net.ssehub.easy.instantiation.core.model.common.VilException- in case that obtaining the artifact fails
-
extractDataArtifact
Extracts the data artifact tobase.- Parameters:
file- the file to extractbase- the base folder to extract to
-
createNewRoot
private static net.ssehub.easy.varModel.model.Project createNewRoot(net.ssehub.easy.varModel.confModel.Configuration config, String pipelineName, String familyName, String algorithmName) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException Creates a new QM model root leaving the real one as it is.- Parameters:
config- the configuration to be used as basis for creationpipelineName- the pipeline name (here a valid Java identifier)familyName- the name of the family to testalgorithmName- the name of the algorithm withinfamilyto test- Returns:
- the new model root project
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- in case of model query problemsnet.ssehub.easy.basics.modelManagement.ModelManagementException- in case of model management problemsnet.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case of unmatching values
-
createPipelinesCfg
private static net.ssehub.easy.varModel.model.Project createPipelinesCfg(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project pip, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException Creates the PipelinesCfg IVML project.- Parameters:
cfgProject- the top-level configuration projectpip- the pipeline projectpipVar- the pipeline decision variable- Returns:
- the IVML project
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- in case of model query problemsnet.ssehub.easy.basics.modelManagement.ModelManagementException- in case of model management problemsnet.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case of unmatching values
-
createInfrastructureCfg
private static net.ssehub.easy.varModel.model.Project createInfrastructureCfg(net.ssehub.easy.varModel.confModel.Configuration config, net.ssehub.easy.varModel.model.Project pipelines, net.ssehub.easy.varModel.model.Project cfgInfra, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipVar) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException Creates the InfrastructureCfg IVML project.- Parameters:
config- the top-level configurationpipelines- the pipelines project (seecreatePipelinesCfg(Project, Project, DecisionVariableDeclaration)cfgInfra- the orignal infrastructure configuration projectpipVar- the pipeline decision variable- Returns:
- the IVML project
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- in case of model query problemsnet.ssehub.easy.basics.modelManagement.ModelManagementException- in case of model management problemsnet.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case of unmatching values
-
createQm
private static net.ssehub.easy.varModel.model.Project createQm(net.ssehub.easy.varModel.model.Project cfgProject, net.ssehub.easy.varModel.model.Project infra) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.basics.modelManagement.ModelManagementException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.cst.CSTSemanticException Creates the top-level QM project.- Parameters:
cfgProject- the top-level configuration projectinfra- the infrastructure cfg project (seecreateInfrastructureCfg(Configuration, Project, Project, DecisionVariableDeclaration))- Returns:
- the IVML project
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- in case of model query problemsnet.ssehub.easy.basics.modelManagement.ModelManagementException- in case of model management problemsnet.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case of unmatching values
-
createRefToTuple
private static net.ssehub.easy.varModel.cst.ConstraintSyntaxTree createRefToTuple(net.ssehub.easy.varModel.model.DecisionVariableDeclaration var, String slotName, int index) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException Creates an expression accessing theindexelement ofslotNameinvar.- Parameters:
var- the variable to accessslotName- the slot to accessindex- the index within the slot to access- Returns:
- the accessing expression
- Throws:
net.ssehub.easy.varModel.cst.CSTSemanticException- in case that the constraint expression cannot be creatednet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case that the index value does not match
-
createDataSourceParameters
private static Object[] createDataSourceParameters(net.ssehub.easy.varModel.model.Project cfgProject) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException Creates the default adaptable parameters for a data source.- Parameters:
cfgProject- the project used to query for types- Returns:
- the parameters
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- in case that types cannot be resolvednet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case that the value cannot be created due to type mismatches
-
createFreezeBlock
private static net.ssehub.easy.varModel.model.FreezeBlock createFreezeBlock(net.ssehub.easy.varModel.model.IFreezable[] freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.model.ModelQueryException Creates a freeze block forprojectand adds it toproject.- Parameters:
freezables- the freezablesproject- the IVML project to add to (may be null if failed)fallbackForType- in case thatprojectis being written the first time, may be null- Returns:
- the created freeze block
- Throws:
net.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case of unmatching valuesnet.ssehub.easy.varModel.model.ModelQueryException- in case of model access problems
-
createFreezeBlock
public static net.ssehub.easy.varModel.model.FreezeBlock createFreezeBlock(List<net.ssehub.easy.varModel.model.IFreezable> freezables, net.ssehub.easy.varModel.model.Project project, net.ssehub.easy.varModel.model.Project fallbackForType) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.model.ModelQueryException Creates a freeze block forprojectand adds it toproject.- Parameters:
freezables- the freezablesproject- the IVML project to add to (may be null if failed)fallbackForType- in case thatprojectis being written the first time, may be null- Returns:
- the created freeze block
- Throws:
net.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case of unmatching valuesnet.ssehub.easy.varModel.model.ModelQueryException- in case of model access problems
-
createQmProject
private static net.ssehub.easy.varModel.model.Project createQmProject(String name, net.ssehub.easy.varModel.model.Project typeFallback) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException, net.ssehub.easy.varModel.model.ModelQueryException Creates a project with basic settings for QM.- Parameters:
name- the name of the projecttypeFallback- a project acting as type fallback (may be null)- Returns:
- the created project
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- in case of model query problemsnet.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- in case of unmatching values
-
getValue
private static net.ssehub.easy.varModel.model.values.Value getValue(net.ssehub.easy.varModel.confModel.IDecisionVariable var, String slot) throws net.ssehub.easy.varModel.model.ModelQueryException Returns (a copy) of the value of theslotinvar.- Parameters:
var- the variable to look intoslot- the slot name- Returns:
- the (copied) value
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- if the given slot does not exist
-
addTopLevelValues
private static List<net.ssehub.easy.varModel.model.IFreezable> addTopLevelValues(net.ssehub.easy.varModel.confModel.Configuration cfg, net.ssehub.easy.varModel.model.Project source, net.ssehub.easy.varModel.model.Project target, String... exclude) throws net.ssehub.easy.varModel.cst.CSTSemanticException Adds top level values configured forsourcetotarget.- Parameters:
cfg- the actual configuration holding the valuessource- the source projecttarget- the target projectexclude- the variable names to exclude- Returns:
- the changed top-level variables ready for freezing
- Throws:
net.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errors
-
addImports
private static void addImports(net.ssehub.easy.varModel.model.Project source, String[] imports, net.ssehub.easy.varModel.model.Project target, net.ssehub.easy.varModel.model.Project... furtherImports) throws net.ssehub.easy.basics.modelManagement.ModelManagementException Adds the given imports totarget.- Parameters:
source- the project to look for the importsimports- the import names to addtarget- the target project to modify as a side effectfurtherImports- further imports created in this class- Throws:
net.ssehub.easy.basics.modelManagement.ModelManagementException- in case of model management problems
-
createDecisionVariable
private static net.ssehub.easy.varModel.model.DecisionVariableDeclaration createDecisionVariable(String name, net.ssehub.easy.varModel.model.datatypes.IDatatype type, net.ssehub.easy.varModel.model.Project target, Object... values) throws net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException Creates a decision variable declaration.- Parameters:
name- the name of the variabletype- the typetarget- the project to add the variable tovalues- the values as default value- Returns:
- the created variable
- Throws:
net.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- if the given values do not match
-
setPipelines
private static net.ssehub.easy.varModel.model.DecisionVariableDeclaration setPipelines(net.ssehub.easy.varModel.model.Project prj, String varName, net.ssehub.easy.varModel.model.DecisionVariableDeclaration pipeline) throws net.ssehub.easy.varModel.model.ModelQueryException, net.ssehub.easy.varModel.cst.CSTSemanticException, net.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException Sets the givenpipelineas value in thevarNameofprj.- Parameters:
prj- the project to modifyvarName- the variable to modifypipeline- the pipeline to set as (reference) value- Returns:
- the affected variable
- Throws:
net.ssehub.easy.varModel.model.ModelQueryException- if access to the variable failednet.ssehub.easy.varModel.cst.CSTSemanticException- in case of CST errorsnet.ssehub.easy.varModel.model.values.ValueDoesNotMatchTypeException- ifpipelinedoes not match as a value
-