Running a process from inside NetBeans
Hello ^_^
i'm sorry but i guess i have the typical question , how can i run my process from inside the NetBeans
i know the problem here is in the path because i read a lot about this problem but no answer could really make me understand the solution
my code is
try {
RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE);
RapidMiner.init();
Process process = new Process (new File("C:\Users\SAR\.RapidMiner\repositories\Local Repository\processes"));//the problem is here and i can't access the repository
process.run();
} catch (IOException | XMLException | OperatorException ex) {
ex.printStackTrace();
what is the exact path should i use here or using the other method
RepositoryLocation loc = new RepositoryLocation("//Local Repository/Users/SAR/.RapidMiner/repositories/Local Repository/processesKNN2.rmp");//i know the path here is not working right too
Process process = new RepositoryProcessLocation(loc).load(null);
process.run()
thank you in advance
Find more posts tagged with
If you save the process in Studio via "File" - "Export Process...", the created .rmp file will have the right XML format. You then read the whole content of this file via plain Java (see for example here: http://javarevisited.blogspot.com/2015/02/how-to-read-file-in-one-line-java-8.html). Let's assume the XML string is stored in the variable "xmlOfProcess", the code to create the process object is then simply
Process process = new Process(xmlOfProcess);
Still I do not know how to read a process from a repository. The path you used looks correct, but maybe your Netbeans installation does not know about where the repositories are stored...
Anyway, hope this helps. Cheers,
Ingo
Don't know what happened there. Here again: http://javarevisited.blogspot.com/2015/02/how-to-read-file-in-one-line-java-8.html
Sorry to bother again but is this right using the way you mentioned?? cause i don't think i really get it
try {
String s = new String (readAllBytes(get("C:\\Users\\SAR\\Desktop\\g.rmp")));
RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE);
RapidMiner.init();
process.run(s);
} catch (IOException | XMLException | OperatorException ex) {
ex.printStackTrace();
Aeh, no :-)
Here are three code snippets which should help. First you initialize RapidMiner like you do. That part is fine.
Then, you read the XML from a file or URL. As I said, there are dozens of methods to do that. Here is a code snippet I found online:
private String readFile(String fileName) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String line = null;
StringBuilder stringBuilder = new StringBuilder();
String ls = System.getProperty("line.separator");
try {
while((line = reader.readLine()) != null) {
stringBuilder.append(line);
stringBuilder.append(ls);
}
return stringBuilder.toString();
} finally {
reader.close();
}
}
Now you create a process:
process = null;
try {
process = new Process(processXML);
} catch (IOException | XMLException e) {
// do something
}
Finally, you run the process and collect the results:
IOContainer results;
try {
results = process.run();
} catch (Throwable e) {
// do something
}
You can now query the results from the IOContainer, for example with something like this:
ExampleSet data = null;
try {
data = results.get(ExampleSet.class);
} catch (MissingIOObjectException e) {
// do something
}
This should do the trick.
Cheers,
Ingo
Hello
i put the function "readFile" exactly like you mentioned in the first block of code just added "statsic" so i can call it in the main
inside the main :
RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE);
RapidMiner.init();
String s;
try
{
s=readFile("C://Users//SAR//.RapidMiner//repositories//Local Repository//processes//KNN2.rmp");
Process process = null;
process = new Process(s);
IOContainer results;
results = process.run();
ExampleSet data = null;
data = results.get(ExampleSet.class);
System.out.println(data);
}
catch (Exception ex)
{
System.out.println("EXCEPTION");
ex.printStackTrace();
System.out.println(ex.toString());
}
and it gave the same error :
com.rapidminer.operator.UserError: Cannot resolve relative repository location '../data/Final DataSet'. Process is not associated with a repository.
where "Final DataSet" is the set inside my processes...is there a solution??
Actually everything works as expected with the process loading. But now you have a new problem: since you load the process without a repository connection now, you cannot resolve the path to your data (since the process is built from a string it does not know where it lives...). Replace the data loading in your process with Read XYZ operator reading the data from a file with an absolute path reference and you should be fine...
Again, you might also be able to load from the repository but then you need to let your program know where the repositories are... I unfortunately do not know how this is done but maybe somebody else does...
Cheers,
Ingo
Actually everything works as expected with the process loading. But now you have a new problem: since you load the process without a repository connection now, you cannot resolve the path to your data (since the process is built from a string it does not know where it lives...). Replace the data loading in your process with Read XYZ operator reading the data from a file with an absolute path reference and you should be fine...
Again, you might also be able to load from the repository but then you need to let your program know where the repositories are... I unfortunately do not know how this is done but maybe somebody else does...
Cheers,
Ingo
just need to know the exact path to use please to reach my processes