发布新帖

查找

公告
· 11 hr 前

线上启动会:InterSystems 2026 全栈竞赛

Hi开发者们,

我们很高兴邀请大家参加即将举行的 InterSystems 全栈竞赛线上启动会

在此次线上研讨会上,您将发现本次竞赛中等待开发人员的激动人心的挑战和机遇。我们还将讨论希望参赛者涉及的主题,并向您展示如何使用 InterSystems IRIS 数据平台开发、构建和部署应用程序。

日期和时间:美国东部时间 2 月 2 日星期一下午 12:00 | 欧洲中部时间下午 6:00

演讲者
🗣 @Derek Gervais,开发人员关系布道师
🗣 @Evgeny Shvarov,开发人员和初创企业项目高级经理
🗣 @Raj Singh,开发人员体验产品经理

今天就注册参加启动仪式

讨论 (0)1
登录或注册以继续
文章
· 11 hr 前 阅读大约需 6 分钟

pyprod: Pure Python IRIS Interoperability

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

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:

  1. Business Hosts: These are the core building blocks—Services, Processes, and Operations—that pass persistable messages between one another.
  2. Adapters: Inbound and outbound adapters manage the interaction with the external world, handling the specific protocols needed to receive and send data.
  3. 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.
  4. 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.

  1. 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.
  2. 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. 
  3. 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.

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.


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!
讨论 (0)1
登录或注册以继续
文章
· 12 hr 前 阅读大约需 2 分钟

临时文件与单例:自我清理

我曾多次遇到一种模式,即我需要使用临时文件/文件夹,并在稍后的某个时候将其清理掉。

在这种情况下,自然是遵循"Robust Error Handling and Cleanup in ObjectScript "中的模式,使用 try/catch/pseudo-finally 或注册对象来管理析构函数中的清理工作。%Stream.File*也有一个 "RemoveOnClose "属性,您可以对其进行设置,但要小心使用,因为您可能会不小心删除一个重要文件,而且这个标志会在调用%Save()时被重置,因此您需要在重置后将其设回 1。

不过,有一个棘手的情况——假设你需要临时文件在外部堆栈级别中继续存在。例如:

ClassMethod MethodA()
{
    Do ..MethodB(.filename)
    // Do something else with the filename
}

ClassMethod MethodB(Output filename)
{
    // Create a temp file and set filename to the file's name
    Set filename = ##class(%Library.File).TempFilename()
    
    //... and probably do some other stuff
}

你总是可以传递 RemoveOnClose 设置为 1 的 %Stream.File* 对象,但我们在这里讨论的其实只是临时文件。

这就是 "单例(Singleton)"概念的由来。我们在IPM %IPM.General.Singleton 中有一个基本实现,你可以扩展它以满足不同的使用情况。一般行为和使用模式如下

  • 在较高的堆栈层中,调用该类的 %Get(),可以获得一个实例,在较低的堆栈层中调用 %Get() 也可以获得该实例。
  • 当对象在使用它的最高堆栈层中退出作用域时,将运行清理代码。

这比 % 变量更好一些,因为你不需要去检查它是否被定义,而且它还能通过一些深层对象技巧,在较低的堆栈层级上存活下来。

关于临时文件,IPM 也有一个临时文件管理器单例。解决这个问题的方法是:

ClassMethod MethodA()
{
    Set tempFileManager = ##class(%IPM.Utils.TempFileManager).%Get()
    Do ..MethodB(.filename)
    // Do something else with the filename
    // The temp file is cleaned up automatically when tempFileManager goes out of scope
}

ClassMethod MethodB(Output filename)
{
    Set tempFileManager = ##class(%IPM.Utils.TempFileManager).%Get()
    // Create a temp file and set filename to the file's name
    Set filename = tempFileManager.GetTempFileName(".md")
    
    //... and probably do some other stuff
}
讨论 (0)1
登录或注册以继续
问题
· 14 hr 前

Plumbing Services in Dubai – Professional & Reliable Plumbing Solutions

Our Plumbing Services in Dubai provide expert, fast, and affordable solutions for residential and commercial plumbing needs. Whether you are dealing with a leaking pipe, blocked drain, faulty water heater, or require complete plumbing installation, our skilled plumbers deliver efficient and long-lasting results.

We use advanced tools, high-quality materials, and industry-approved techniques to diagnose and resolve plumbing issues safely and effectively. Each service begins with a detailed inspection to identify the root cause and prevent future problems.

Our plumbing services in Dubai include leak detection and repair, blocked drain cleaning, pipe repair and replacement, tap and mixer installation, toilet repair, water heater installation and maintenance, bathroom and kitchen plumbing, and emergency plumbing services.

讨论 (0)1
登录或注册以继续
文章
· 14 hr 前 阅读大约需 4 分钟

SQLウィンドウ関数を理解する(パート1)

InterSystems IRISのウィンドウ関数を使用すると、累積合計、ランキング、移動平均など、強力な分析を直接SQLで実行できます。
ウィンドウ関数は、「GROUP BY」のように結果をまとめることなく、関連行の「ウィンドウ」(グループ上)で動作します。
つまり、ループも結合も一時テーブルも使わずに、より簡潔で高速、しかも保守しやすいクエリを書くことができます。

この記事では、よくあるデータ分析タスクに取り組むことで、ウィンドウ関数の仕組みを理解していきましょう。


InterSystems IRISでのSQLウィンドウ関数入門

SQLウィンドウ関数は、データ分析のための強力なツールです。
各行をそのまま表示したまま、複数行の集計とランキングを計算することができます。
ダッシュボード、レポート、または複雑な分析を構築しているかどうかに関係なく、ウィンドウ関数はロジックを簡素化し、パフォーマンスを大幅に向上させます。

注意:私はウィンドウ関数の専門家ではありませんが、私がウィンドウ関数を理解するうえで役立ったインサイトやリソースを共有したいと思います。 ご提案や訂正があれば、ぜひお知らせください!

讨论 (0)0
登录或注册以继续