#Python

8 Followers · 477 Posts

Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, Python has a design philosophy that emphasizes code readability, notably using significant whitespace

Official site.

InterSystems Python Binding Documentation.

Article Alberto Fuentes · Jan 29, 2024 12m read

We have a yummy dataset with recipes written by multiple Reddit users, however most of the information is free text as the title or description of a post. Let's find out how we can very easily load the dataset, extract some features and analyze it using features from OpenAI large language model within Embedded Python and the Langchain framework.

Loading the dataset

First things first, we need to load the dataset or can we just connect to it?

There are different ways you can achieve this: for instance CSV Record Mapper you can use in an interoperability production or even nice OpenExchange appl

image

3
2 441
Article Nicole Raimundo · May 15, 2024 9m read

DNA Similarity and Classification was developed as a REST API utilizing InterSystems Vector Search technology to investigate genetic similarities and efficiently classify DNA sequences. This is an application that utilizes artificial intelligence techniques, such as machine learning, enhanced by vector search capabilities, to classify genetic families and identify known similar DNAs from an unknown input DNA.

K-mer Analysis: Fundamentals in DNA Sequence Analysis

Fragmentation of a DNA sequence into k-mers is a fundamental technique in genetic data processing. This approach involves break

2
1 426
Article José Pereira · May 14, 2024 11m read

TL;DR

This article introduces using the langchain framework supported by IRIS for implementing a Q&A chatbot, focusing on Retrieval Augmented Generation (RAG). It explores how IRIS Vector Search within langchain-iris facilitates storage, retrieval, and semantic search of data, enabling precise and up-to-date responses to user queries. Through seamless integration and processes like indexing and retrieval/generation, RAG applications powered by IRIS enable the capabilities of GenAI systems for InterSystems developers.

A notebook and a complete Q&A chatbot application using the topics discussed

Retrieved result for query about task decomposition downsides

3
3 557
Question Stephane Devin · May 15, 2024

Hi, I need to use some pythonic library from cos.
To use them I need a python dict with some python object in it
Ex in python:

obj = pythonObject("value1")
dict = {object : obj  ,key : "value2"}
result = pythonFunc(dict)

To do that I first tried to pass by dynamic object, to later convert them in dict from Json. But unfortunately the dynamic object doesn't accept python object inside it. And my pythonic function need to have an instance of my python object.
So I tried with the python built-in function dict() to create a python dictionary, but I'm not sure how to use it as in the python docume

2
0 199
Discussion Yone Moreno · May 15, 2024

Hello,

I would like you to propose this challenge.

It has been created by the CodeWars community here: https://www.codewars.com/kata/6523a71df7666800170a1954/python

I will copy and paste the description:

🔡🟢 DESCRIPTION:

A number is Esthetic if, in any base from base2 up to base10, the absolute difference between every pair of its adjacent digits is constantly equal to 1.

num = 441 (base10)
// Adjacent pairs of digits:
// |4, 4|, |4, 1|
// The absolute difference is not constant
// 441 is not Esthetic in base10

441 in base4 = 12321
// Adjacent pairs of digits:
// |1, 2|, |2, 3
4
0 198
Article xuanyou du · May 11, 2024 1m read

Principle: After dividing the article uploaded by the user into sentences using Python, the embedded value is obtained and stored in the Iris database. Then, the similarity between sentences is compared through Iris vector search, and finally displayed on the front-end page.

The installation steps can be viewed in the readme file. It should be noted that the BERT model used in the example has some memory requirements. If there is a long-term stuck situation during the testing process, other models such as MiniLM (which is used in the online demo) can be considered. Note that if using other mo

0
1 223
Announcement Olga Zavrazhnova · Apr 9, 2024

Hi Developers,

Join us at the upcoming Developer Roundtable on April 25th at 9 am ET | 3 pm CET. 📍
We will have 2 topics covered by the invited experts and open discussion as always.

Tech Talks:
➡ Practical Usage of Embedded Python - by Stefan Wittmann Product Manager, InterSystems

▶ Recording: 

 

1
0 238
Article Alex Woodhead · Mar 24, 2024 8m read

BPL from 10,000 feet

BPL stands for Business Process Language.
This is an XML format for describing complex information orchestration interactions between systems.
InterSystems Integration engine has for two decades, provided a visual designer to build, configure, and maintain, BPL using a graphical interface.
Think of it like drawing a process flow diagram that can be compiled and deployed.

An example: Make a cup of tea

BPL components are added to Integration productions like any other built-in or custom business component.

Test example input and output

There can be a mixed reception















4
0 552
Article Robbie Luman · Jan 12, 2024 7m read

With the advent of Embedded Python, a myriad of use cases are now possible from within IRIS directly using Python libraries for more complex operations. One such operation is the use of natural language processing tools such as textual similarity comparison.

Setting up Embedded Python to Use the Sentence Transformers Library

Note: For this article, I will be using a Linux system with IRIS installed. Some of the processes for using Embedded Python with Windows, such as installing libraries, may be a bit different from Linux to Windows so please refer to the IRIS documentation for the prope

