Ashok Kumar T · Jan 13, 2025 go to post

Hello @omer 

The above same is ACID complaint when using transactions. It will be reverted  to old value under transaction rollback. However, The counter values are incremented by  $Increment and $Sequence are will not changed even rollback.

LEARNING>w ^myTracker("onSomething")
1
LEARNING>ts
 
TL1:LEARNING>s ^myTracker("onSomething")=12
 
TL1:LEARNING>w ^myTracker("onSomething")
12
TL1:LEARNING>trollback
 
LEARNING>w ^myTracker("onSomething")
1
LEARNING>

$Increment and $sequence

LEARNING>write ^myTracker("onSomething")
1
LEARNING>tstart
 
TL1:LEARNING>do $Increment(^myTracker("onSomething"))
 
TL1:LEARNING>write ^myTracker("onSomething")
2
TL1:LEARNING>trollback
 
LEARNING>write ^myTracker("onSomething")
2
LEARNING>
Ashok Kumar T · Dec 16, 2024 go to post

Hello @Yaron Munz 
I've enabled the "%System/%Login/JobEnd" in Audit events. I opened a new terminal(new process) and I terminate the process via Management portal. However, I haven't seen any entry in the Audit log. 

Ashok Kumar T · Dec 12, 2024 go to post

:clear deletes all the commands in that particular process/recall buffer. If you open another terminal and :history shows all commands. So, I thought some native commands exist like :clear to delete the commands history permanently. 

!del %USERPROFILE%\.iris_history - yes, we can the use the file system commands.

Thanks!

Ashok Kumar T · Dec 12, 2024 go to post

Thanks Chris, It works. However, There is no command to do it from terminal itself?

Ashok Kumar T · Dec 11, 2024 go to post

Thanks for pointing the solution. By using this integer we can get the request if test is 1or response test=2 or test = 3 headers. However, As of my understanding we didn't get both request and response at the same time.

Ashok Kumar T · Dec 11, 2024 go to post

Thanks for the code samples. my expectation is to convert the %Net.HttpRequest to Http request standard message structure. Actually Mr @Jeffrey Drumm gives me the expected solution. The Http Get , Post methods has the second parameter "test" it helps me to get that standard http message string

Ashok Kumar T · Dec 11, 2024 go to post

Hello @Enrico Parisi 

I'm expect/built in method to generate the below HTTP request and HTTP response from %Net.HttpRequest. which was shown in the "View HTTP Trace" option in web gateway.

