Accessing a process definition and metadata

BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
Recently I got an interesting request: provide a configuration setting (which is defined in a process context macro) as a web service.
I expected this to work with built-in RapidMiner operators, but neither Loop Repository nor Retrieve nor Open File will open a process from the repository. 
However, with a simple Groovy script (in the built-in Execute Script operator) it's easy to get the process definition as XML, and then process it further with RapidMiner operators.
import com.rapidminer.repository.RepositoryLocation;
import com.rapidminer.RepositoryProcessLocation;
 
//Current repository path
parentLoc = operator.getProcess().getRepositoryLocation().parent();
//Other repository entry, relative to the current path
loc = new RepositoryLocation(parentLoc, "Example process");
//Process to read as XML
processCode = new RepositoryProcessLocation(loc).getRawXML();
 
//Add a macro with the process XML
operator.getProcess().getMacroHandler().addMacro("processXML", processCode);
The result is a macro that contains the specified process formatted as XML. You can then use RapidMiner operators to process the data further and extract the things you want. 
You can find more details and a downloadable example process in my blog on datascientist.at.
Sign In or Register to comment.