Skip to content

Commit 0b361e7

Browse files
committed
cleanup and readme
1 parent 35cbdd1 commit 0b361e7

File tree

2 files changed

+80
-15
lines changed

2 files changed

+80
-15
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ ENV PATH "/usr/irissys/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sb
2121
RUN --mount=type=bind,src=.,dst=. \
2222
pip3 install -r requirements.txt && \
2323
iris start IRIS && \
24-
iris merge IRIS /home/irisowner/dev/merge.cpf && \
25-
irispython /home/irisowner/dev/iris-script.py && \
24+
iris merge IRIS merge.cpf && \
25+
irispython iris-script.py && \
2626
iris stop IRIS quietly

README.md

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,43 @@ $ docker-compose build
5252
$ docker-compose up -d
5353
```
5454

55+
### IRIS Initialization
56+
In this template two approaches are provided to initialize iris: merge and python.
57+
58+
1. Using merge to initialize IRIS and create IRIS Database and Namespace
59+
Notice merge.cpf file that is being implemented during docker image build in Dockerfile
60+
```
61+
iris merge IRIS merge.cpf && \
62+
```
63+
that contains:
64+
```
65+
[Actions]
66+
CreateResource:Name=%DB_IRISAPP_DATA,Description="IRISAPP_DATA database"
67+
CreateDatabase:Name=IRISAPP_DATA,Directory=/usr/irissys/mgr/IRISAPP_DATA
68+
CreateResource:Name=%DB_IRISAPP_CODE,Description="IRISAPP_CODE database"
69+
CreateDatabase:Name=IRISAPP_CODE,Directory=/usr/irissys/mgr/IRISAPP_CODE
70+
CreateNamespace:Name=IRISAPP,Globals=IRISAPP_DATA,Routines=IRISAPP_CODE,Interop=1
71+
ModifyService:Name=%Service_CallIn,Enabled=1,AutheEnabled=48
72+
ModifyUser:Name=SuperUser,PasswordHash=a31d24aecc0bfe560a7e45bd913ad27c667dc25a75cbfd358c451bb595b6bd52bd25c82cafaa23ca1dd30b3b4947d12d3bb0ffb2a717df29912b743a281f97c1,0a4c463a2fa1e7542b61aa48800091ab688eb0a14bebf536638f411f5454c9343b9aa6402b4694f0a89b624407a5f43f0a38fc35216bb18aab7dc41ef9f056b1,10000,SHA512
73+
```
74+
As you can see it creates dabasases IRISAPP_DATA and IRISAPP_CODE for data and code, the related IRISAPP namespace to access it and the related resources %IRISAPP_DATA and %IRISAPP_CODE" to manage the access.
75+
76+
Also it enables Callin service to make Embedded python work via ModifyService clause.
77+
and it updates the password for the built-in user SuperUser to "SYS". The hash for this password is obtained via the following command:
78+
```bash
79+
docker run --rm -it containers.intersystems.com/intersystems/passwordhash:1.1 -algorithm SHA512 -workfactor 10000
80+
```
81+
82+
2. Using python to initialize IRIS.
83+
Often we used a special iris.script file to run ObjectScript commands during the initialization.
84+
This template shows you how to use python for the same purpose.
85+
It is being executed via the line in Dockerfile:
86+
```
87+
irispython iris-script.py && \
88+
```
89+
the iris-script.py file contains examples how developer can initialize different services of iris via Python code.
90+
91+
5592
## How to test it
5693

5794
### Working with Python libs from ObjectScript
@@ -88,18 +125,10 @@ As mentioned Embedded Python works in the **same process as IRIS**.
88125

89126
So you have 2 options to work with Embedded Python in IRIS:
90127

91-
1. Bind VsCode to the running IRIS container.
92-
2. Develop in VSCode locally and then run the code in IRIS container with a shared folder.
93-
94-
#### Bind VSCode to the running IRIS container
95-
96-
Open VSCode in the project directory.
97-
98-
Go to the `docker-compose.yml` file, right-click on it and select `Compose Up`.
99-
100-
Once the container is up and running you can open the docker extension and right-click on the container name and select `Attach Visual Studio Code`.
128+
1. Develop in VSCode locally and then run the code in IRIS container with a shared folder.
129+
2. Bind VsCode to the running IRIS container.
101130

102-
#### Develop locally and run the code in IRIS container
131+
### Develop python scripts locally and run the code in IRIS container
103132

104133
By default, the template is configured to use the shared folder `./src` for python scripts to `/home/irisowner/dev/src` in IRIS container.
105134

@@ -121,15 +150,52 @@ Install the requirements:
121150
$ pip install -r requirements.txt
122151
```
123152

124-
Run the python script:
153+
#### Run the python script in iris container:
125154

126155
```bash
127156
# attach to the running IRIS container
128157
docker-compose exec iris bash
129158
# run the script
130159
$ irispython ./python/irisapp.py
131160
```
161+
The script contains different samples of working with IRIS from python and goes through it.
162+
it should return something like this:
163+
```
164+
Hello World
165+
Method call:
166+
It works!
167+
42
168+
Iris Version:
169+
IRIS for UNIX (Ubuntu Server LTS for ARM64 Containers) 2023.2 (Build 227U) Mon Jul 31 2023 17:43:25 EDT
170+
Creating new record in dc.python.PersistentClass
171+
1
172+
Printing one IRIS Object Dump:
173+
+----------------- general information ---------------
174+
| oref value: 1
175+
| class name: dc.python.PersistentClass
176+
| %%OID: $lb("1","dc.python.PersistentClass")
177+
| reference count: 1
178+
+----------------- attribute values ------------------
179+
| %Concurrency = 1 <Set>
180+
| Test = "2023-09-03 10:56:45.227577"
181+
+-----------------------------------------------------
182+
1
183+
Running SQL query Select * from dc_python.PersistentClass
184+
[0]: ['1', '2023-09-03 10:56:45.227577']
185+
Printing the whole global of the persistence storage for the class dc.python.PersistentClass:^dc.Package4C8F.PersistentC1A93D
186+
key=['1']: 2023-09-03 10:56:45.227577
187+
James
188+
Jim
189+
John
190+
```
132191

192+
#### Bind VSCode to the running IRIS container
193+
194+
Open VSCode in the project directory.
195+
196+
Go to the `docker-compose.yml` file, right-click on it and select `Compose Up`.
197+
198+
Once the container is up and running you can open the docker extension and right-click on the container name and select `Attach Visual Studio Code`.
133199

134200
#### Working with IRIS from Embedded Python
135201
Open VSCode in Devcontainer - this is the bell(notifications) button in the left bottom corner, where you will see the suggestion to open VSCOde in DevContainer mode.
@@ -139,7 +205,6 @@ Once devcontainer is opened go to /python/irisapp.py and run it, either with Run
139205
```bash
140206
$ irispython /python/irisapp.py
141207
```
142-
The script contains different samples of working with IRIS from python and goes through it.
143208

144209

145210
### Working with flask

0 commit comments

Comments
 (0)