New post

Find

Article
· Mar 8, 2023 5m read

Keep your docker iris images in shape ;)

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!

11 Comments
Discussion (11)4
Log in or sign up to continue
Announcement
· Mar 8, 2023

Global Masters: get points for your ideas on Ideas Portal

Hi All, 

We are excited to announce that, starting on February 22, 2023, you will earn Global Masters points for your product ideas on the InterSystems Ideas Portal!

Free Vector | Businessman get an idea

100 points - for submitted ideas. You get points after the idea passes moderation and has "Needs Review" status.
500 points - when an idea is promoted for implementation, has "Planned", "In Progress", or "Community Opportunity" status.
3000 points - when an idea is implemented and has "Implemented" or "Done by Community" status.

Please note: points are awarded only for ideas submitted under the "InterSystems Products" category.

Publish your awesome ideas and gain points for them!

Not a Global Masters gamification program member yet? Log in using your InterSystems SSO credentials.

5 Comments
Discussion (5)3
Log in or sign up to continue
Article
· Mar 5, 2023 4m read

VSCode:RESTサービス実行中プロセスにアタッチしてデバッグする方法

開発者の皆さん、こんにちは!

1つ前の記事では、VSCodeのObjectScriptエクステンションに追加されたRESTサービスのデバッグツールについてご紹介しましたが、この記事では、RESTクライアントなどからHTTP要求を実行し、処理中のIRIS内プロセスにアタッチしながらデバッグを行う方法についてご紹介します。

 

事前準備などは、前回の記事と一緒になりますのでこの記事では割愛します。

図解のクラスでお試しいただく場合は、こちら👉https://github.com/Intersystems-jp/RESTDebug-VSCode をご利用ください。

 

この方法では、HTTP要求時に実行しているIRIS内プロセスを特定する必要があります。

そのため、デバッグ対象のメソッドで処理を待機させるため、hang 20のようにhangコマンドをコード中に追加して試します。

手順は以下の通りです。

1) プロセスにアタッチしてデバッグを行うため、launch.jsonを作成する。

VSCodeのデバッグ用ファイル:launch.jsonファイルを作成し、アタッチ用の設定を行います。

作成方法詳細は、VSCode:プロセスにアタッチしてデバッグする方法の「手順1:launch.json の用意」をご参照ください。

例)

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "objectscript",
            "request": "attach",
            "name": "アタッチデバッグ練習",
            "system": true,
            "processId": "${command:PickProcess}"
        }
    ]
}

 

2) デバッグ対象メソッドにHangコマンド追加します。

Hangを利用して処理を数秒待機させ、その間に実行中プロセスを特定します。ブレークポイントを置きたい行の前あたりにhangコマンドを追加してください(20~30秒待機するように記述します)。

hang 20

VSCodeでコードを編集するためには、ワークスペース内にクラス定義用ファイル(*.cls)を配置する必要があります。

サーバ側にあるコードに追記したい場合は、ワークスペースにエクスポートしてから追記します。

エクスポートは、サーバ側の対象コードを右クリックし「Export」を選択します。(下図参照)

Export実行後、ワークスペースに移動します。エクスポートファイルは、/src/パッケージ名/クラス名.clsの形式でワークスペースにエクスポートされます。

対象クラスを開き、コードを追記します。

 コードの追記が終わったら、Ctrl+Sで保存します(保存+コンパイルが実施されます)。

 

3) 外部クライアントからHTTP要求を実行します。

例は、PostmanからPOST要求でクエリパラメータとBodyに文字列を指定しています。

Sendボタンを実行すると、2) で指定したHangコマンドが実行されるため、指定秒数待機します。

この間に、アタッチ対象プロセスを探します。

 

4) アタッチ対象プロセスにアタッチする。

3) の実行後すぐ、VSCodeのデバッグウィンドウを開き、launch.jsonで指定したデバッグ名(例では、「アタッチデバッグ練習」)をクリックし、プロセスリストを表示させます。

プロセスリストには「RESTディスパッチクラス名.*」(*には数字が入ります)の形式で処理中ルーチン名が表示されます。

