Initial Release
Examples of PythonGateway Usage. Python Gateway for InterSystems Data Platforms. Execute Python code and more from InterSystems IRIS brings you the power of Python right into your InterSystems IRIS environment:
git clone https://github.com/intersystems-community/PythonGatewaySamples.git
cd PythonGatewaySamples
docker-compose build --pull
docker-compose up -d
do $system.OBJ.ImportDir("C:\InterSystems\Repos\PythongatewaySamples\","*.cls","c",,1)
) into Production (Ensemble-enabled) namespace. In case you want to Production-enable namespace call: write ##class(%EnsembleMgr).EnableNamespace($Namespace, 1)
.do ##class(ml.match.Restaurant).Import()
.do $system.OBJ.ImportDir("C:\InterSystems\Repos\PythongatewaySamples\","*.xml","c")
pip install -r requirements.txt
ml.Production
.To choose a specific example filter by production category.
Using Dedupe or RLTK to deduplicate restaurant data.
We start with the working self-correcting model used for predictive maintenance. First, we see how production elements work together and how our transactional processes can benefit from AI/ML models. After that, we’d improve the model and see how this change propagates through production. Finally, we’ll explore different applications of this architecture.
We want to do predictive maintenance on engines. Dataset: we store information about one specific engine. We get a large array of sensor data every second. Historic data is already in the dataset. Check https://github.com/intersystems-community/PythonGatewaySamples/blob/master/Engine.md for a step-by-step walkthrough. Note that GitHub does not render base64 embedded images, so you’ll need a separate markdown viewer.
py.ens.Operation
– executes Python code and sends back the results.ml.engine.TrainProcess
– trains a new prediction model.ml.engine.PredictService
– a service that receives information from engine sensors and sends it to ml.engine.PredictProcess to predict engine state. At the moment it is disabled (grey) and does not transfer data.ml.engine.PredictProcess
- uses the ML model to predict engine state.ml.engine.CheckService
– regularly checks the accuracy of the ML model. If the prediction error rate is above the threshold, the service sends a request to the ml.engine.TrainProcess
to update the model.ml.engine.InitService
– sends a request to the ml.engine.TrainProcess
to train the initial model at production start.Start Predict Service
and Check Service
to see model be automatically retrained when prediction quality drops.
This example shows an image similarity search, by default we are using the footwear dataset, but any type of image can be used, as long as the target object is the main object on the images in the dataset. Additionally, this example shows how an AI model can be exposed via REST API in InterSystems IRIS. This example can be used as a feature in retail a mobile app to allow users to take product photos from a camera and find the corresponding product(s) from the retailer shop.
Docker Installation
above. Do not run the containers./usr/irissys/mgr/Temp
directory. docker-compose.yml
contains an example. Uncomment the lines and point docker to the empty host directory. If you’re running DD on Windows with HV backend you’ll additionally need to share the host directory with Docker.docker-compose up -d
ml.cam.ens.bs.InitService
http://localhost:52773/csp/user/recommend.html
and upload your image (you can use images from img
directory for testing)ml.cam.data.Photo
class contains our dataset of photos. Use LoadDir
method to add more photos.ml.cam.ens.bp.LoaderProcess
receives ids of ml.cam.data.Photo
and indexes them:
isc.py.data.Context
to Intersystems IRISml.cam.ens.bp.LoaderProcess
first checks if saved context exists and if it does loads the index/variables instead of building it againml.cam.ens.bs.InitService
sends initial trainig request on production startupml.cam.ens.bp.MatcherProcess
receives one target image and uses the index to find the best matchescam.rest.Main
exposes ml.cam.ens.bp.MatcherProcess
as a REST API web application /cam
recommend.html
calls /cam
to get the best matches for an uploaded image (you can use images from img
directory for testing)Execute all steps from Host Installation
first.
zw ##class(ml.cam.data.Photo).LoadDir(<dir>)
.ml.cam.ens.bs.InitService
.recommend.html
to any web application./cam
with ml.cam.rest.Main
dispatch class.recommend.html
in a browser and send your test imageTRUNCATE TABLE isc_py_data.Context
TRUNCATE TABLE isc_py_data.Variable
/usr/irissys/mgr/Temp/index.ann
(this is Default for Docker, in general use check WorkDirectory
value for ml.cam.ens.bp.LoaderProcess
and save the file there as index.ann
).