#Beginner

0 Followers · 499 Posts

Beginner tag unites articles and questions for those who are getting started with InterSystems Data Platform

InterSystems staff + admins Hide everywhere
Hidden post for admin
Question Niccolò Predebon · Nov 19, 2019

Hi everyone. I'm new to cache, and i  was looking for a command who reads a .txt file and store the informations in variables. I've found on the documentation the EnsLib.SQL.SNapshot class, and, even if i'm not sure if that's what i need, when i run the code it says that the class doesn't exist, but i couldn't find the right superclass to extend.

3
0 562
Question Flávio Lúcio Naves Júnior · Oct 21, 2019

Hello Everyone,

I'm want to know, what is more common for your company to use, the abbreviation syntax or the complety name of commands, and why?

Ex. 

S VAR=10 / D FUNC^ROUTINE F 1:1:1000

Set VAR=10 / Do Func^Routine / For 1:1:1000

set var=10 / do func^routine / for 1:1:1000

Here in my company, we are familiar with the abbreviation syntax, because to spell is more faster.

35
0 1117
Article Evgeny Shvarov · Sep 14, 2019 1m read

Hi Developers!

Often I find questions on how to install IRIS, connect to IRIS from IDE, setup the environment, compile, debug, maintain the repository.

Here below possibly the shortest way to set up all the environment and start development with ObjectScript on InterSystems IRIS.

Prerequisites

Make sure you have Git, Docker, and VSCode installed

Install Docker and ObjectScript extensions into VSCode

Sign in or Create an account on Github

Here we go!

9
6 1543
Question Ignacio Valdes · Nov 14, 2019

I want to edit this routine to replace "Cache" with "IRIS" how do I do that in Intersystems Google Cloud environment?  The portal  System > Routines  doesn't seem to show much. 

RPMS>ZL %RCR ZP

DIRCR    ;SFISC/GFT-DELETE THIS LINE AND SAVE AS '%RCR'*** ;12:18 PM  20 Apr 1993 [ 04/02/2003   8:23 AM ]

         ;;22.0;VA FileMan;**1001**;APR 1, 2003

         ;;22.0;VA FileMan;;Mar 30, 1999

         ;THIS ROUTINE CONTAINS AN IHS MODIFICATION BY IHS/MFD

         ;Per VHA Directive 10-93-142, this routine should not be modified.

%RCR     ;GFT/SF

         ;

STORLIST ;

         ;----- BEGIN IHS MODIFICATION

19
0 471
Announcement Michelle Spisak · Oct 22, 2019

The Learning Services Online Learning team has posted new videos to help you learn the benefits of InterSystems IRIS. Take a peek to see what you stand to gain from making the switch to InterSystems IRIS!

Why Multi-Model?
Stefan Wittmann presents use cases for the multi-model data access of InterSystems IRIS data platform. He shows the multi-model architecture that allows you to use the data model that best fits each task in your application — relational, object, or even direct/native access — all accessible through the language of your choice.

0
0 222
Article Eduard Lebedyuk · Oct 10, 2019 7m read

This series of articles would cover Python Gateway for InterSystems Data Platforms. Execute Python code and more from InterSystems IRIS. This project brings you the power of Python right into your InterSystems IRIS environment:

  • Execute arbitrary Python code
  • Seamlessly transfer data from InterSystems IRIS into Python
  • Build intelligent Interoperability business processes with Python Interoperability Adapter
  • Save, examine, modify and restore Python context from InterSystems IRIS

Other articles

The plan for the series so far (subject to change).

Intro

You now have Python gateway installed and validated that it works, time to start using it! In this article I would cover the main interface to Python, which is isc.py.Main. It offers these methods (all return %Status), which can be separated into

  • Code execution
  • Data Transfer
  • Auxiliary

Code execution

These methods allow execution of arbitrary Python code.

SimpleString