対象プロセスを見つけたら行をクリックしプロセスにアタッチします。

注意:指定したhangの秒数の間にプロセスを見つけてアタッチしてください。

 

5) デバッグを実行する。

Hangコマンドの実行が終わると、ブレークマークのところでデバッグが一時停止します。

後は、デバッグ用アイコンを利用してデバッグを進めるだけです。

 

6) デバッグを終了する。

最後に、デバッグ停止のボタンを押して終了します。

 


メモ:

  1. アタッチ用プロセス一覧に対象プロセスが表示されない場合は、一旦VSCodeを再起動して再度お試しください。
  2. アタッチのデバッグを実行するために追加したhangコマンドはデバッグ終了時必ず削除/コメント化してください。
5 Comments
Discussion (5)1
Log in or sign up to continue
Article
· Mar 2, 2023 4m read

Tutorial - Streams in Pieces

This tutorial is a follow on to Working with %Query    
It was displaying the content of the input stream chopped in fixed-size chunks.
But often those streams are structured and have well-defined separators (e.g HL7)
So as a side subject of this tutorial, this chapter shows how to break a stream into PIECES.

It is exactly the same idea as the $PIECE() function for strings with some add-ons.


The query takes these input parameters:

  • idfrom = first ID to show
  • idto = last ID to show - missing shos al higher IDs available
  • maxtxt = maximum size of output text from the stream. Default = 25
  • separator = characters as know from $Piece function 
  • startpiece = first piece to display
  • endpiece = last piece to display - if missing only the first is displayed
  • grouped = number of pieces in output text.  limited by maxtxt - default = 1
  • before = number of characters before the limiter from the previous piece

Implementation

The base for the Query was shown in the previous chapters.
Again the Source Object is kept local while processing the related Stream.
And as for the fixed-sized chunks also the Stream Object is kept while
processing the resulting output lines.

To find the pieces and count them method FindAt() scans the whole Stream
as a first action and builds a list of start points. It is used when the pieces
are collected into their groups by line.
The Streàm-Function used is ReadSQL(start, end). It is somewhat sensitive
and honors unprecise values with no result or ERROR. So besides locating all
pieces correctly composing precise and meaningful limits is the major challenge
for this part of the exercise.
It is all packaged in the method Piece() of the example code 

To enable multiple reentrances in the Fetch method all parameters are kept in
the common JSON object of the customized Query.

Here are some examples

  • Record #3 was deleted
  • Record#4 has no stream
  • PieceCnt shows the total pieces in the first row and number of pieces following
  • PieceId shows the number of the first Piece displayed

Some variations to the previous Tutorials:

  • the common variable qHandle that hat holds all requirements changed its name to qj to demonstrate independence from docu and for less typing.
  • the layout of the output in ROWSPEC is changed to also show the number of the starting piece, the total number of pieces in the first row, and the number of pieces in the following rows.

The first example shows objects 1..5 with max 33 chars
separated by || pieces 2..4  grouped by 2  with 3 previous characters

 

[SQL]USER>>call rcc.Q3(1,5,33,'||',2,4,2,3)
7.     call rcc.Q3(1,5,33,'||',2,4,2,3)

Dumping result #1
ID      City    Name    Age     pcCnt   PieceId PieceTxt
1       Bensonh Kovalev 16      52      2       ty.||Scope ||An AmAn LoIcA On
_       _       _       _       2       4        On||Iso
2       Queensb Yeats   15      52      2       00.||LoI||IesMorphSy
_       _       _       _       2       4       hSy||Re Uni
4       Newton  Evans   61      0       2
5       Hialeah Zemaiti 47      52      2       ks.||TwoToLy Wa||LoGraphIc Theti
_       _       _       _       2       4       eti||Ism LoToTri AticViaOpOp
 
7 Rows(s) Affected
statement prepare time(s)/globals/lines/disk: 0.0064s/2159/18029/0ms
          execute time(s)/globals/lines/disk: 0.0060s/186/21480/0ms
                          cached query class: %sqlcq.USER.cls86
---------------------------------------------------------------------------

Next example:
All records from 5 to end, maximum 33 characters, separated with || pieces 50 ..55 and 1 by line

