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
"Additional operators XML in Linux does not work"
I believe that you cannot load additional operators XML files in linux: the following code works in windows:
Thanks,
Jon
String myOperatorsPath = MyInit.class.getResource("/com/mycompany/rapidminer/MyOperators.xml").getPath();But it does not work in Linux because it appears that the operators path is split by RapidMiner's OperaterService according the the Linux file separator ":" and as such the file path above results in two files ("file" and "/home/user/my.jar!/com/mycompany/rapidminer/MyOperators.xml") which are clearly not files
logger.info("Attempting to load additional RapidMiner Operators at path {}.", myOperatorsPath); // This will be something like "file:/home/user/my.jar!/com/mycompany/rapidminer/MyOperators.xml"
OperatorService.setAdditionalOperatorDescriptors(myOperatorsPath);
logger.info("Initialising RapidMiner OperatorService.");
// Note: only need to initialise RapidMiner Operations for this app
OperatorService.init();
I wonder if you could confirm this is a bug and either way provide a solution for loading additional operators from XML file located WITHIN a jar file. Just a reminder that the code does work on Windows, but not linux.
OperatorService.init:
String[] additionalOperatorFileNames = additionalOperators.split(File.pathSeparator); // this is ":" on Linux, and ";" on Windows.
for (int i = 0; i < additionalOperatorFileNames.length; i++) {
...
}
Thanks,
Jon
Tagged:
0
Answers
I can confirm that your code will not work. However, it is a miracle that it works on Windows. The method signature OperatorService.setAdditionalOperatorDescriptors() asks for file names, not URLs, so passing "file:/home/user/my.jar!/com/mycompany/rapidminer/MyOperators.xml" would not work either. Anyway, why do you assume getResource(...).getPath() returns anything that is usable without the rest of the URL? Maybe in your Windows version the class files were not in a Jar but in a file system, so the getPath() actually returned valid file names and it worked by chance.
I agree that there is no escaping in the mathod you are calling, but adding the escaping would not help either due to the reasons mentioned above. Why don't you just make it an extension, that's much cleaner anyway. Actually I don't remember why the OperatorService.setAdditionalOperatorDescriptors() exists anyway :-)
Best,
Simon
I'm sure an extension would be cleaner. However, the "additional operators" feature seems very quick and easy. The only steps need are:
- Write my custom operator (can be in my package as long as it extends Operator).
- Create my Operators.xml and OperatorsDescription.xml - I actually believe the operator description requirement should be relaxed for quick development and plugin of operators. In this case, I only need to do step 1.
- Tell RapidMiner where to find my xml files.
That's all. I've not looked into extensions and how much code is needed for them though.Thanks for the response, Jon.
ok, so the only thing you need to do is to use a file rather than a URL.
In your case, you seem to have a JAR already, so making it an extension, is basically step 3: Tell RapidMiner where to find your xml files. That goes into the manifest.
Best,
Simon