POST /aktest/test HTTP/1.1
Content-Type: application/fhir+json
Accept: */*
Host: localhost:52773
Accept-Encoding: gzip, deflate, br
Content-Length: 21

{ "asd":"asd" }
Ashok Kumar T · Nov 21, 2024 go to post

Are you able to set those Status and HTTPheaders straight into the instance of EnsLib.HTTP.GenericMessage in your code. like below

Set httpGeneric = ##Class(EnsLib.HTTP.GenericMessage).%New() ; this was already initiated in your business host via code.
set att("Status")=..#HTTP400BADREQUEST
do httpGeneric.SetAttributes(.att)
set httpHeader("ContentType")="application/json"
set httpHeader("totalcount")=totalcount
do httpGeneric.SetHTTPHeaders(.httpHeader)
Ashok Kumar T · Nov 6, 2024 go to post

Hello @Enrico Parisi 

I just a generated text by executing this  set data="" for i=1:1:400 set data=data_"a"_i and it's 1492 characters long and it's not other JPEG or other file formats. But this text is not compressed. However, If I use random text/place holder text more than 1500 characters and that text was compressed automatically.

Ashok Kumar T · Sep 19, 2024 go to post

You're right. I just add as a sample. There is no direct end of month option to execute. Just select monthly and 1 to 31 dates or 1st to 5th week option. If really go with schedule option then follow your below code

Ashok Kumar T · Sep 19, 2024 go to post

Hello Warren,

You can use "Schedule Specifications" in production to schedule running your business host. First select your business host(service) and go to additional setting and check "Schedule" option click the magnifier. It opens the "Schedule Spec Editor" and create your schedule ex: "monthend_9to930" and click add action. Then select START and STOP action this action is basically "action:YYYY-MM-DDThh:mm:ss" . Refer the below sample and documentation

START *-*-31T09:00:00
STOP *-*-31T09:30:00

Note: this is suitable only for 31 days of month

Ashok Kumar T · Sep 13, 2024 go to post

anyway when I keep my native python scripts under "IRISinstalldirectory\mgr\python" and import my code as module and it's working because it's running inside the IRIS not using the python "driver" 

ClassMethod CallPyscripts()
{
    set ap = "mypyap"
    set pyImport = ##class(%SYS.Python).Import(ap)
    set builtin = $SYSTEM.Python.Builtins()
    do builtin.help(pyImport)
    write pyImport.irisversion,!
    write pyImport."Execute_Classmethod1"()
}
#__init__.py
import iris
from .irisembdpyth2024 import *

irisversion = iris.execute('return $zv')

# irisembdpyth2024.py file
import iris

def Execute_Classmethod1():
    print(iris.cls('MyLearn.EmbeddedPython').test1())
Ashok Kumar T · Sep 13, 2024 go to post

Hello @Guillaume Rongier

Thanks for the feedback! I go over your pretty useful article. I just write python code inside the ObjectScript itself by using language mode because of it's small code snippets. I actually facing some issues while writing IRIS in native python script.

From my pervious community question. First I install this intersystems_irispython-3.2.0-py3-none-any.whl in python and there is no cls, execute, routine, gref, ref or other IRIS script functions available.

As you recommend from the post. I install the official driver  https://github.com/intersystems-community/intersystems-irispython/releases/download/3.8.0/intersystems_iris-3.8.0-py3-none-any.whl file and I could use the IRIS functions for embedded python cls, execute, routine, gref, ref etc...

However, I got this ImportError: DLL load failed while importing pythonint: The specified module could not be found." error while executing the .py scripterror while executing my script

script is nothing but simple class method invocation.

import iris
def Execute_Classmethod():
    print(iris.cls('MyLearn.EmbeddedPython').test1())

Execute_Classmethod()
 
Ashok Kumar T · Aug 29, 2024 go to post

And I'm trying to execute these lines from post  and git in to my .py source file. This functions are not available in iris library package.So, Is this code snippet is only applicable for embedded python. Please correct me If I'm doing wrong

If the below syntax works in python source file, What changed I need to do in my package.

    # switch namespace to the %SYS namespace
    iris.system.Process.SetNamespace("%SYS")

    # set credentials to not expire
    iris.cls('Security.Users').UnExpireUserPasswords("*")

    print(iris.cls('dc.python.ObjectScript').Test())

Thanks!

Ashok Kumar T · Aug 28, 2024 go to post

Hello @Raj Singh 

Certainly. There is no issue in the python installation in my different machine (windows).  I'm using my IRIS local instance to connect in both. No major difference except the port number and I'm using the super server port number in both cases. 

Ashok Kumar T · Aug 28, 2024 go to post

Thanks @Luis Angel Pérez Ramos 

It works. I downloaded and installed in python. However I got timeout error while trying to connect the IRIS in one machine  and it works in another machine. IDK pyodbc is required anyway it is also installed.

import iris

# Open a connection to the server
args = {'hostname':'127.0.0.1', 'port':52773,
    '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}")

error mesage

    conn = iris.connect(**args)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\iris\_IRISNative.py", line 167, in connect
    connection._connect(hostname, port, namespace, username, password, timeout, sharedmemory, logfile, sslcontext, autoCommit, isolationLevel, featureOptions)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\iris\_IRISConnection.py", line 282, in _connect
    raise e
  File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\iris\_IRISConnection.py", line 190, in _connect
    self._in_message._read_message_sql(sequence_number)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\iris\_InStream.py", line 46, in _read_message_sql
    is_for_gateway = self.__read_message_internal(expected_message_id, expected_statement_id, type)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\iris\_InStream.py", line 59, in __read_message_internal
    self.__read_buffer(header.buffer, 0, iris._MessageHeader._MessageHeader.HEADER_SIZE)
  File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\iris\_InStream.py", line 133, in __read_buffer
    data = self._device.recv(length)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HP\AppData\Local\Programs\Python\Python312\Lib\site-packages\iris\_Device.py", line 40, in recv
    return self._socket.recv(len)
           ^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out

Thanks!

Ashok Kumar T · Aug 5, 2024 go to post

Hello @Tommy.Heyding 

Thank you for pointing ToList in %SYS.Python It works for $LIST only not for the dynamicarray. Yes I believe the same convert the dynamic array to $LIST and send to the python. I grab the sample from doc

set clist = $lb(123, 456.789, "hello world")
set plist = ##class(%SYS.Python).ToList(clist)
Ashok Kumar T · Jul 29, 2024 go to post

Hello,

Have you tried use the record map persistent class directly in the DTL as a source class and use SDA class as Target class. I use Allergy SDA for sample.

DTL sample

Record mapping