Some time ago I saw an email on one of the email lists in which, the author asked how to import custom python modules into ODI. When reading this email, I did not know, what would be the best way to perform such a thing and that made me a little curious. After a while, trying to find the answer on the net and waiting for replies on the email lists, I have decided to check it out on my own. The best solution, in my opinion, would be using the -Dpython.path Java argument. The main reasons for this would be:
- This is more a Jython problem than ODIs and therefore, the solution should be, as well, at Jythons level.
- Another good thing is that this argument could easily rely on the, well known, $PYTHONPATH environment variable. Resulting, in insurance that all applications are using the same version of the files.
- Anyone importing custom modules into ODI would like to maintain some kind of portability option, just in case, the decision of moving the python files will come. In this case, all that will be required is changing the $PYTHONPATH environment variable to the new location and restart the agents so the change will take effect.
1. Configure the $PYTHONPATH environment variable. For example in linux:
2. Edit the ODI_ADDITIONAL_JAVA_OPTIONS in your odiParams.sh/bat and append “$PYTHONPATH” to it. For example in linux:
Now, if you try using your python files they will be successfully imported into Jython from within ODI. Also, to make sure that the changes have taken effect, you can print the sys.path variable from Jython in order to see what is included in your path.