Article
· Dec 6, 2024 2m read

Streamlining Interoperability with Embedded Python in InterSystems IRIS

Interoperability of systems ensures smooth workflow and management of data in today's connected digital world. InterSystems IRIS extends interoperability a notch higher with its Embedded Python feature, which lets developers seamlessly integrate Python scripts into the IRIS components, like services, operations, and custom functions.


Why Embedded Python in IRIS?
Embedded Python brings the flexibility of Python into the powerful world of InterSystems IRIS and provides the following: Access to Python Libraries: Leverage popular libraries such as pandas, NumPy, and requests for advanced data processing.
Ease of Use: Python simplifies the implementation of complex logic.
Efficient Interoperability: Develop services, operations, and transformations directly within IRIS, reducing the need for external tools.

Below is the code I tried to implement for a python business operation:

from iris import irisnative  

class SamplePythonOperation:  
    def on_message(self, request):  
        # Connect to IRIS  
        conn = irisnative.createConnection("localhost", 1972, "USER", "_SYSTEM", "SYS")  
        iris_obj = irisnative.createIRIS(conn)  

        # Log the request message  
        iris_obj.set("Received: " + request.get("MessageText"), "MyApp", "Log")  

        # Process the request  
        response = "Hello, " + request.get("MessageText")  
        return {"Result": response}  

Embedded Python in InterSystems IRIS allows developers to leverage the flexibility of Python with the robustness of IRIS for interoperability solutions. In transforming data, building APIs, or integrating external systems, traditional expectations are that Embedded Python is a revolution for modern applications.

Use Embedded Python today, and discover new avenues of seamless interoperability! 

Discussion (4)1
Log in or sign up to continue

Thanks! Yes I can tell you that. For registering a class into a production,

  • Navigate to Interoperability > Productions.
  • Open or create a new production.
  • Add a new Business Operation.
  • Select the Python Adapter.
  • In the Settings, specify your Python class name
  • The adapter will invoke the method of the Python class whenever the operation receives input.​​​​​​​​​​​​​​

And the difference between them is- Embedded Python runs natively within InterSystems IRIS, allowing you to build and integrate IRIS components like services or operations directly using Python. In contrast, irisnative is an external Python library for connecting to and interacting with an IRIS database from outside the IRIS environment, such as standalone scripts or external applications.

Thanks, but i can't find the Python Adapter do you mean EnsLib.PEX.BusinessOperation or IOP.BusinessOperation.

Next if Embedded Python runs natively on iris, why i have to declare a connection as you mention in your example ?

Does this work best ?

from iop import BusinessOperation

class HelloWorld(BusinessOperation):

    def on_message(self, request):
        self.log_info("Hello World")

Yes, You're right. Sorry for the confusion. By saying Python adapter, I meant EnsLib.PEX.BusinessOperation and also you're perfectly correct about the declaration too. irisnative is unnecessary for local interactions. I'm just trying things on iris so don't take me for an expert😄.

Your code is correct and I would like to add that - 'from EnsLib.PEX import BusinessOperation' would be the best.