How can we use the wolframclient
Python library to call Mathematica functions when Mathematica is running in an another server?
For example, if we have Mathematica running locally we can do as following:
from wolframclient.language import wlexpr
from wolframclient.evaluation import WolframLanguageSession
if __name__ == '__main__':
with WolframLanguageSession() as session:
code = 'N[Zeta[2]]'
expression = wlexpr(code)
result = session.evaluate(expression)
print(result)
the code above will connect with our local Kernel and execute the command. We can also pass an argument to point the location of the Mathematica Kernel as well with
WolframLanguageSession('/path/to/the/wolframscript/kernel')
But how can we configure and call Mathematica running in another server? Let's say 10.0.0.1:31415?
I've seen that we have an option to use a WSTPServer, but I couldn't figure it out how to use it with the wolframscript
Python library.
Also in the WolframScript documentation we have an option to use the argument -wstpserver
.
So how could we put all of this together?