SimpleString is the main method. It accepts 4 optional arguments:

  • code - string of code to execute. Separate several lines with $c(10).
  • returnVariable - name of a variable to return.
  • serialization - how to serialize returnVariable. 0 - string serialization (default), 1 - repr serialization.
  • result - pass variable by reference. returnVariable is written into it.

Here's an example:

set sc = ##class(isc.py.Main).SimpleString("x='HELLO'", "x", , .var)

In this example we assign Python variable x value Hello and we want to return Python x variable into ObjectScript var variable.

ExecuteCode

ExecuteCode is a safer alternative to SimpleString without SimpleString limitations. Strings are limited by 3 641 144 characters, and if you want to execute a longer piece of code you need to use streams. It accepts two arguments:

  • code - string or stream of Python code to execute.
  • variable - (optional) set result of code execution into this Python variable.

Here's how to use it:

set sc = ##class(isc.py.Main).ExecuteCode("2*3","y")

In this example we multiply 2 by 3 and write the result into Python y variable.

Data Transfer

Transfer data into and from Python.

Python -> InterSystems IRIS

There are 4 ways to get variable value from Python to InterSystems IRIS, depending on the serialization you need:

  • String for simple datatypes and debugging.
  • Repr for storage of simple objects and debugging.
  • JSON for easy maipulation of data on InterSystems IRIS side.
  • Pickle for persisting objects.

These methods allow getting variables from Python as string or streams.

  • GetVariable(variable, serialization, .stream, useString) - get serialization of variable in stream. If useString is 1 and variable serialization can fit into string then string is returned instead of the stream.
  • GetVariableJson(variable, .stream, useString) - get JSON serialization of variable.
  • GetVariablePickle(variable, .stream, useString, useDill) - get Pickle (or Dill) serialization of variable.

Let's try to get our y variable.

set sc = ##class(isc.py.Main).GetVariable("y", , .val, 1)
w val
>6

InterSystems IRIS -> Python

And finally let's load some data into Python from InterSystems IRIS.

  • ExecuteQuery(query, variable, type, namespace) - create resultset (pandas dataframe or list) from sql query and set it into variable. isc.py package must be available in namespace.
  • ExecuteGlobal(global, variable, type, start, end, mask, labels, namespace) - transfer global data (from start to end) to Python variable of type: list of tuples or pandas dataframe. For mask and labels arguments specification check class docs and Data Transfer docs.
  • ExecuteClass(class, variable, type, start, end, properties, namespace) - transfer class data to Python list of tuples or pandas dataframe. properties - comma-separated list of properties to form dataframe from. * and ? wildcards are supported. Defaults to * (all properties). %%CLASSNAME property is ignored. Only stored properties can be used.
  • ExecuteTable(table, variable, type, start, end, properties, namespace) - transfer table data to Python list of tuples or pandas dataframe.

ExecuteQuery is universal (any valid SQL query would be transfered into Python). ExecuteGlobal and its wrappers ExecuteClass and ExecuteTable, however, operate with a number of limitations. But they are much faster (3-5 times faster than ODBC driver and 20 times faster than ExecuteQuery). More information in Data Transfer docs. All these methods support data transfer from any local namespace. isc.py package must be available in namespace.

ExecuteQuery

ExecuteQuery(query, variable, type, namespace) - transfer results from any valid SQL query into Python. It is the slowest method of data transfer. Use it if ExecuteGlobal and its wrappers are unavailable.

Arguments:

  • query - sql query
  • variable - target variable on a Python side
  • type - list or Pandas dataframe

ExecuteGlobal

ExecuteGlobal(global, variable, type, start, end, mask, labels, namespace) - transfer global data to Python.