USER>>call rcc.Q3(5,,33,'||',50,55,1)
9.     call rcc.Q3(5,,33,'||',50,55,1)

Dumping result #1
ID      City    Name    Age     pcCnt   PieceId PieceTxt
5       Hialeah Zemaiti 47      52      50      ||LoOp Am TriAmGeo LookMuch ReAble
_       _       _       _       1       51      ||AnIAn I GeoIc Ly Copter A IcA
_       _       _       _       1       52      ||***Done***
6       Elmhurs Jenkins 29      52      50      ||Re PhotoTech Ies
_       _       _       _       1       51      ||A
_       _       _       _       1       52      ||***Done***
7       Islip   Drabek  61      52      50      ||Thetic Status Cycle AmAm To Tech
_       _       _       _       1       51      ||Ly SoundCo CoCo AmCo Am ToRePus
_       _       _       _       1       52      ||***Done***
8       Islip   Kovalev 88      52      50      ||IcGeoType PhysicalLyIsm Ies To T
_       _       _       _       1       51      ||ComI An GeoRange On AnOnTo Two P
_       _       _       _       1       52      ||***Done***
 
12 Rows(s) Affected
statement prepare time(s)/globals/lines/disk: 0.0065s/2158/18091/0ms
          execute time(s)/globals/lines/disk: 0.0082s/245/28753/0ms
                          cached query class: %sqlcq.USER.cls103
---------------------------------------------------------------------------

Just a reminder:
All test data are generated using the System method %Populate
So your output will be different. I suggest you run our tests also with other parameters
than the shown examples to get the full power of this tool.

1 Comment
Discussion (1)1
Log in or sign up to continue
Article
· Mar 2, 2023 5m read

Tutorial - Working with %Query #3

My previous article introduced you to the COS based Custom Class Query.
There were some features missing like more lines of the stream displayed
and numbered.

The basic idea is the same.
A new input parameter chunks is introduced that sets a limit of displayed
pieces of our stream.

/// pack all params into qHandle
/// called only once at start
ClassMethod Q2Execute(
	ByRef qHandle As %Binary,
	idfrom As %Integer = 1,
	idto As %Integer = 0,
	maxtxt As %Integer = 25,
	chunks As %Integer = 1) As %Status
{
  set qHandle={}
  set qHandle.id=0
  set qHandle.idfrom=idfrom
  set qHandle.idto=idto
  set qHandle.obj=0
  set qHandle.stream=0
  set qHandle.maxtxt=maxtxt
  set qHandle.chunks=chunks
  set qHandle.chcnt=1
  Quit $$$OK
}
  • I now have a limit and a counter of displayed chunks default is 1 chunk
  • the Stream Object is kept open in qHandle to avoid reload
  • once the stream is empty I jump to the next available object.

and it looks like that:
 

[SQL]USER>>call rcc.Q2(1,,,3)
11.     call rcc.Q2(1,,,3)

Dumping result #1
ID      City    Name    Age     chunk   Stream
1       Bensonh Kovalev 16      1       Building shareholder valu
_       _       _       _       2       e by delivering secure di
_       _       _       _       3       stributed devices and med
2       Queensb Yeats   15      1       Spearheading the next gen
_       _       _       _       2       eration of high-performan
_       _       _       _       3       ce genetic virtualized in
4       Newton  Evans   61      1
5       Hialeah Zemaiti 47      1       Resellers of premise-base
_       _       _       _       2       d secure XML services for
_       _       _       _       3        social networks.||TwoToL
6       Elmhurs Jenkins 29      1       Enabling individuals and
_       _       _       _       2       businesses to manage ente
_       _       _       _       3       rprise models for social
7       Islip   Drabek  61      1       Building shareholder valu
_       _       _       _       2       e by delivering open crow
_       _       _       _       3       d-sourced voice-enabled c
8       Islip   Kovalev 88      1       Experts in standards-base
_       _       _       _       2       d distributed voice-enabl
_       _       _       _       3       ed services for social ne
 
