Initial Release
Interface to Julia programming language for InterSystems IRIS. Execute Julia code and more from InterSystems IRIS.
This projects brings you the power of Julia right into your InterSystems IRIS environment:
ML Toolkit user group is a private GitHub repository set up as part of InterSystems corporate GitHub organization. It is addressed to the external users that are installing, learning or are already using ML Toolkit components. To join ML Toolkit user group, please send a short e-mail at the following address: MLToolkit@intersystems.com and indicate in your e-mail the following details (needed for the group members to get to know and identify you during discussions):
do $system.OBJ.ImportDir("/path/to/unpacked/juliagateway","*.cls","c",,1)) in Production (Ensemble-enabled) namespace. In case you want to Production-enable namespace call: write ##class(%EnsembleMgr).EnableNamespace($Namespace, 1).bin folder of your InterSystems IRIS installation. Library file should be placed into a path returned by write ##class(isc.julia.Callout).GetLib().JULIA_HOME environment variable points to Julia 1.4.0.PATH environment variable has:%JULIA_HOME%\bin variable (or directory it points to)write $SYSTEM.Util.GetEnviron("JULIA_HOME") and verify it prints out the directory of Julia installationwrite $SYSTEM.Util.GetEnviron("PATH") and verify it prints out the bin directory of Julia installation$JULIA_HOME/lib (if you installed to /tmp/julia, set LibPath=/tmp/julia/lib).After installation you’ll need these packages. In OS bash run:
import Pkg;
Pkg.add(["JSON", "CSV", "DataFrames"])
using JSON, CSV, DataFrames
iscjulia.so into repository root (if it’s not there already)docker build --force-rm --tag intersystemsdc/irisjulia:latest . By default the image is built upon store/intersystems/iris-community:2019.4.0.383.0 image, however you can change that by providing IMAGE variable. To build from InterSystems IRIS execute: docker build --build-arg IMAGE=store/intersystems/iris:2019.4.0.383.0 --force-rm --tag intersystemsdc/irisjulia:latest .docker run -d \
-p 52773:52773 \
-v /<HOST-DIR-WITH-iris.key>/:/mount \
--name iris \
intersystemsdc/irisjulia:latest \
--key /mount/iris.key \
docker exec -it iris iris session iris.docker stop iris && docker rm --force iris.set sc = ##class(isc.julia.Callout).Setup() once per systems start (add to ZSTART: docs, sample routine available in rtn folder).set sc = ##class(isc.julia.Callout).Initialize()write ##class(isc.julia.Main).SimpleString(code, .result)set sc = ##class(isc.julia.Callout).Finalize() to free Julia context.set sc = ##class(isc.julia.Callout).Unload() to free callout library.set sc = ##class(isc.julia.Callout).Setup()
set sc = ##class(isc.julia.Callout).Initialize()
set sc = ##class(isc.julia.Main).SimpleString("sqrt(4)", .result)
write result
set sc = ##class(isc.julia.Callout).Finalize()
set sc = ##class(isc.julia.Callout).Unload()
Generally the main interface to Julia is isc.julia.Main. It offers these methods (all return %Status), which can be separated into three categories:
These methods allow execution of arbitrary Julia code:
ImportModule(module) - import module.SimpleString(code, .result) - execute code for cases where both code and result are less than $$$MaxStringLength in length.ExecuteCode(code, variable, .result) - execute code (it may be a stream or string), optionally set code into variable.Transfer data into and from Julia.
GetVariable(variable, serialization, .stream, useString) - get serialization of variable in stream. If useString is 1 and variable serialization can fit into string then string is returned instead of the stream.ExecuteQuery(query, variable, type, namespace) - create DataFrame from sql query and set it into variable. isc.julia package must be available in namespace (Available type is DataFrame).Support methods.
GetVariableInfo(variable, serialization, .defined, .type, .length) - get info about variable: is it defined, type and serialized length.GetVariableDefined(variable, .defined) - is variable defined.GetVariableType(variable, .type) - get variable FQCN.Possible Serializations:
string - Serialization by string() functionjson - Serialization by JSON moduleTo open Julia shell: do ##class(isc.julia.util.Shell).Shell(). To exit press enter.
In rtn folder zj command example is also available. Import into %SYS namespace.
Interoperability adapter isc.julia.ens.Operation offers ability to interact with Julia process from Interoperability productions. Currently three requests are supported:
isc.julia.msg.ExecutionRequest. Returns isc.julia.msg.ExecutionResponse with requested variable valuesisc.julia.msg.StreamExecutionRequest. Returns isc.julia.msg.StreamExecutionResponse with requested variable values. Same as above, but accepts and returns streams instead of strings.isc.julia.msg.QueryRequest. Returns Ens.Response.Check request/response classes documentation for details.
Settings:
Initializer - select a class implementing isc.julia.init.Abstract. It can be used to load functions, modules, classes and so on. It would be executed at process start.julia <repo-dir>\install.jl
write ##class(isc.julia.test.AMES).Import() to load the dataset.isc.julia.test.Production production.Ens.Request message to the isc.julia.test.Process.All business processes inheriting from isc.julia.ens.ProcessUtils can use GetAnnotation(name) method to get value of activity annotation by activity name. Activity annotation can contain variables which would be calculated on ObjectScript side before being passed to Julia. This is the syntax for variable substitution:
${class:method:arg1:...:argN} - execute method#{expr} - execute ObjectScript codeExample: save(r'#{process.WorkDirectory}SHOWCASE${%PopulateUtils:Integer:1:100}.png')
In this example:
#{process.WorkDirectory} returns WorkDirectory property of process object which is an instance of the current business process.${%PopulateUtils:Integer:1:100} calls Integer method of %PopulateUtils class passing arguments 1 and 100, returning random integer in range 1...100.To run tests execute:
set repo = ##class(%SourceControl.Git.Utils).TempFolder()
set ^UnitTestRoot = ##class(%File).SubDirectoryName(##class(%File).SubDirectoryName(##class(%File).SubDirectoryName(repo,"isc"),"julia"),"unit",1)
set sc = ##class(%UnitTest.Manager).RunTest(,"/nodelete")
Install ZLANG routine from rtn folder to add zj command:
zj "sqrt(2)"
zj
Argumentless zj command opens Julia shell.
There are several limitations associated with the use of JuliaGateway.
Pkg is not supported on Windows.zzz* variables. Please report any leakage of these variables. System code should always clear them.zzz*() functions.Development of ObjectScript is done via cache-tort-git in UDL mode.
Development of C code is done in Eclipse.
Commits should follow the pattern: module: description issue. List of modules:
isc.julia.Callout.isc.julia.Main.make and gcc.mingw32-make.exe to make.exe in mingw64\bin directory.GLOBALS_HOME environment variable to the root of InterSystems IRIS installation.JULIA_HOME environment variable to the root of Julia installation.mingw64env.cmd or mingw-w64.bat).<Repository>\c\ execute make.apt install build-essential (for Mac install gcc compiler and make).GLOBALS_HOME environment variable to the root of InterSystems IRIS installation.JULIA_HOME environment variable to the root of Julia installation.<Repository>/c/ execute make.