Arguments:

  • global - global name without ^
  • variable - target variable on a Python side
  • type - list or Pandas dataframe
  • start - initial global key. Must be integer.
  • end - final global key. Must be integer.
  • mask - string, mask for global values. Mask may be shorter than the number of global value fields (in this case fields at the end would be skipped). How to format mask:
    • + use field as is
    • - skip field
    • b - boolean (0 - False, anything else - True)
    • d - date (from $horolog, on Windows only from 1970, on Linux from 1900 see notes for details)
    • t - time ($horolog, seconds since midnight)
    • m - (moment) timestamp string in YEAR-MONTH-DAY HOUR:MINUTE:SECOND format.
  • labels - %List of column names, first element is key column name. Therefore: List length must be mask symbol length + 1.

ExecuteClass

Wrapper for ExecuteGlobal. Effectively it parses compiled class definition, constructs ExecuteGlobal arguments and calls it.

ExecuteClass(class, variable, type, start, end, properties, namespace) - transfer class data to Python list of tuples or pandas dataframe. properties - comma-separated list of properties to form dataframe from. * and ? wildcards are supported. Defaults to * (all properties). %%CLASSNAME property is ignored. Only stored properties can be used.

Arguments:

  • class - class name
  • variable - target variable on a Python side
  • type - list or Pandas dataframe
  • start - initial object id. Must be integer.
  • end - final object id. Must be integer.
  • properties - comma-separated list of properties to form dataframe from. * and ? wildcards are supported. Defaults to * (all properties). %%CLASSNAME property is ignored. Only stored properties can be used.

All properties transferred as is except properties of %Date, %Time, %Boolean and %TimeStamp types. They are converted to respective Python datatypes.

ExecuteTable

Wrapper for ExecuteClass. Translates table name to class name and calls ExecuteClass. Signature:

ExecuteTable(table, variable, type, start, end, properties, namespace) - transfer table data to Python list of tuples or pandas dataframe.

Arguments:

  • table - table name.

Other arguments are passed as is to ExecuteClass.

Notes

  • ExecuteGlobal, ExecuteClass and ExecuteTable generally offer the same speed (as the time to parse class definition is negligible).
  • ExecuteGlobal is up to 20 times faster than ExecuteQuery on measurable workloads (>0.01 second).
  • ExecuteGlobal, ExecuteClass and ExecuteTable only work on the globals with this structure: ^global(key) = $lb(prop1, prop2, ..., propN) where key must be an integer.
  • For ExecuteGlobal, ExecuteClass and ExecuteTable supported %Date range equals mktime range (windows: 1970-01-01, linux 1900-01-01, mac). Use %TimeStamp to transfer dates outside of this range. Or use pandas dataframe (as this is a list limitation).
  • For ExecuteGlobal, ExecuteClass and ExecuteTable all arguments besides the source (global, class, table) and variable are optional.

Examples

Let's say we have isc.py.test.Person class. Here's how we can use all methods of data transfer:

// All the ways to transfer data
set global = "isc.py.test.PersonD"
set class = "isc.py.test.Person"
set table = "isc_py_test.Person"
set query = "SELECT * FROM isc_py_test.Person"

// Common arguments
set variable = "df"
set type = "dataframe"
set start = 1
set end = $g(^isc.py.test.PersonD, start)

// Approach 0: ExecuteGlobal without arguments
set sc = ##class(isc.py.Main).ExecuteGlobal(global, variable _ 0, type)

// Approach 1: ExecuteGlobal with arguments	
// For global transfer labels are not calculated automatically
// globalKey - is global subscript
set labels = $lb("globalKey", "Name", "DOB", "TS", "RandomTime", "AgeYears", "AgeDecimal", "AgeDouble", "Bool")

// mask is 1 element shorter than labels because "globalKey" is global subscript label
// Here we want to skip %%CLASSNAME field
set mask = "-+dmt+++b"

set sc = ##class(isc.py.Main).ExecuteGlobal(global, variable _ 1, type, start, end, mask, labels)

// Approach 2: ExecuteClass
set sc = ##class(isc.py.Main).ExecuteClass(class, variable _ 2, type, start, end)

// Approach 3: ExecuteTable
set sc = ##class(isc.py.Main).ExecuteTable(table, variable _ 3, type, start, end)