4
4 704
Announcement Evgeny Shvarov · Apr 18, 2024

Hi Developers!

Here're the technology bonuses for the InterSystems Vector Search, GenAI, and ML contest 2024 that will give you extra points in the voting:

  • Vector Search usage - 5
  • IntegratedML usage - 3
  • Embedded Python - 3
  • LLM AI or LangChain usage: Chat GPT, Bard, and others - 3
  • Questionnaire - 2
  • Docker container usage - 2 
  • ZPM Package deployment - 2
  • Online Demo - 2
  • Implement InterSystems Community Idea - 4
  • Find a bug in Vector Search, or Integrated ML, or Embedded Python - 2
  • First Article on Developer Community - 2
  • Second Article On DC - 1
  • First Time Contribution - 3
  • Video on YouTube - 3
  • Suggest a new idea - 1

See the details below.<--break-><--break->

0
0 362
Question Pietro Di Leo · Apr 17, 2024

Hello everybody, 

I've been experimenting with Embedded Python and have been following the steps outlined in this documentation: https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cl…

I'm trying to convert a python dictionary into an objectscript array but there is an issue with the 'arrayref' function, that is not working as in the linked example.

This is a snapshoot of my IRIS terminal: 

USER>do##class(%SYS.Python).Shell()

Python 3.10.12 (main, Nov 202023, 15:14:05) [GCC 11.4.0] on linux
Type quit() or C
2
1 272
Question Stephane Devin · Apr 10, 2024

Hi,

I am using embeded python to utilize some pythonic library but i got a problem on my hand.
One of the python function i am using return multiple values

in python you would do something like that :

val1, val2, val3, = function(params)

In COS I got something like that :

lib = ##class(%SYS.Python).Import("lib")
val1 = lib.function(params)

And I don't know how to get the second and third values.
Is there a way to get them?

5
1 288
Announcement Laurel James (GJS) · Apr 5, 2024

Visual Studio Code releases new updates every month with new features and bug fixes, and the March 2024 release is now available. 

0
0 395
Question August Turano · Apr 1, 2024

After running many tests to kick the tires calling Python from COS (which worked fine) in any directory,  I encountered problems when trying to access Python libraries like Numpy from any OTHER namespace.   I saw some other posts about this but the resolution seems unclear.   When I run the test program method numpytest below in %SYS it works just fine.  If i run the Python method in any other namespace I get: 

PITT>do ##class(test.python).numpytest()
DO ##CLASS(test.python).numpytest()
^
<OBJECT DISPATCH> *python object not found

Here is the test program - i did the install with IRISPIP on pan

4
0 202
Question Kim Trieu · Mar 26, 2024

Using VECTOR_COSINE() in SQL query to perform a text similarity search on existing embeddings in a %VECTOR column.

Code is below.

