Guillaume Rongier · Feb 3, 2025 go to post

FYI in python :

import iris

iris.system.Process.SetNamespace("%SYS")

db_ref_list = iris.ref(None)
iris.cls("Config.Databases").DatabasesByServer("", db_ref_list)
db_list = db_ref_list.value

db_names = db_list.split(",")
for db_name in db_names:
    print(db_name)
Guillaume Rongier · Jan 30, 2025 go to post

I just build it, i had no issue on my side.

In your case, it seems that you don't have the permissions to access /tmp while building the image.

It's weird because /tmp is a public directory, so you should have access to it.

Make sure you haven't mounted a volume on /tmp.

Otherwise, you can try to modify the Dockerfile to use another directory, like /home/your_user/tmp.

# run iris and initial 
RUN iris start IRIS \
	&& iris session IRIS < /opt/irisapp/iris.script \
	&& iris stop IRIS quietly
Guillaume Rongier · Jan 29, 2025 go to post
import iris

GLOBAL_QUEUE = iris.gref("Ens.Queue")

def get_list_host_queue() -> dict:
    dict_queue = {}
    for composed_key, v in GLOBAL_QUEUE.query():
        host = composed_key[0]
        if host not in dict_queue:
            try:
                dict_queue[host] = v if composed_key[2] == 'count' else None
            except IndexError:
                dict_queue[host] = None
    return dict_queue

if __name__ == "__main__":
    print(get_list_host_queue())
    
# {'Ens.Actor': 0, 'Ens.Alarm': 0, 'Ens.ScheduleHandler': 0, 'EnsLib.Testing.Process': 0, 'Python.MyAsyncNGBO': 10, 'Python.MyAsyncNGBP': 0, 'SystemSignal:29404': 0, '_SyncCall:29420': 0}

Try some thing like that

Guillaume Rongier · Jan 24, 2025 go to post

Thanks @Dmitry Maslennikov , once again you make things clear. What we do today and what can be improve, i hope, other can have a look at this study and understand the value of such feedback.

Guillaume Rongier · Jan 22, 2025 go to post

As Robert said it's because of the list build serialization.

You can give a try to :

https://pypi.org/project/iris-dollar-list/

which is an list build parser in python :

from iris_dollar_list import DollarList

dollar_list_str = b'\x1B\x01SERVERA.FOO.BAR.ORG/STAGE\x1A\x01SERVERA.foo.bar.org|2188\t\x01Primary\x08\x01Active\x13\x01172.31.33.69|1972\x1A\x01SERVERA.foo.bar.org|1972'
dollar_list = DollarList(dollar_list_str)
print(dollar_list)

## $lb("SERVERA.FOO.BAR.ORG/STAGE","SERVERA.foo.bar.org|2188","Primary","Active","172.31.33.69|1972","SERVERA.foo.bar.org|1972")
Guillaume Rongier · Jan 16, 2025 go to post
>>> import iris
>>> mirror=iris.cls('SYS.Mirror')
>>> pri_ref = iris.ref(None)
>>> alt_ref = iris.ref(None)
>>> sc=mirror.GetFailoverMemberStatus(pri_ref,alt_ref)
>>> pri_ref.value
>>> alt_ref.value

Something like this should work

Guillaume Rongier · Dec 18, 2024 go to post

I'm using it all the time for string and i haven't seen any performance issue so far.

May be try to increase the buffer :

def stream_to_string(stream,buffer=1000000)-> str:
    string = ""
    stream.Rewind()
    while not stream.AtEnd:
        string += stream.Read(buffer)
    return string
Guillaume Rongier · Dec 9, 2024 go to post

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")
Guillaume Rongier · Dec 7, 2024 go to post

wow, nice article, can you provide more information about how you register this python class into a production ?

for the more, can you tell me what is the difference between embedded python and irisnative, i'm a bit confused.

Guillaume Rongier · Nov 4, 2024 go to post

did you try to put thoses var env :

export IRISUSERNAME=...
export IRISPASSWORD=...
export IRISNAMESPACE=...
Guillaume Rongier · Oct 15, 2024 go to post

You can use your default python/pip but it needs more works (setup BYOP (bring your on python), make sure that your current user has suffisant privilege to run irisdb, make use of virtual environnement, fix some C library path)

Guillaume Rongier · Oct 14, 2024 go to post

Your version of numpy is not compatible with python3.9.

Try to reinstall it with irispython :

irispython -m pip install --target C:\InterSystems\IRIS\mgr\python numpy
Guillaume Rongier · Sep 13, 2024 go to post

