Article Guillaume Rongier · Jul 31 4m read

This article will introduce you to the concept of virtual environments in Python, which are essential for managing dependencies and isolating project from the OS.

What is a Virtual Environment?

A virtual environment is a folder that contains :

  • A specific version of Python
  • At start an empty site-packages directory

Virtual environments will help you to isolate your project from the OS Python installation and from other projects.

How to use it?

To use virtual environments, you can follow these steps:

0
0 0
Article Guillaume Rongier · Jul 28 3m read

This will be a short article about Python dunder methods, also known as magic methods.

What are Dunder Methods?

Dunder methods are special methods in Python that start and end with double underscores (__). They allow you to define the behavior of your objects for built-in operations, such as addition, subtraction, string representation, and more.

Some common dunder methods include:

0
0 0
Article Guillaume Rongier · Jul 24 5m read

Modules what a topic! We don't have this notion in ObjectScript, but it's a fundamental concept in Python. Let's discover it together.

What is a Module?

I see modules as an intermediate layer between classes and packages. Let see it by example.

A bad example :

# MyClass.py
class MyClass:
    def my_method(self):
        print("Hello from MyClass!")

When you try to use this class in another script, you would do:

# class_usage.py
from MyClass import MyClass # weird, right?

my_instance = MyClass()
my_instance.my_method()

Why this is a bad example?

0
0 0
Article Guillaume Rongier · Jul 17 5m read

This will be an introduction to Python programming in the context of IRIS.

Before anything I will cover an important topic: How python works, this will help you understand some issues and limitations you may encounter when working with Python in IRIS.

All the articles and examples can be found in this git repository: iris-python-article

How Python works

Interpreted Language

Python is an interpreted language, which means that the code is executed line by line at runtime even when you import a script.

What does this mean ? Let's take a look at the following code:

0
0 0
Article Guillaume Rongier · Jan 10 4m read

I'm glad to announce the new version of IoP, which by the way is not just a command line. I'm saying because the new AI search engine still thinks that IoP is just a command line. But it's not. It's a whole framework for building applications on top of the interoperability framework of IRIS with a python first approach.

The new version of IoP: 3.2.0 has a lot of new features, but the most important one is the support of DTL . 🥳

For both IoP messages and jsonschema. 🎉

image

DTL Support

Starting with version 3.2.0, IoP supports DTL transformations.

DTL the Data Transformation Layer in IRIS Interoperability.

DTL transformations are used to transform data from one format to another with a graphical editor. It supports also jsonschema structures.

0
0 0
Article Guillaume Rongier · Jul 26, 2024 5m read

It's been a long time since I didn't write an update post on IoP.

So what's new since IoP command line interface was released?

Two new big features were added to IoP:

  • Rebranding: the grongier.pex module was renamed to iop to reflect the new name of the project.
  • Async support: IoP now supports async functions and coroutines.

Rebranding

The grongier.pex module was renamed to iop to reflect the new name of the project.

The grongier.pex module is still available for backward compatibility, but it will be removed in the future.

Async support

0
0 0
Article Guillaume Rongier · Jul 8, 2024 6m read

Description

This is a template for a Flask application that can be deployed in IRIS as an native Web Application.

Installation

  1. Clone the repository
  2. Create a virtual environment
  3. Install the requirements
  4. Run the docker-compose file
git clone
cd iris-flask-template
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
docker-compose up

Usage

The base URL is http://localhost:53795/flask/.

Endpoints

0
0 0
Article Guillaume Rongier · Jul 8, 2024 8m read

Description

This is a template for an Django application that can be deployed in IRIS as an native Web Application.

Installation

  1. Clone the repository
  2. Create a virtual environment
  3. Install the requirements
  4. Run the docker-compose file
git clone
cd iris-django-template
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
docker-compose up

Usage

The base URL is http://localhost:53795/django/.

Endpoints

0
0 0
Article Guillaume Rongier · Jul 8, 2024 6m read

Description

This is a template for a FastApi application that can be deployed in IRIS as an native Web Application.

Installation

  1. Clone the repository
  2. Create a virtual environment
  3. Install the requirements
  4. Run the docker-compose file
git clone
cd iris-fastapi-template
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
docker-compose up

Usage

The base URL is http://localhost:53795/fastapi/.

Endpoints

0
0 0
Article Guillaume Rongier · Jul 8, 2024 3m read

Context

The Web Server Gateway Interface (WSGI) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. WSGI is a Python standard described in detail in PEP 3333.

🤔 Ok, great definition and what the point with iris ?