// Approach 4: ExecuteTable
set sc = ##class(isc.py.Main).ExecuteQuery(query, variable _ 4, type)

You can call this method: do ##class(isc.py.test.Person).Test() to check how these data transfer methods work.

Auxiliary

Support methods.

  • GetVariableInfo(variable, serialization, .defined, .type, .length) - get info about variable: is it defined, type and serialized length.
  • GetVariableDefined(variable, .defined) - is variable defined.
  • GetVariableType(variable, .type) - get variable FQCN.
  • GetStatus() - returns last occurred exception in Python and clears it.
  • GetModuleInfo(module, .imported, .alias) - get module alias and is it currently imported.
  • GetFunctionInfo(function, .defined, .type, .docs, .signature, .arguments) - get function information.

Summary

Python Gateway allows seamless integration between InterSsytems IRIS and Python. Use it to execute code and transfer data bidirectionally.

Links

Illustrated guide

There's also illustrated guide in ML Toolkit user group. ML Toolkit user group is a private GitHub repository set up as part of InterSystems corporate GitHub organization. It is addressed to the external users that are installing, learning or are already using ML Toolkit components including Python Gateway. To join ML Toolkit user group, please send a short e-mail at the following address: MLToolkit@intersystems.com and indicate in your e-mail the following details (needed for the group members to get to know and identify you during discussions):

  • GitHub username
  • Full Name (your first name followed by your last name in Latin script)
  • Organization (you are working for, or you study at, or your home office)
  • Position (your actual position in your organization, or “Student”, or “Independent”)
  • Country (you are based in)
0
1 714
Question Graham Hartley · Oct 8, 2019

Hi All, I'm in the process of trying to rollout the git version control system with our current code base within Atelier.  We use Ensemble to develop interfaces but are looking to move to IRIS in the near future.  Our code is structured similar to below:

 Site

           System1

Routers

Processes

Transformations

Data

Services

Operations

System2

Routers

Processes

Transformations

Services

Operations

Data

Productions

Routers

Operations

1
0 390
Question Evgeny Shvarov · Sep 6, 2019

Hi Developers!

Suppose I have a project where I want to build an IRIS container with two different dockerfiles depending on goals.  How can I make it?

The issue is that docker-compose is looking for the file with name 'dockerfile'

Are there any #IF constrations in a dockerfile syntax? 

Commenting works but sometimes it's more than one line.

2
0 327
Question Joshua Feener · Aug 30, 2019

I have a repository that I want to have in my /home/centos7/ directory, but it appears that Cache cannot access files there. Is that really the case? 

It seems like this is the case because in System Management Portal, when I try to up a new database in /home/centos7/, there aren't any directories listed, even if I add a custom one. Is Cache blocked out from this directory, and are there any others that Cache doesn't have the permission to access? 

4
0 456
Question Token Ibragimov · Aug 8, 2019

Hello! I'm sending get request. When send the request bellow 

Set httprequest=##class(%Net.HttpRequest).%New()
Set httprequest.Server=url
Do httprequest.Get("/"_par1_"/"_par2)
 Set statusCode = httprequest.HttpResponse.StatusCode

I get http status 200, but should get 410 status. Since the parameters passed are not valid. 

If I send request differently as below, I get http status 410, which is correct. 

Do httprequest.Get("/2019/0912")

What is the difference between these two requests Do httprequest.Get("/"_par1_"/"_par2) and Do httprequest.Get("/2019/0912")?

8
1 407
Article Nikolay Solovyev · Aug 1, 2019 3m read

In many projects I was faced with storing hierarchical data (tree) in classes.
By tree, I mean such data, where each node has a parent node — an object of the same class.
Many examples of such data can be given. For example, a catalog in the online store. Suppose that this online store sells books, in this case, the category tree might look like this:

The number in front of the name is the category ID.
For storage, you can create classes:

The MyApp.Category class  is used to store the category tree and contains the property “Parent” - reference to the same class.

1
1 1207
Question Erin Dolson · Jul 16, 2019