Great articles. Thanks for sharing.

Why are you using Language Tag and not "pure" python script ? It's so much convient to work with native python script than python code in cls classes.

Guillaume Rongier · Sep 3, 2024 go to post

Hi,

If i remember correctly, the default behavior of the to_sql method is to use a transaction to insert the data.

What i do is using with statement to ensure that the transaction is commited and closed after the insert:

with engine.connect() as conn:
    train_df.to_sql(name='table1', con=conn, if_exists='replace', index=False)

Otherwise, you can commit the transaction manually:

conn = engine.connect()
train_df.to_sql(name='table1', con=conn, if_exists='replace', index=False)
conn.commit()
conn.close()

That's what i do, hope it helps.

Guillaume Rongier · Aug 29, 2024 go to post

Here, those scripts are embedded python script, which are different from python script.

For whatever reason, embedded python iris module is called iris and official driver is also called iris from this wheel intersystems_irispython-3.2.0-py3-none-any.whl.

This create confusion and package collision, an community edition exist that solve this issue and allow you to use them both, you can install it from here : https://github.com/intersystems-community/intersystems-irispython

Another option is to use the iris wrapper : https://pypi.org/project/iris-embedded-python-wrapper/

Works well on macos, and i'm looking for feedback on windows machines.

Guillaume Rongier · Aug 29, 2024 go to post

Hi,

My bet is that you are using web server port 52773 instead of 1972

Try this :

import iris

# Open a connection to the server
args = {'hostname':'127.0.0.1', 'port':1972,
    'namespace':'USER', 'username':'_SYSTEM', 'password':'SYS'
}

try:
    conn = iris.connect(**args)
    # Create an iris object
    irispy = iris.createIRIS(conn)
except Exception as e:
    # Handling the exception and printing the error
    print(f"An error occurred: {e}")
Guillaume Rongier · Jul 29, 2024 go to post

Thanks for this feedback, this is very helpful for our implementation of WSGI/ASGI. As you can see it's still a work in progress, but we are working hard to make it better.

We will have a look at the cookie issue, we encountered it as well, but we haven't gone deep into it yet as you did. Your feedback will help us, thanks again.

For the ASGI Post issue, it's also a known issue, that will be fixed in the next release.

We also plan to add more features to the WSGI/ASGI implementation, like the ability to reload the server with a button click/a command line.

We will have a look also at the WebSockets support.

Guillaume Rongier · Jul 11, 2024 go to post

Hi @ala zaalouni,

When you encounter this error :

The error appears: "An error has occurred: iris.cls: error finding class"

This usually mean that the Iop framework is not loaded into iris.

pip install iris-pex-embedded-python

you must init it to iris (install the associated classes to iris), for that you must do :

iop --init

or

from iop import Utils
Utils.setup()

please refer to the documentation :

https://github.com/grongierisc/interoperability-embedded-python?tab=readme-ov-file#32-with-pypi

For the more, make sure you are on the right namespace by specifying the var env : $IRISNAMESPACE

Guillaume Rongier · May 15, 2024 go to post

I would try something like this :

ClassMethod "test_dict"()
{
    set pythonObj = ##class(%SYS.Python).Bytes("toto")

    set dict = ##class(%SYS.Python).Builtins().dict()
    do dict."__setitem__"("my_bytes", pythonObj)

    w !, dict."__getitem__"("my_bytes")
}
Guillaume Rongier · May 13, 2024 go to post

Great application, do you know that iris now support wsgi app : https://docs.intersystems.com/iris20241/csp/docbook/Doc.View.cls?KEY=AWSGI

For the more, you did a pretty good job with a python only app, can you have a look at this one and tell me if you wish to learn more about Iop (Interoperability on python, the backend framework of this app): https://community.intersystems.com/post/vector-search-and-rag-retrieval-augmented-generation-models

Guillaume Rongier · Apr 11, 2024 go to post

For this given python function :

file name demo.py

def return_tuple():
    return 1, 2, 3

To retrieve the values in ObjectScript, you can use the following code, basically use dunder methods to access the values.

set return = ##class(%SYS.Python).Import("demo")."return_tuple"()
write return."__len__"() // 3
write return."__getitem__"(0) // 1
write return."__getitem__"(1) // 2
write return."__getitem__"(2) // 3
Guillaume Rongier · Mar 27, 2024 go to post

Hi Rob,

This is indeed very impressive result.

I do have a dumb question, why are you using your superserver port called mgsi instead of the default one provided by IRIS?