Skip to content

Commit 0e04ff7

Browse files
committed
update readme and rename iris_script.py
1 parent c8b16db commit 0e04ff7

File tree

3 files changed

+60
-56
lines changed

3 files changed

+60
-56
lines changed

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ RUN --mount=type=bind,src=.,dst=. \
2222
pip3 install -r requirements.txt && \
2323
iris start IRIS && \
2424
iris merge IRIS merge.cpf && \
25-
irispython iris-script.py && \
25+
irispython iris_script.py && \
2626
iris stop IRIS quietly

Diff for: README.md

+59-55
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ $ docker-compose up -d
5454

5555
### IRIS Initialization
5656
In this template two approaches are provided to initialize iris: merge and python.
57+
merge.cpf is a convenient way to setup different IRIS configuration settings. [Learn more about merge.cpf](https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RACS_cpf#:~:text=Use%20the%20iris%20merge%20command,is%20the%20instance's%20current%20iris.).
5758

5859
1. Using merge to initialize IRIS and create IRIS Database and Namespace
5960
Notice [merge.cpf](https://github.com/intersystems-community/iris-embedded-python-template/blob/4c12d4b02770c7422c7553ee818a18c1871c3759/merge.cpf) file that is being implemented during docker image build in Dockerfile
@@ -80,76 +81,26 @@ docker run --rm -it containers.intersystems.com/intersystems/passwordhash:1.1 -a
8081
```
8182

8283
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 with [iris-script.py](https://github.com/intersystems-community/iris-embedded-python-template/blob/4c12d4b02770c7422c7553ee818a18c1871c3759/iris-script.py)file.
84+
Often we used a special [iris.script](https://github.com/intersystems-community/iris-embedded-python-template/blob/d7c817865b48681e3454997906e1374b3baeef74/iris.script) file to run ObjectScript commands during the initialization - it is here just for the information.
85+
This template shows you how to use python for the same purpose with [iris_script.py](https://github.com/intersystems-community/iris-embedded-python-template/blob/4c12d4b02770c7422c7553ee818a18c1871c3759/iris_script.py)file.
8586
It is being executed via the line in Dockerfile:
8687
```
87-
irispython iris-script.py && \
88+
irispython iris_script.py && \
8889
```
89-
the iris-script.py file contains examples how developer can initialize different services of iris via Python code.
90+
the iris_script.py file contains examples how developer can initialize different services of iris via Python code.
9091

9192

9293
## How to test it
9394

94-
### Working with Python libs from ObjectScript
95-
Open IRIS terminal:
96-
97-
```objectscript
98-
$ docker-compose exec iris iris session iris
99-
USER>zn "IRISAPP"
100-
```
101-
102-
The first test demonstrates the call to a standard python library working with dates datetime
103-
```objectscript
104-
IRISAPP>d ##class(dc.python.test).Today()
105-
2021-02-09
106-
```
107-
108-
Another example shows the work of a custom lib sample.py which is installed with repo or ZPM. It has function hello which returns string "world":
109-
```objectscript
110-
IRISAPP>d ##class(dc.python.test).Hello()
111-
World
112-
```
113-
114-
Another example shows how to work with files and use pandas and numpy libs.
115-
It calculates the mean age of Titanic passengers:
116-
117-
```objectscript
118-
IRISAPP>d ##class(dc.python.test).TitanicMeanAge()
119-
mean age=29.69911764705882
120-
121-
```
12295
### Working with IRIS from Embedded Python
12396

12497
As mentioned Embedded Python works in the **same process as IRIS**.
12598

12699
So you have 2 options to work with Embedded Python in IRIS:
127100

128-
1. Develop in VSCode locally and then run the code in IRIS container with a shared folder.
101+
1. Run the code in IRIS container with a shared folder.
129102
2. Bind VsCode to the running IRIS container.
130103

131-
### Develop python scripts locally and run the code in IRIS container
132-
133-
By default, the template is configured to use the shared folder `./src` for python scripts to `/home/irisowner/dev/src` in IRIS container.
134-
135-
You can change the folder according to your preferences.
136-
137-
It's recommended to work with a virtual environment.
138-
139-
Create a virtual environment in the project directory. Click New Terminal in the VS Code menu:
140-
```bash
141-
$ python3 -m venv .venv
142-
```
143-
Activate the virtual environment:
144-
```
145-
$ source .venv/bin/activate
146-
```
147-
148-
Install the requirements:
149-
```
150-
$ pip install -r requirements.txt
151-
```
152-
153104
#### Run the python script in iris container:
154105

155106
```bash
@@ -207,6 +158,59 @@ $ irispython /python/irisapp.py
207158
```
208159

209160

161+
### Working with Python libs from ObjectScript
162+
Open IRIS terminal:
163+
164+
```objectscript
165+
$ docker-compose exec iris iris session iris
166+
USER>zn "IRISAPP"
167+
```
168+
169+
The first test demonstrates the call to a standard python library working with dates datetime
170+
```objectscript
171+
IRISAPP>d ##class(dc.python.test).Today()
172+
2021-02-09
173+
```
174+
175+
Another example shows the work of a custom lib sample.py which is installed with repo or ZPM. It has function hello which returns string "world":
176+
```objectscript
177+
IRISAPP>d ##class(dc.python.test).Hello()
178+
World
179+
```
180+
181+
Another example shows how to work with files and use pandas and numpy libs.
182+
It calculates the mean age of Titanic passengers:
183+
184+
```objectscript
185+
IRISAPP>d ##class(dc.python.test).TitanicMeanAge()
186+
mean age=29.69911764705882
187+
188+
```
189+
190+
### Develop python scripts locally
191+
192+
By default, the template is configured to use the shared folder `./python` for python scripts to `/home/irisowner/dev/python` in IRIS container.
193+
194+
You can change the folder according to your preferences. Usually python developers name project at the root folder.
195+
196+
It's recommended to work with a virtual environment.
197+
198+
Create a virtual environment in the project directory. Click New Terminal in the VS Code menu:
199+
```bash
200+
$ python3 -m venv .venv
201+
```
202+
Activate the virtual environment:
203+
```
204+
$ source .venv/bin/activate
205+
```
206+
207+
Install the requirements:
208+
```
209+
$ pip install -r requirements.txt
210+
```
211+
212+
213+
210214
### Working with flask
211215

212216
The template also contains samples of working with flask.

Diff for: iris-script.py renamed to iris_script.py

File renamed without changes.

0 commit comments

Comments
 (0)