The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
"Load singleMacroDefinition into groovy"
Hello,
I have two operators which gives input to groovy.
ExampleSet exampleSet = operator.getInput(ExampleSet.class,1);
ExampleSet exampleSet2 = operator.getInput(ExampleSet.class,0);
One exampleSet1 is data from a database query, while exampleSet2 is from an excel file. What I would like to do, is change the input from a database query and excel file, to a database query, and 3 SingleMacroDefinition operators.
Thanks
Cleo
I have two operators which gives input to groovy.
ExampleSet exampleSet = operator.getInput(ExampleSet.class,1);
ExampleSet exampleSet2 = operator.getInput(ExampleSet.class,0);
One exampleSet1 is data from a database query, while exampleSet2 is from an excel file. What I would like to do, is change the input from a database query and excel file, to a database query, and 3 SingleMacroDefinition operators.
Thanks
Cleo
Tagged:
0
Answers
I have tried several different setups in an attempt to load the macro values into an Execute Script.
I have an Execute Script Operator, with a Set Macros, and a Set Macro Operator attached to it.
Within the Execute Script Operator I print the results of the following statements.
operator.hasInput(DataMacroDefinitionOperator.class);
operator.hasInput(Macro2Log.class);
operator.hasInput(MacroConstructionOperator.class);
operator.hasInput(MacroDefinitionOperator.class);
operator.hasInput(SingleMacroDefinitionOperator.class);
Each time I get false.
In a different setup I attach the Set Macro Operator to a Log Operator, which writes the value of the macro to a file, then attach it to an Execute Script Operator. Within the Execute Script Operator, I have not been able to access the information within the Log Operator.
operator.getLog().toString();
I can attach the Set Macro Operator to a Log Operator, write the macro information to a file then read the file from the execute script operator but I think there should be a better way to do this.
Any suggestions,
Thanks,
Cleo
Macros aren't delivered over input ports like usual IOObjects. Instead they are set globally in the process. The macro operators doesn't need input and output, but they provide ports forwarding the inputs for giving the user a possibility to define the execution order in an easy way.
So all you have to do is to ensure that the set macro operators has been executed before the scripting operator is started. Then you could access all macros using this code: Greetings,
Sebastian
FYI: I am using RM 5 RC. 5.0.1
I tried the above code and got the following error.
Message: The scripting engine Groovy reported an error in the script: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script1.groovy: 12: unable to resolve class MacroHandler
@ line 12, column 14.Script1.groovy: 13: unable to resolve class MacroHandler
@ line 13, column 29.Script1.groovy: 15: unable to resolve class MacroHandler
@ line 15, column 23.
3 errors
So I added the line:
inculde com.rapidminer.MacroHandler;
It then gave me the error
Message: The scripting engine Groovy reported an error in the script: groovy.lang.MissingMethodException: No signature of method: Script1.getProcess() is applicable for argument types: () values: [].
I then added the line:
import com.rapidminer.Process;
and nothing happened.
To ensure the set macro operator has been executed before the script operator has started I have:
Verified that the set macro operator is above the script operator within the tree view.
Included an additional Script operator with the following code:
synchronized(this) {
wait(2000);
}
in between the set macro operator, and the Script operator trying to access the macro information.
Questions:
1) Any suggests to debug this problem?
2) I could not find documentation on the function getProcess() could you please point me to it. Is there a list of global functions and variables available to the Script operator?
3) The "this" in the function synchronized(this). What object type is it?
4) Unrelated question, but can I write the macro to dynamically write sql queries for the Read Database Operator?
Thanks,
Cleo
I guess you have to and an It seems to me, it's the only combination you didn't try
Greetings,
Sebastian
I did try
This code removed the first set of errors. The global function "getProcess()"
seems to be the source of the second set of errors.
I tried to add the code in an attempt to eliminate this problem but it did not work.
I could not find any documentation on the function getProcess().
Now that the RM 5 RC source code is released on sourceforge I may try to debug the problem from that.
Thanks,
Cleo
I took a look in that matter and found that "this" is defined inside the script to be the script itself. The current operator might be reached over the predefined variable "operator". Take a look at this code: I will note this in the whitepaper for extending RapidMiner...
Greetings,
Sebastian
This works perfectly now.
Cheers,
Cleo