IRIS 2024.2+ has a new feature that allows you to run WSGI applications directly on IRIS. This feature is a great way to integrate IRIS with other Python frameworks and libraries.

0
0 0
Article Guillaume Rongier · Feb 29, 2024 26m read

The objective of the article is to provide the reader with the following informations:

  • Configure and use the FHIR server
  • Create an OAuth2 Authorization Server
  • Bind the FHIR server to the OAuth2 Authorization Server for support of SMART on FHIR
  • Use the interoperability capabilities of IRIS for Health to filter FHIR resources
  • Create a custom operation on the FHIR server

Schema of the article:

Schema

0
0 433
Article Guillaume Rongier · Dec 18, 2023 13m read

1. IRIS RAG Demo

IRIS RAG Demo

This demo showcases the powerful synergy between IRIS Vector Search and RAG (Retrieval Augmented Generation), providing a cutting-edge approach to interacting with documents through a conversational interface. Utilizing InterSystems IRIS's newly introduced Vector Search capabilities, this application sets a new standard for retrieving and generating information based on a knowledge base. The backend, crafted in Python and leveraging the prowess of IRIS and IoP, the LLM model is orca-mini and served by the ollama server. The frontend is an chatbot written with Streamlit.

4
2 1017
Article Guillaume Rongier · Aug 28, 2023 1m read

InstallFoundation method is missing (IRIS 2023.2+)

Recently IRIS 2023.2 was released. This version removed this method InstallFoundation from this class HS.HC.Util.Installer. This was a private method and it was not documented. But it was widely used by the community to install FHIR server.

So if you encounter this error:

<METHOD DOES NOT EXIST> *InstallFoundation,HS.HC.Util.Installer

While build a demo our your own FHIR server, you can fix it by replacing this line:

  do ##class(HS.HC.Util.Installer).InstallFoundation(namespace)

to

  Do ##class(HS.Util.Installer.Foundation).Install(namespace)
2
1 381
Article Guillaume Rongier · Jul 24, 2023 20m read

k8sfhir

This is a sample to deploy iris-oauth-fhir on k3d with IKO.

  • iris-oauth-fhir is a sample to deploy a FHIR server with OAuth2 authentication with InterSystems IRIS for Health as a resource server and Google OpenId as an authorization server.
  • k3d is a lightweight wrapper to run k3s (Rancher Lab's minimal Kubernetes distribution) in docker.
  • IKO is a tool to deploy InterSystems IRIS for Health on Kubernetes.
0
1 579
Article Guillaume Rongier · Jul 7, 2023 8m read

Description

With InterSystems IRIS FHIR Server you can build a Strategy to customize the behavior of the server (see documentation for more details).

Image

This repository contains a Python Strategy that can be used as a starting point to build your own Strategy in python.

This demo strategy provides the following features:

  • Update the capability statement to remove the Account resource
  • Simulate a consent management system to allow or not access to the Observation resource
    • If the User has sufficient rights, the Observation resource is returned
    • Otherwise, the Observation resource is not returned
0
1 396
Article Guillaume Rongier · Jul 4, 2023 2m read

When it comes to build an iris image, we can use the cpf merge files.

Here is an cpf merge example:

[Actions]
CreateDatabase:Name=IRISAPP_DATA,Directory=/usr/irissys/mgr/IRISAPP_DATA

CreateDatabase:Name=IRISAPP_CODE,Directory=/usr/irissys/mgr/IRISAPP_CODE

CreateNamespace:Name=IRISAPP,Globals=IRISAPP_DATA,Routines=IRISAPP_CODE,Interop=1

ModifyService:Name=%Service_CallIn,Enabled=1,AutheEnabled=48

CreateApplication:Name=/frn,NameSpace=IRISAPP,DispatchClass=Formation.REST.Dispatch,AutheEnabled=48

ModifyUser:Name=SuperUser,PasswordHash=a31d24aecc0bfe560a7e45bd913ad27c667dc25a75cbfd358c451bb595b6bd52bd25c82cafaa23ca1dd30b3b4947d12d3bb0ffb2a717df29912b743a281f97c1,0a4c463a2fa1e7542b61aa48800091ab688eb0a14bebf536638f411f5454c9343b9aa6402b4694f0a89b624407a5f43f0a38fc35216bb18aab7dc41ef9f056b1,10000,SHA512
0
0 386
Article Guillaume Rongier · May 31, 2023 6m read

I'm proud to announce the new release of iris-pex-embedded-python (v2.3.1) with a new command line interface.

This command line is called iop for Interoperability On Python.

First I would like to present in few words the project the main changes since the version 1.

A breif history of the project

Version 1.0 was a proof of concept to show how the interoperability framework of IRIS can be used with a python first approach while remaining compatible with any existing ObjectScript code.

What does it mean? It means that any python developer can use the IRIS interoperability framework without any knowledge of ObjectScript.

Example :

from grongier.pex import BusinessOperation

class MyBusinessOperation(BusinessOperation):

    def on_message(self, request):
        self.log.info("Received request")

Great, isn't it?

3
0 532
Article Guillaume Rongier · Mar 29, 2023 1m read

Quick Tips: Total Productive Maintenance

Named parameters can be achieved with SQLAlchemy :  

from sqlalchemy import create_engine, text,types,engine

_engine = create_engine('iris+emb:///')

with _engine.connect() as conn:
    rs = conn.execute(text("select :some_private_name"), {"some_private_name": 1})
    print(rs.all())

or with native api

from sqlalchemy import create_engine, text,types,engine

# set URL for SQLAlchemy
url = engine.url.URL.create('iris', username='SuperUser', password='SYS', host='localhost', port=33782, database='FHIRSERVER')

_engine = create_engine(url)

with _engine.connect() as conn:
    rs = conn.execute(text("select :some_private_name"), {"some_private_name": 1})
    print(rs.all())
0
0 517
Article Guillaume Rongier · Mar 8, 2023 5m read

iris-docker-multi-stage-script

A python script to keep your docker iris images in shape ;)

