Intersystems IRIS Productions provide a powerful framework for connecting disparate systems across various protocols and message formats in a reliable, observable, and scalable manner. intersystems_pyprod, short for InterSystems Python Productions, is a Python library that enables developers to build these interoperability components entirely in Python. Designed for flexibility, it supports a hybrid approach: you can seamlessly mix new Python-based components with existing ObjectScript-based ones, leveraging your established IRIS infrastructure. Once defined, these Python components are managed just like any other; they can be added, configured, and connected using the IRIS Production Configuration page.
A Quick Primer on InterSystems IRIS Productions
.png)
Key Elements of a Production
Image from Learning Services training material
An IRIS Production generally receives data from external interfaces, processes it through coordinated steps, and routes it to its destination. As messages move through the system, they are automatically persisted, making the entire flow fully traceable through IRIS’s visual trace and logging tools. The architecture relies on certain key elements:
- Business Hosts: These are the core building blocks—Services, Processes, and Operations—that pass persistable messages between one another.
- Adapters: Inbound and outbound adapters manage the interaction with the external world, handling the specific protocols needed to receive and send data.
- Callbacks: The engine uses specific callback methods to pass messages between hosts, either synchronously or asynchronously. These callbacks follow strict signatures and return a
Status object to ensure execution integrity.
- Configuration Helpers: Objects such as Properties and Parameters expose settings to the Production Configuration UI, allowing users to easily instantiate, configure, and save the state of these components.
Workflow using pyprod
This is essentially a 3 step process.
- Write your production components in a regular Python script. In that script, you import the required base classes from intersystems_pyprod and define your own components by subclassing them, just as you would with any other Python library.
- Load them into InterSystems IRIS by running the
intersystems_pyprod (same name as the library) command from the terminal and passing it the path to your Python script. This step links the Python classes with IRIS so that they appear as production components and can be configured and wired together using the standard Production Configuration UI.
- Create the production using the Production Configuration page and start the Production
NOTE: If you create all your components with all their Properties hardcoded within the python script, you only need to add them to the production and start the Production.
You can connect pyprod to your IRIS instance by doing a one time setup.
Simple Example
In this example, we demonstrate a synchronous message flow where a request originates from a Service, moves through a Process, and is forwarded to an Operation. The resulting response then travels the same path in reverse, passing from the Operation back through the Process to the Service. Additionally, we showcase how to utilize the IRISLog utility to write custom log entries.
.png)
Step 1
Create your Production components using pyprod in the file HelloWorld.py
Here are some key parts of the code
- Package Naming: We define
iris_package_name, which prefixes all classes as they appear on the Production Configuration page (If omitted, the script name is used as the default prefix).
- Persistable Messages: We define
MyRequest and MyResponse. These are the essential data structures for communication, as only persistable objects can be passed between Services, Processes, and Operations.
- The Inbound Adapter: Our adapter passes a string to the Service using the
business_host_process_input method.
- The Business Service: Implemented with the help of OnProcessInput callback.
- MyService receives data from the adapter and converts it into a
MyRequest message
- We use the
ADAPTER IRISParameter to link the Inbound Adapter to the Service. Note that this attribute must be named ADAPTER in all caps to align with IRIS conventions.
- We define a
target IRISProperty, which allows users to select the destination component directly via the Configuration UI.
- The Business Process: Implemented with the help of OnRequest callback.
- The Business Operation: Implemented with the help of OnMessage callback. (You can also define a MessageMap)
- Logic & Callbacks: Finally, the hosts implement their core logic within standard callbacks like
OnProcessInput and OnRequest, routing messages using the SendRequestSync method.
You can read more about each of these parts on the pyprod API Reference page and also using the Quick Start Guide.
import time
from intersystems_pyprod import (
InboundAdapter,BusinessService, BusinessProcess,
BusinessOperation, OutboundAdapter, JsonSerialize,
IRISProperty, IRISParameter, IRISLog, Status)
iris_package_name = "helloworld"
class MyRequest(JsonSerialize):
content: str
class MyResponse(JsonSerialize):
content: str
class MyInAdapter(InboundAdapter):
def OnTask(self):
time.sleep(0.5)
self.business_host_process_input("request message")
return Status.OK()
class MyService(BusinessService):
ADAPTER = IRISParameter("helloworld.MyInAdapter")
target = IRISProperty(settings="Target")
def OnProcessInput(self, input):
persistent_message = MyRequest(input)
status, response = self.SendRequestSync(self.target, persistent_message)
IRISLog.Info(response.content)
return status
class MyProcess(BusinessProcess):
target = IRISProperty(settings="Target")
def on_request(self, input):
status, response = self.SendRequestSync(self.target,input)
return status, response
class MyOperation(BusinessOperation):
ADAPTER = IRISParameter("helloworld.MyOutAdapter")
def OnMessage(self, input):
status = self.ADAPTER.custom_method(input)
response = MyResponse("response message")
return status, response
class MyOutAdapter(OutboundAdapter):
def custom_method(self, input):
IRISLog.Info(input.content)
return Status.OK()
Step 2
Once your code is ready, load the components to IRIS.
$ intersystems_pyprod /full/path/to/HelloWorld.py
Loading MyRequest to IRIS...
...
Load finished successfully.
Loading MyResponse to IRIS...
...
Load finished successfully.
...
Step 3
Add each host to the Production using the Production Configuration page.
The image below shows MyService and its target property being configured through the UI. Follow the same process to add MyProcess and MyOperation. Once the setup is complete, simply start the production to see your messages in motion.
.png)
Final Thoughts
By combining the flexibility of the Python ecosystem with the industrial-grade reliability of InterSystems IRIS, pyprod offers a modern path for building interoperability solutions. Whether you are developing entirely new "Pure Python" productions or enhancing existing ObjectScript infrastructures with specialized Python libraries, pyprod ensures your components remain fully integrated, observable, and easy to configure. We look forward to seeing what you build!
Quick Links
GitHub repository
PyPi Package
Support the Project: If you find this library useful, please consider giving us a ⭐ on GitHub and suggesting enhancements. It helps the project grow and makes it easier for other developers in the InterSystems community to discover it!