Hi all,

I'm looking to set up monitoring for several interfaces. I understand that I can set an Inactivity Timeout. However, obviously there are messages coming through more frequently during certain hours than other hours. 

Is there a way to set an Inactivity Timeout for each hour of the day instead of one value that is used all day long? 

Best,

Erin

12
3 882
Question Bob Ebbert · Jul 18, 2019

Hi,

I have  a program that displays the current running processes to the screen. I need to have a program execute that display program and capture the results to a file. The display program does pause at the bottom of each page waiting for an 'enter' to go to the next page.

Note( the display program will not successfully compile on the current system but it does work)

Also - very, very new to Mumps. 

Thanks,

Bob

23
0 632
Question Evgeny Shvarov · Jun 28, 2019

Hi guys!

As you know there are two (at least) ways to get the stored value of the property of InterSystems IRIS class if you know the ID of an instance (or a record).

1. Get it by as a property of an instance with "Object access":

ClassMethod GetPropertyForID(stId As %Integer) As %String

{

set obj=..%OpenId(stId)

return obj.StringData

}

2. Get it as a value of a column of the record with "SQL access":

18
0 1241
Article Zhong Li · Mar 15, 2019 15m read

Keywords:   Jupyter Notebook, Tensorflow GPU, Keras, Deep Learning, MLP,  and HealthShare    

1. Purpose and Objectives

In  previous"Part I" we have set up a deep learning demo environment. In this "Part II" we will test what we could do with it.

Many people at my age had started with the classic MLP (Multi-Layer Perceptron) model. It is intuitive hence conceptually easier to start with.

2
3 1034
Article David E Nelson · Apr 5, 2019 6m read

Now that the InterSystems IRIS Data Platform Community Edition is available on Docker Hub (https://hub.docker.com/_/intersystems-iris-data-platform), it seems like a great time to try InterSystems IRIS in a container. For some time already, the community edition has been available in the cloud, for example on AWS (https://community.intersystems.com/post/free-iris-community-edition-aws), but maybe it would be nice to try it locally as well. Fellow Windows users are no doubt used to eye rolling, being told “YMMV”, etc., whenever they mention using Docker for Windows. Sometimes we are even told

5
2 1294
Article Sergey Kamenev · Jul 7, 2017 7m read

In the previous parts (1, 2) we talked about globals as trees. In this article, we will look at them as sparse arrays.

A sparse array - is a type of array where most values assume an identical value.

In practice, you will often see sparse arrays so huge that there is no point in occupying memory with identical elements. Therefore, it makes sense to organize sparse arrays in such a way that memory is not wasted on storing duplicate values.

In some programming languages, sparse arrays are part of the language - for example, in J, MATLAB. In other languages, there are special libraries that let you use them. For C++, those would be Eigen and the like.

Globals are good candidates for implementing sparse arrays for the following reasons:

3
1 1524
Article Niyaz Khafizov · Jul 27, 2018 4m read

Hi all. Today we are going to upload a ML model into IRIS Manager and test it.

Note: I have done the following on Ubuntu 18.04, Apache Zeppelin 0.8.0, Python 3.6.5.

Introduction

These days many available different tools for Data Mining enable you to develop predictive models and analyze the data you have with unprecedented ease. InterSystems IRIS Data Platform provide a stable foundation for your big data and fast data applications, providing interoperability with modern DataMining tools. 

2
2 1494
Article David E Nelson · Apr 26, 2019 13m read

The last time that I created a playground for experimenting with machine learning using Apache Spark and an InterSystems data platform,  see Machine Learning with Spark and Caché, I installed and configured everything directly on my laptop: Caché, Python, Apache Spark, Java, some Hadoop libraries, to name a few. It required some effort, but eventually it worked. Paradise. But, I worried. Would I ever be able to reproduce all those steps? Maybe. Would it be possible for a random Windows or Java update to wreck the whole thing in an instant? Almost certainly.

3
7 1070