19 Rows(s) Affected
statement prepare time(s)/globals/lines/disk: 0.0069s/2022/14949/0ms
          execute time(s)/globals/lines/disk: 0.0025s/48/5520/0ms
                          cached query class: %sqlcq.USER.cls82
---------------------------------------------------------------------------

for shorter streams it terminates when stream ends

[SQL]USER>>call rcc.Q2(,4,70,20)
22.     call rcc.Q2(,4,70,20)
 
Dumping result #1
ID      City    Name    Age     chunk   Stream
1       Bensonh Kovalev 16      1       Building shareholder value by delivering secure distributed devices an
_       _       _       _       2       d media for the Health Care community.||Scope ||An AmAn LoIcA On||Iso|
_       _       _       _       3       |PlasmA||Atic CoLoIO||IcOpIon An Lo||Re||Ies Tw||Lo Dyna I||Atic To Ly
_       _       _       _       4       ||Ecto O||AticL||Ism IAn Look||Plasm ||A||A Cop||Two IRe ||Two ||I||Dy
_       _       _       _       5       na Much LoN||Ion AmQuoAn Ec||OpOc||IcTwoCycl||A ComRe||I||GeoPedeLo ||
_       _       _       _       6       Pus EndoPyro||IesIsoIsmCom Te||A||Pyro||I On An I Tr||Syn AIcA||Gyro P
_       _       _       _       7       ho||AmCo UniTe||AScope ComQuo IH||Two A Ect||Graph ||A ||Pyro Heli AnR
_       _       _       _       8       eAn||Muc||Range IcTri||IonIsoIonAnC||A Wave Lo I||PusAt||To||Able ||Lo
_       _       _       _       9       Ati||A||Quo||Ly LyIc||***Done***
2       Queensb Yeats   15      1       Spearheading the next generation of high-performance genetic virtualiz
_       _       _       _       2       ed instruments for the Fortune 500.||LoI||IesMorphSy||Re Uni ||CoQuoEc
_       _       _       _       3       to||Tech IesOn ||Invent Vi||To LyIonGeoIc||Able||Ion Ect||Co I Ic Quo
_       _       _       _       4       U||AOn Much Ly To||Iso Much G||Am||LoIsmGraph Pus ||ReOp ViaComLo||OpI
_       _       _       _       5        TheticOn R||Ly OpCopter Mil||Quo Am Te||T||Plasm Type||On IsoIOpIcOp
_       _       _       _       6       P||I Dyna Tech Q||IGeo Dyna ||An AmLyCo Ion||Ic AnIsm Phot||IesAmI Am
_       _       _       _       7       OpA||KiloAnLo Am Co||Op ATr||TheticGraph||P||IcIc IOnTwoT||Ped||On On
_       _       _       _       8       QuoAnGrap||I||Copter LyQuo||ALookIcMuch Dyn||Abl||Re CoIcMuchCo A||ReO
_       _       _       _       9       nMuchAnToGr||TheticToTec||Ism Ies A||An AIAbleCo ||Q||LoI||Pus Ly ATri
_       _       _       _       10      On G||SoundU||To Heli Com||AOn||Ly Re||ComInventLoR||***Done***
4       Newton  Evans   61      1
20 Rows(s) Affected
statement prepare time(s)/globals/lines/disk: 0.0065s/2020/15410/0ms
          execute time(s)/globals/lines/disk: 0.0021s/33/5048/0ms
                          cached query class: %sqlcq.USER.cls84
---------------------------------------------------------------------------
  • the next step is to honor the separators and display segments
  • and also allow groups of segments
  • As the basic functionality is there it's more a matter of chopping the streams 

Follow me on to the next chapter for the extension of this example that
will show and control more result lines.

Just a reminder:
All test data are generated using the System method %Populate
So your output will be different. I suggest you run our tests also with other parameters
than the shown examples to get the full power of this tool.

The full code example is again available on GitHub  

The Video is available now. See section Custom Class Query 

For immediate access, you can use Demo Server WebTerminal  
and the related system Management Portal on Demo Server SMP

I hope you liked it so far and I can count on your votes.

1 Comment
Discussion (1)1
Log in or sign up to continue