Witout changing your dockerfile or your code you can reduce the size of your image by 50% or more !

TL;DR

Name the builder image builder and the final image final and add this to end of your Dockerfile:

Modify your Dockerfile to use a multi-stage build:

ARG IMAGE=intersystemsdc/irishealth-community:latest
FROM $IMAGE as builder

Add this to end of your Dockerfile:

FROM $IMAGE as final

ADD --chown=${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} https://github.com/grongierisc/iris-docker-multi-stage-script/releases/latest/download/copy-data.py /irisdev/app/copy-data.py

RUN --mount=type=bind,source=/,target=/builder/root,from=builder \
    cp -f /builder/root/usr/irissys/iris.cpf /usr/irissys/iris.cpf && \
    python3 /irisdev/app/copy-data.py -c /usr/irissys/iris.cpf -d /builder/root/ 

Boom! You're done!

8
7 860
Article Guillaume Rongier · Dec 6, 2022 3m read

OCR DEMO

This is a demo of the OCR functionality of the pero-ocr library.

It used in the iris application server in python.

Demo

This is an example of input data :

This is the result of the OCR :

In this example you have the following information:

  • The text is in the TextEquiv tag
  • The confidence is in the conf attribute of the TextEquiv tag
  • The coordinates of the text are in the Coords tag
6
2 535
Article Guillaume Rongier · Nov 30, 2022 2m read

If you are using Python, you can use the built-in venv module to create a virtual environment. This module is the recommended way to create and manage virtual environments.

A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.

So if like me you work a lot with Python, you can use the venv module to create a virtual environment for your project. This will allow you to install packages without affecting the global Python installation.

You will find here two neat alias to create and activate a virtual environment.

Python aliases

alias venv="python3 -m venv .venv; source .venv/bin/activate"
alias irisvenv="python3 -m venv .venv; source .venv/bin/activate; pip install https://github.com/grongierisc/iris-embedded-python-wrapper/releases/download/v0.0.3/iris-0.0.3-py3-none-any.whl"
3
2 1864
Article Guillaume Rongier · Oct 28, 2022 4m read

1. iris-dollar-list

PyPI - StatusPyPIGitHubCoverage

Interpretor of $list for python named DollarList.

This interpretor was made because :

  • I wanted to use $list in python.
  • Embedded Python do not support $list.
  • The native API version do not support embedded $list in $list.

This is a work in progress. For now, it only support embedded $list in $list, int and string.

WIP float,decimal,double

This module is available on Pypi :

pip3 install iris-dollar-list

It is compatible with embedded python and native api.

2
0 683
Article Guillaume Rongier · Sep 30, 2022 8m read

grpc-iris-interop

The aim of this proof of concept is to show how the gRPC protocl can be implemented with the IRIS ineroperabilty module.

architecture

On this schema, we can see that the gRPC Service is hosted by IRIS.

This service must invoke the IRIS interoperability module. For that it transforms the protobuf messages to IRIS messages.

The gRPC client is host by a Flask server for demo purpose, the gRPC client can also be invoke by the python script.

definition of each file

users.proto

0
0 652