Commented out sql query returns this error: SQLCODE: -29  Field 'NEW_EMBEDDING_STR' not found in the applicable tables^ SELECT TOP ? maxID , activity , outcome FROMMain .AITest ORDER BY VECTOR_COSINE ( new_embedding_str ,

Sql query as written returns ERROR #5002: ObjectScript error: <PYTHON EXCEPTION> *<class 'OSError'>: isc_stdout_write: PyArg_ParseTuple failed!

Table column properties:

Property MaxID As %Integer;

Property Activity As %String(MAXLEN = "")
10
0 302
Question Adrian Maguire · Feb 18, 2022

Hi, I am trying to use embedded python in a cache class, but I can only get it to work in the source code namespace.

We map our client namespaces to our source code namespaces using Default Database for Routines under System > Configuration > Namespaces > Edit Namespace in the management portal.

In the source code namespace:

SOURCENEW>w ##class(EF.helloWorld).helloWorldPython()

Hello World!

SOURCENEW>ZN "EVEXAMPLE"

In the client namespace:

EVEXAMPLE>w ##class(EF.helloWorld).helloWorldPython()

W ##CLASS(EF.helloWorld).helloWorldPython()

^

<OBJECT DISPATCH> *python object not found

W

3
2 592
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

3
6 512
Question Wanbo Wang · Mar 2, 2024

Hi all,

Does anybody have the same issue?

$ZF(-100) to run python script not work when directly execute in studio or in storedproc called by TrakCare, but can work when do in iris session.

The python script imports a "barcode" package. It seems that when directly execute in studio or in storedproc called by TrakCare, the package can not be imported.

sr = $ZF(-100,"/SHELL", "/usr/bin/python3.9","/trak/cnpubase/tc/webfiles/web/custom/CNPU/script/py/barcode/genslbarcodetest.py",keyStr,path)
import sys
import barcode
from barcode.writer import ImageWriter
spn=sys.argv[1]
name=sys.argv[2]
2
0 250
Announcement Laurel James (GJS) · Feb 29, 2024

Visual Studio Code releases new updates every month with new features and bug fixes, and the February 2024 release is now available. 

Version 1.87 includes: 

0
0 440
Question Lowell Buschert · Feb 25, 2024

I am sending an httpRequest from ObjectScript to a python server.   I am not receiving a response in OS
 
OS config On the client side

// Create an HTTP request object
    Set httpRequest = ##class(%Net.HttpRequest).%New()
    
    // Set the server URL
    Set httpRequest.Server = "http://127.0.0.1:8080"
    
    // Set content type to JSON
    Set httpRequest.ContentType = "application/json"

    // Clear any existing entity body"{""name"": ""Lowell Buschert"", ""dob"": ""1970-12-09"", ""address"": ""XXXXX""}"
    do httpRequest.EntityBody.Clear()
    //Set httpRequest.EntityBody = "{""name"": ""Lowel

5
1 276
Article Heloisa Paiva · Feb 6, 2024 7m read

Introduction

Not so long ago, I came across the idea of using Python Class Definition Syntax to create IRIS classes on the InterSystems Ideas Portal. It caught my attention since integrating as many syntaxes as possible gives visibility to InterSystems’s products for programmers with experience in many languages.

The author of that idea pointed out the possibility of creating classes using Python’s syntax, in addition to the currently available ones on IRIS. This concept inspired me to write this article, exploring the possibilities of accessing the full InterSystems power employing only Pyt

3
0 595
Article Sylvain Guilbaud · Feb 1, 2024 5m read

Hello Community,

SQL language remains the most practical way to retrieve information stored in a database.

The JSON format is very often used in data exchange.

It is therefore common to seek to obtain data in JSON format from SQL queries.

Below you will find simple examples that can help you meet this need using ObjectScript and Python code.

ObjectScript : using Dynamic SQL with %SQL.StatementJSON structures with %DynamicObject and %DynamicArray

ClassMethod getJSON() As%String
{
    // declaration of an SQL queryset query = "SELECT top 3 name,age,to_char(dob,'Day DD Month YY
1
4 567
Article Vadim Aniskin · Jan 31, 2024 3m read

Django, a high-level web framework written in Python, has become a staple for developers seeking a robust, efficient, and easy-to-learn solution for building web applications. Its popularity stems from its versatility, offering developers an efficient toolkit for building web applications. Integrating Django with InterSystems IRIS introduces a dynamic synergy, providing developers with a comprehensive web development and database management solution. That's why on the Ideas Portal, @Evgeny Shvarov suggested that having Examples to work with IRIS from Django would be beneficial. In this article, we'll explore two projects created to answer the posted idea — Django-iris by @Dmitry Maslennikov and Iris-size-django by @Heloisa.Paiva.

      

0
2 388
Question Weston Willett · Jan 2, 2024

Using the below python script I am getting : 

$ ./hello_world.py 
Traceback (most recent call last):
  File "/home/wwillett/dev/vscode-objectscript/Samples-python-helloworld/./hello_world.py", line 34, in <module>
    run()
  File "/home/wwillett/dev/vscode-objectscript/Samples-python-helloworld/./hello_world.py", line 21, in run
    connection = irisnative.createConnection(ip, port, namespace, username, password)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: * [ERROR_SEQUENCE_ERROR]

I have verified that the Gateway is running.

I don't know wha

2
0 213
Article Muhammad Waseem · Jan 9, 2024 9m read

  Hi, Community!

Since this article is an overview of Flask Login, let's begin with Flask Introduction!

What is Flask?

In the realm of web development, Python has emerged as a formidable force, offering its versatility and robustness to create dynamic and scalable applications. For that reason, tools and services compatible with this language are in demand these days. Flask is a lightweight and easy-to-use web framework for Python. It stands out as a lightweight and user-friendly option. Its simplicity and flexibility have made it a popular choice for developers, particularly for creating smaller-scale applications. It is based on the Werkzeug toolkit and provides a simple but powerful API for building web applications. 
Unlike its full-stack counterparts, Flask provides a core set of features, focusing on URL routing, template rendering, and request handling. This minimalist approach makes Flask lightweight and easy to learn, allowing developers to build web applications quickly and without the burden of unnecessary complexity.

0
1 1949
Article Luis Angel Pérez Ramos · Dec 29, 2023 6m read

It seems like yesterday when we did a small project in Java to test the performance of IRIS, PostgreSQL and MySQL (you can review the article we wrote back in June at the end of this article). If you remember, IRIS was superior to PostgreSQL and clearly superior to MySQL in insertions, with no big difference in queries.

Well, shortly after @Dmitry Maslennikov told me "Why don't you test it from a Python project?" Well, here is the Python version of the tests we previously performed using the JDBC connections.

First of all, let you know that I am not an expert in Python, so if you see anythin

6
3 1003
Article Heloisa Paiva · Sep 22, 2022 4m read

Here you'll find a simple program that uses Python in an IRIS environment and another simple program that uses ObjectScript in a Python environment. Also, I'd like to share a few of the troubles I went trough while learning to implement this.

Python in IRIS environment

Let's say, for example, you're in an IRIS environment and you want to solve a problem that you find easy, or more efficient with Python.

You can simply change the environment: create your method as any other, and in the end of it's name and specifications, you add [ Language = python ]:

You can use any kinds of argum

9
5 2407
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.

3
2 1132