iris-pex-embedded-python 3.1.4b2__py3-none-any.whl → 3.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of iris-pex-embedded-python might be problematic. Click here for more details.

@@ -1,1403 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: iris_pex_embedded_python
3
- Version: 3.1.4b2
4
- Summary: Iris Interoperability based on Embedded Python
5
- Author-email: grongier <guillaume.rongier@intersystems.com>
6
- License: MIT License
7
-
8
- Copyright (c) 2019 InterSystems Developer Community
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
-
28
- Project-URL: homepage, https://github.com/grongierisc/interoperability-embedded-python
29
- Project-URL: documentation, https://github.com/grongierisc/interoperability-embedded-python/blob/master/README.md
30
- Project-URL: repository, https://github.com/grongierisc/interoperability-embedded-python
31
- Project-URL: issues, https://github.com/grongierisc/interoperability-embedded-python/issues
32
- Keywords: iris,intersystems,python,embedded
33
- Classifier: Development Status :: 5 - Production/Stable
34
- Classifier: Intended Audience :: Developers
35
- Classifier: License :: OSI Approved :: MIT License
36
- Classifier: Operating System :: OS Independent
37
- Classifier: Programming Language :: Python :: 3.6
38
- Classifier: Programming Language :: Python :: 3.7
39
- Classifier: Programming Language :: Python :: 3.8
40
- Classifier: Programming Language :: Python :: 3.9
41
- Classifier: Programming Language :: Python :: 3.10
42
- Classifier: Programming Language :: Python :: 3.11
43
- Classifier: Topic :: Utilities
44
- Description-Content-Type: text/markdown
45
- License-File: LICENSE
46
- Requires-Dist: dacite>=1.6.0
47
- Requires-Dist: xmltodict>=0.12.0
48
- Requires-Dist: iris-embedded-python-wrapper>=0.0.6
49
-
50
- # 1. interoperability-embedded-python
51
-
52
- [![PyPI - Status](https://img.shields.io/pypi/status/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
53
- [![PyPI](https://img.shields.io/pypi/v/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
54
- [![PyPI - Downloads](https://img.shields.io/pypi/dm/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
55
- [![PyPI - License](https://img.shields.io/pypi/l/iris-pex-embedded-python)](https://pypi.org/project/iris-pex-embedded-python/)
56
- ![GitHub last commit](https://img.shields.io/github/last-commit/grongierisc/interoperability-embedded-python)
57
-
58
- This proof of concept aims to show how the **iris interoperability framework** can be use with **embedded python**.
59
-
60
- ## 1.1. Table of Contents
61
-
62
- - [1. interoperability-embedded-python](#1-interoperability-embedded-python)
63
- - [1.1. Table of Contents](#11-table-of-contents)
64
- - [1.2. Example](#12-example)
65
- - [1.3. Register a component](#13-register-a-component)
66
- - [2. Demo](#2-demo)
67
- - [3. Installation](#3-installation)
68
- - [3.1. With ZPM](#31-with-zpm)
69
- - [3.2. With PyPI](#32-with-pypi)
70
- - [3.2.1. Known issues](#321-known-issues)
71
- - [4. How to Run the Sample](#4-how-to-run-the-sample)
72
- - [4.1. Docker containers](#41-docker-containers)
73
- - [4.2. Management Portal and VSCode](#42-management-portal-and-vscode)
74
- - [4.3. Open the production](#43-open-the-production)
75
- - [5. What's inside the repository](#5-whats-inside-the-repository)
76
- - [5.1. Dockerfile](#51-dockerfile)
77
- - [5.2. .vscode/settings.json](#52-vscodesettingsjson)
78
- - [5.3. .vscode/launch.json](#53-vscodelaunchjson)
79
- - [5.4. .vscode/extensions.json](#54-vscodeextensionsjson)
80
- - [5.5. src folder](#55-src-folder)
81
- - [6. How it works](#6-how-it-works)
82
- - [6.1. The `__init__.py`file](#61-the-__init__pyfile)
83
- - [6.2. The `common` class](#62-the-common-class)
84
- - [6.3. The `business_host` class](#63-the-business_host-class)
85
- - [6.4. The `inbound_adapter` class](#64-the-inbound_adapter-class)
86
- - [6.5. The `outbound_adapter` class](#65-the-outbound_adapter-class)
87
- - [6.6. The `business_service` class](#66-the-business_service-class)
88
- - [6.7. The `business_process` class](#67-the-business_process-class)
89
- - [6.8. The `business_operation` class](#68-the-business_operation-class)
90
- - [6.8.1. The dispacth system](#681-the-dispacth-system)
91
- - [6.8.2. The methods](#682-the-methods)
92
- - [6.9. The `director` class](#69-the-director-class)
93
- - [6.10. The `objects`](#610-the-objects)
94
- - [6.11. The `messages`](#611-the-messages)
95
- - [6.12. How to regsiter a component](#612-how-to-regsiter-a-component)
96
- - [6.12.1. register\_component](#6121-register_component)
97
- - [6.12.2. register\_file](#6122-register_file)
98
- - [6.12.3. register\_folder](#6123-register_folder)
99
- - [6.12.4. migrate](#6124-migrate)
100
- - [6.12.4.1. setting.py file](#61241-settingpy-file)
101
- - [6.12.4.1.1. CLASSES section](#612411-classes-section)
102
- - [6.12.4.1.2. Productions section](#612412-productions-section)
103
- - [6.13. Direct use of IOP](#613-direct-use-of-iop)
104
- - [7. Command line](#7-command-line)
105
- - [7.1. help](#71-help)
106
- - [7.2. default](#72-default)
107
- - [7.3. lists](#73-lists)
108
- - [7.4. start](#74-start)
109
- - [7.5. kill](#75-kill)
110
- - [7.6. stop](#76-stop)
111
- - [7.7. restart](#77-restart)
112
- - [7.8. migrate](#78-migrate)
113
- - [7.9. export](#79-export)
114
- - [7.10. status](#710-status)
115
- - [7.11. version](#711-version)
116
- - [7.12. log](#712-log)
117
- - [8. Credits](#8-credits)
118
- - [9. Benchmarks](#9-benchmarks)
119
-
120
- ## 1.2. Example
121
-
122
- bo.py
123
- ```python
124
- from iop import BusinessOperation,Message
125
-
126
- class MyBusinessOperation(BusinessOperation):
127
-
128
- def on_init(self):
129
- #This method is called when the component is becoming active in the production
130
-
131
- self.log_info("[Python] ...MyBusinessOperation:on_init() is called")
132
-
133
- return
134
-
135
- def on_teardown(self):
136
- #This method is called when the component is becoming inactive in the production
137
-
138
- self.log_info("[Python] ...MyBusinessOperation:on_teardown() is called")
139
-
140
- return
141
-
142
- def on_message(self, message_input:MyRequest):
143
- # called from service/process/operation, message is of type MyRequest with property request_string
144
-
145
- self.log_info("[Python] ...MyBusinessOperation:on_message() is called with message:"+message_input.request_string)
146
-
147
- response = MyResponse("...MyBusinessOperation:on_message() echos")
148
-
149
- return response
150
-
151
- @dataclass
152
- class MyRequest(Message):
153
-
154
- request_string:str = None
155
-
156
- @dataclass
157
- class MyResponse(Message):
158
-
159
- my_string:str = None
160
-
161
- ```
162
-
163
- ## 1.3. Register a component
164
-
165
- To register a component, you need to create a `setting.py` file in the root of your project.<br>
166
-
167
- This file will be used to register your classes and productions.<br>
168
-
169
- e.g.:
170
- setting.py
171
- ```python
172
- from iop import Utils
173
-
174
- import bo
175
-
176
- CLASSES = {
177
- "Python.MyBusinessOperation": bo.MyBusinessOperation
178
- }
179
- ```
180
-
181
- Then you can use the `iop` command line to register your component.
182
-
183
- ```sh
184
- iop --migrate /path/to/your/project/setting.py
185
- ```
186
-
187
- # 2. Demo
188
-
189
- You can find a demo in the [src/python/demo](src/python/demo) folder.
190
-
191
- Other demos are aviailable in those repositories:
192
-
193
- - [training](https://github.com/grongierisc/formation-template-python)
194
- - [template](https://github.com/grongierisc/iris-python-interoperability-template)
195
- - [falsk](https://github.com/grongierisc/iris-python-flask-api-template)
196
- - [rest-to-dicom](https://github.com/grongierisc/RestToDicom)
197
-
198
- # 3. Installation
199
-
200
- ## 3.1. With ZPM
201
-
202
- ```objectscript
203
- zpm "install pex-embbeded-python"
204
- ```
205
-
206
- ## 3.2. With PyPI
207
-
208
- ```sh
209
- pip3 install iris-pex-embedded-python
210
- ```
211
-
212
- Import the ObjectScript classes, open an embedded python shell and run :
213
-
214
- ```python
215
- from iop import Utils
216
- Utils.setup()
217
- ```
218
-
219
- or use `iop` command line :
220
-
221
- ```sh
222
- iop --init
223
- ```
224
-
225
- ### 3.2.1. Known issues
226
-
227
- If the module is not updated, make sure to remove the old version :
228
-
229
- ```sh
230
- pip3 uninstall iris-pex-embedded-python
231
- ```
232
-
233
- or manually remove the `grongier` folder in `<iris_installation>/lib/python/`
234
-
235
- or force the installation with pip :
236
-
237
- ```sh
238
- pip3 install --upgrade iris-pex-embedded-python --target <iris_installation>/lib/python/
239
- ```
240
-
241
- # 4. How to Run the Sample
242
-
243
- ## 4.1. Docker containers
244
-
245
-
246
- In order to have access to the InterSystems images, we need to go to the following url: http://container.intersystems.com. After connecting with our InterSystems credentials, we will get our password to connect to the registry. In the docker VScode addon, in the image tab, by pressing connect registry and entering the same url as before (http://container.intersystems.com) as a generic registry, we will be asked to give our credentials. The login is the usual one but the password is the one we got from the website.
247
-
248
- From there, we should be able to build and compose our containers (with the `docker-compose.yml` and `Dockerfile` files given).
249
-
250
- ## 4.2. Management Portal and VSCode
251
-
252
- This repository is ready for [VS Code](https://code.visualstudio.com/).
253
-
254
- Open the locally-cloned `interoperability-embedeed-python` folder in VS Code.
255
-
256
- If prompted (bottom right corner), install the recommended extensions.
257
-
258
- **IMPORTANT**: When prompted, reopen the folder inside the container so you will be able to use the python components within it. The first time you do this it may take several minutes while the container is readied.
259
-
260
- By opening the folder remote you enable VS Code and any terminals you open within it to use the python components within the container. Configure these to use `/usr/irissys/bin/irispython`
261
-
262
- <img width="1614" alt="PythonInterpreter" src="https://user-images.githubusercontent.com/47849411/145864423-2de24aaa-036c-4beb-bda0-3a73fe15ccbd.png">
263
-
264
- ## 4.3. Open the production
265
- To open the production you can go to [production](http://localhost:52773/csp/irisapp/EnsPortal.ProductionConfig.zen?PRODUCTION=PEX.Production).<br>
266
- You can also click on the bottom on the `127.0.0.1:52773[IRISAPP]` button and select `Open Management Portal` then, click on [Interoperability] and [Configure] menus then click [productions] and [Go].
267
-
268
- The production already has some code sample.
269
-
270
- Here we can see the production and our pure python services and operations:
271
- <img width="1177" alt="interop-screenshot" src="https://user-images.githubusercontent.com/47849411/131305197-d19511fd-6e05-4aec-a525-c88e6ebd0971.png">
272
-
273
- <br>
274
-
275
- New json trace for python native messages :
276
- <img width="910" alt="json-message-trace" src="https://user-images.githubusercontent.com/47849411/131305211-b8beb2c0-438d-4afc-a6d2-f94d854373ae.png">
277
-
278
- # 5. What's inside the repository
279
-
280
- ## 5.1. Dockerfile
281
-
282
- A dockerfile which install some python dependancies (pip, venv) and sudo in the container for conviencies.
283
- Then it create the dev directory and copy in it this git repository.
284
-
285
- It starts IRIS and activates **%Service_CallIn** for **Python Shell**.
286
- Use the related docker-compose.yml to easily setup additional parametes like port number and where you map keys and host folders.
287
-
288
- This dockerfile ends with the installation of requirements for python modules.
289
-
290
- Use .env/ file to adjust the dockerfile being used in docker-compose.
291
-
292
- ## 5.2. .vscode/settings.json
293
-
294
- Settings file to let you immedietly code in VSCode with [VSCode ObjectScript plugin](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript)
295
-
296
- ## 5.3. .vscode/launch.json
297
- Config file if you want to debug with VSCode ObjectScript
298
-
299
- [Read about all the files in this article](https://community.intersystems.com/post/dockerfile-and-friends-or-how-run-and-collaborate-objectscript-projects-intersystems-iris)
300
-
301
- ## 5.4. .vscode/extensions.json
302
- Recommendation file to add extensions if you want to run with VSCode in the container.
303
-
304
- [More information here](https://code.visualstudio.com/docs/remote/containers)
305
-
306
- This is very useful to work with embedded python.
307
-
308
- ## 5.5. src folder
309
-
310
- ```
311
- src
312
- ├── Grongier
313
- │ └── PEX // ObjectScript classes that wrap python code
314
- │ ├── BusinessOperation.cls
315
- │ ├── BusinessProcess.cls
316
- │ ├── BusinessService.cls
317
- │ ├── Common.cls
318
- │ ├── Director.cls
319
- │ ├── InboundAdapter.cls
320
- │ ├── Message.cls
321
- │ ├── OutboundAdapter.cls
322
- │ ├── Python.cls
323
- │ ├── Test.cls
324
- │ └── _utils.cls
325
- ├── PEX // Some example of wrapped classes
326
- │ └── Production.cls
327
- └── python
328
- ├── demo // Actual python code to run this demo
329
- | `-- reddit
330
- | |-- adapter.py
331
- | |-- bo.py
332
- | |-- bp.py
333
- | |-- bs.py
334
- | |-- message.py
335
- | `-- obj.py
336
- ├── dist // Wheel used to implement python interoperability components
337
- │ └── grongier_pex-1.2.4-py3-none-any.whl
338
- ├── grongier
339
- │ └── pex // Helper classes to implement interoperability components
340
- │ ├── _business_host.py
341
- │ ├── _business_operation.py
342
- │ ├── _business_process.py
343
- │ ├── _business_service.py
344
- │ ├── _common.py
345
- │ ├── _director.py
346
- │ ├── _inbound_adapter.py
347
- │ ├── _message.py
348
- │ ├── _outbound_adapter.py
349
- │ ├── __init__.py
350
- │ └── _utils.py
351
- └── setup.py // setup to build the wheel
352
- ```
353
- # 6. How it works
354
-
355
- ## 6.1. The `__init__.py`file
356
- This file will allow us to create the classes to import in the code.<br>
357
- It gets from the multiple files seen earlier the classes and make them into callable classes.
358
- That way, when you wish to create a business operation, for example, you can just do:
359
- ```python
360
- from iop import BusinessOperation
361
- ```
362
-
363
- ## 6.2. The `common` class
364
- The common class shouldn't be called by the user, it defines almost all the other classes.<br>
365
- This class defines:
366
-
367
- `on_init`: The on_init() method is called when the component is started.<br> Use the on_init() method to initialize any structures needed by the component.
368
-
369
- `on_tear_down`: Called before the component is terminated.<br> Use it to free any structures.
370
-
371
- `on_connected`: The on_connected() method is called when the component is connected or reconnected after being disconnected.<br>Use the on_connected() method to initialize any structures needed by the component.
372
-
373
- `log_info`: Write a log entry of type "info". :log entries can be viewed in the management portal.
374
-
375
- `log_alert`: Write a log entry of type "alert". :log entries can be viewed in the management portal.
376
-
377
- `log_warning`: Write a log entry of type "warning". :log entries can be viewed in the management portal.
378
-
379
- `log_error`: Write a log entry of type "error". :log entries can be viewed in the management portal.
380
-
381
- ## 6.3. The `business_host` class
382
- The business host class shouldn't be called by the user, it is the base class for all the business classes.<br>
383
- This class defines:
384
-
385
- `send_request_sync`: Send the specified message to the target business process or business operation synchronously.
386
- **Parameters**:<br>
387
- - **target**: a string that specifies the name of the business process or operation to receive the request. <br>
388
- The target is the name of the component as specified in the Item Name property in the production definition, not the class name of the component.
389
- - **request**: specifies the message to send to the target. The request is either an instance of a class that is a subclass of Message class or of IRISObject class.<br>
390
- If the target is a build-in ObjectScript component, you should use the IRISObject class. The IRISObject class enables the PEX framework to convert the message to a class supported by the target.
391
- - **timeout**: an optional integer that specifies the number of seconds to wait before treating the send request as a failure. The default value is -1, which means wait forever.<br>
392
- description: an optional string parameter that sets a description property in the message header. The default is None.
393
-
394
- **Returns**:
395
- the response object from target.
396
-
397
- **Raises**:
398
- TypeError: if request is not of type Message or IRISObject.
399
-
400
- <br><br>
401
-
402
- `send_request_async`: Send the specified message to the target business process or business operation asynchronously.
403
- **Parameters**:<br>
404
- - **target**: a string that specifies the name of the business process or operation to receive the request. <br>
405
- The target is the name of the component as specified in the Item Name property in the production definition, not the class name of the component.
406
- - **request**: specifies the message to send to the target. The request is an instance of IRISObject or of a subclass of Message.<br>
407
- If the target is a built-in ObjectScript component, you should use the IRISObject class. The IRISObject class enables the PEX framework to convert the message to a class supported by the target.
408
- - **description**: an optional string parameter that sets a description property in the message header. The default is None.
409
-
410
- **Raises**:
411
- TypeError: if request is not of type Message or IRISObject.
412
-
413
- <br><br>
414
-
415
- `get_adapter_type`: Name of the registred Adapter.
416
-
417
-
418
- ## 6.4. The `inbound_adapter` class
419
- Inbound Adapter in Python are subclass from iop.InboundAdapter in Python, that inherit from all the functions of the [common class](#72-the-common-class).<br>
420
- This class is responsible for receiving the data from the external system, validating the data, and sending it to the business service by calling the BusinessHost process_input method.
421
- This class defines:
422
-
423
- `on_task`: Called by the production framework at intervals determined by the business service CallInterval property.<br>
424
- The message can have any structure agreed upon by the inbound adapter and the business service.
425
-
426
- Example of an inbound adapter ( situated in the src/python/demo/reddit/adapter.py file ):
427
- ```python
428
- from iop import InboundAdapter
429
- import requests
430
- import iris
431
- import json
432
-
433
- class RedditInboundAdapter(InboundAdapter):
434
- """
435
- This adapter use requests to fetch self.limit posts as data from the reddit
436
- API before calling process_input for each post.
437
- """
438
- def on_init(self):
439
-
440
- if not hasattr(self,'feed'):
441
- self.feed = "/new/"
442
-
443
- if self.limit is None:
444
- raise TypeError('no Limit field')
445
-
446
- self.last_post_name = ""
447
-
448
- return 1
449
-
450
- def on_task(self):
451
- self.log_info(f"LIMIT:{self.limit}")
452
- if self.feed == "" :
453
- return 1
454
-
455
- tSC = 1
456
- # HTTP Request
457
- try:
458
- server = "https://www.reddit.com"
459
- request_string = self.feed+".json?before="+self.last_post_name+"&limit="+self.limit
460
- self.log_info(server+request_string)
461
- response = requests.get(server+request_string)
462
- response.raise_for_status()
463
-
464
- data = response.json()
465
- updateLast = 0
466
-
467
- for key, value in enumerate(data['data']['children']):
468
- if value['data']['selftext']=="":
469
- continue
470
- post = iris.cls('dc.Reddit.Post')._New()
471
- post._JSONImport(json.dumps(value['data']))
472
- post.OriginalJSON = json.dumps(value)
473
- if not updateLast:
474
- self.LastPostName = value['data']['name']
475
- updateLast = 1
476
- response = self.BusinessHost.ProcessInput(post)
477
- except requests.exceptions.HTTPError as err:
478
- if err.response.status_code == 429:
479
- self.log_warning(err.__str__())
480
- else:
481
- raise err
482
- except Exception as err:
483
- self.log_error(err.__str__())
484
- raise err
485
-
486
- return tSC
487
- ```
488
-
489
- ## 6.5. The `outbound_adapter` class
490
- Outbound Adapter in Python are subclass from iop.OutboundAdapter in Python, that inherit from all the functions of the [common class](#72-the-common-class).<br>
491
- This class is responsible for sending the data to the external system.
492
-
493
- The Outbound Adapter gives the Operation the possibility to have a heartbeat notion.
494
- To activate this option, the CallInterval parameter of the adapter must be strictly greater than 0.
495
-
496
- <img width="301" alt="image" src="https://user-images.githubusercontent.com/47849411/178230243-39806602-a63d-4a89-9563-fcf6836d0515.png">
497
-
498
- Example of an outbound adapter ( situated in the src/python/demo/reddit/adapter.py file ):
499
-
500
- ```python
501
- class TestHeartBeat(OutboundAdapter):
502
-
503
- def on_keepalive(self):
504
- self.log_info('beep')
505
-
506
- def on_task(self):
507
- self.log_info('on_task')
508
- ```
509
-
510
- ## 6.6. The `business_service` class
511
- This class is responsible for receiving the data from external system and sending it to business processes or business operations in the production.<br>
512
- The business service can use an adapter to access the external system, which is specified overriding the get_adapter_type method.<br>
513
- There are three ways of implementing a business service:<br>
514
- - Polling business service with an adapter - The production framework at regular intervals calls the adapter’s OnTask() method,
515
- which sends the incoming data to the the business service ProcessInput() method, which, in turn calls the OnProcessInput method with your code.
516
-
517
- - Polling business service that uses the default adapter - In this case, the framework calls the default adapter's OnTask method with no data.
518
- The OnProcessInput() method then performs the role of the adapter and is responsible for accessing the external system and receiving the data.
519
-
520
- - Nonpolling business service - The production framework does not initiate the business service. Instead custom code in either a long-running process
521
- or one that is started at regular intervals initiates the business service by calling the Director.CreateBusinessService() method.
522
-
523
- Business service in Python are subclass from iop.BusinessService in Python, that inherit from all the functions of the [business host](#73-the-business_host-class).<br>
524
- This class defines:
525
-
526
- `on_process_input`: Receives the message from the inbond adapter via the PRocessInput method and is responsible for forwarding it to target business processes or operations.<br>
527
- If the business service does not specify an adapter, then the default adapter calls this method with no message and the business service is responsible for receiving the data from the external system and validating it.
528
- **Parameters**:<br>
529
- - **message_input**: an instance of IRISObject or subclass of Message containing the data that the inbound adapter passes in.<br>
530
- The message can have any structure agreed upon by the inbound adapter and the business service.
531
-
532
- <br><br>
533
-
534
- Example of a business service ( situated in the src/python/demo/reddit/bs.py file ):
535
- ```python
536
- from iop import BusinessService
537
-
538
- import iris
539
-
540
- from message import PostMessage
541
- from obj import PostClass
542
-
543
- class RedditServiceWithPexAdapter(BusinessService):
544
- """
545
- This service use our python Python.RedditInboundAdapter to receive post
546
- from reddit and call the FilterPostRoutingRule process.
547
- """
548
- def get_adapter_type():
549
- """
550
- Name of the registred Adapter
551
- """
552
- return "Python.RedditInboundAdapter"
553
-
554
- def on_process_input(self, message_input):
555
- msg = iris.cls("dc.Demo.PostMessage")._New()
556
- msg.Post = message_input
557
- return self.send_request_sync(self.target,msg)
558
-
559
- def on_init(self):
560
-
561
- if not hasattr(self,'target'):
562
- self.target = "Python.FilterPostRoutingRule"
563
-
564
- return
565
- ```
566
-
567
-
568
- ## 6.7. The `business_process` class
569
- Typically contains most of the logic in a production.<br>
570
- A business process can receive messages from a business service, another business process, or a business operation.<br>
571
- It can modify the message, convert it to a different format, or route it based on the message contents.<br>
572
- The business process can route a message to a business operation or another business process.<br>
573
- Business processes in Python are subclass from iop.BusinessProcess in Python, that inherit from all the functions of the [business host](#73-the-business_host-class).<br>
574
- This class defines:
575
-
576
- `on_request`: Handles requests sent to the business process. A production calls this method whenever an initial request for a specific business process arrives on the appropriate queue and is assigned a job in which to execute.<br>
577
- **Parameters**:<br>
578
- - **request**: An instance of IRISObject or subclass of Message that contains the request message sent to the business process.
579
-
580
- **Returns**:
581
- An instance of IRISObject or subclass of Message that contains the response message that this business process can return
582
- to the production component that sent the initial message.
583
-
584
- <br><br>
585
-
586
- `on_response`: Handles responses sent to the business process in response to messages that it sent to the target.<br>
587
- A production calls this method whenever a response for a specific business process arrives on the appropriate queue and is assigned a job in which to execute.<br>
588
- Typically this is a response to an asynchronous request made by the business process where the responseRequired parameter has a true value.<br>
589
- **Parameters**:<br>
590
- - **request**: An instance of IRISObject or subclass of Message that contains the initial request message sent to the business process.
591
- - **response**: An instance of IRISObject or subclass of Message that contains the response message that this business process can return to the production component that sent the initial message.
592
- - **callRequest**: An instance of IRISObject or subclass of Message that contains the request that the business process sent to its target.
593
- - **callResponse**: An instance of IRISObject or subclass of Message that contains the incoming response.
594
- - **completionKey**: A string that contains the completionKey specified in the completionKey parameter of the outgoing SendAsync() method.
595
-
596
- **Returns**:
597
- An instance of IRISObject or subclass of Message that contains the response message that this business process can return
598
- to the production component that sent the initial message.
599
-
600
- <br><br>
601
-
602
- `on_complete`: Called after the business process has received and handled all responses to requests it has sent to targets.<br>
603
- **Parameters**:
604
- - **request**: An instance of IRISObject or subclass of Message that contains the initial request message sent to the business process.<br>
605
- - **response**: An instance of IRISObject or subclass of Message that contains the response message that this business process can return to the production component that sent the initial message.
606
-
607
- **Returns**:
608
- An instance of IRISObject or subclass of Message that contains the response message that this business process can return to the production component that sent the initial message.
609
-
610
- <br><br>
611
-
612
- Example of a business process ( situated in the src/python/demo/reddit/bp.py file ):
613
- ```python
614
- from iop import BusinessProcess
615
-
616
- from message import PostMessage
617
- from obj import PostClass
618
-
619
- class FilterPostRoutingRule(BusinessProcess):
620
- """
621
- This process receive a PostMessage containing a reddit post.
622
- It then understand if the post is about a dog or a cat or nothing and
623
- fill the right infomation inside the PostMessage before sending it to
624
- the FileOperation operation.
625
- """
626
- def on_init(self):
627
-
628
- if not hasattr(self,'target'):
629
- self.target = "Python.FileOperation"
630
-
631
- return
632
-
633
- def on_request(self, request):
634
-
635
- if 'dog'.upper() in request.post.selftext.upper():
636
- request.to_email_address = 'dog@company.com'
637
- request.found = 'Dog'
638
- if 'cat'.upper() in request.post.selftext.upper():
639
- request.to_email_address = 'cat@company.com'
640
- request.found = 'Cat'
641
-
642
- if request.found is not None:
643
- return self.send_request_sync(self.target,request)
644
- else:
645
- return
646
- ```
647
-
648
- ## 6.8. The `business_operation` class
649
- This class is responsible for sending the data to an external system or a local system such as an iris database.<br>
650
- The business operation can optionally use an adapter to handle the outgoing message which is specified overriding the get_adapter_type method.<br>
651
- If the business operation has an adapter, it uses the adapter to send the message to the external system.<br>
652
- The adapter can either be a PEX adapter, an ObjectScript adapter or a [python adapter](#75-the-outbound_adapter-class).<br>
653
- Business operation in Python are subclass from iop.BusinessOperation in Python, that inherit from all the functions of the [business host](#73-the-business_host-class).<br>
654
-
655
- ### 6.8.1. The dispacth system
656
- In a business operation it is possbile to create any number of function [similar to the on_message method](#782-the-methods) that will take as argument a [typed request](#711-the-messages) like this `my_special_message_method(self,request: MySpecialMessage)`.
657
-
658
- The dispatch system will automatically analyze any request arriving to the operation and dispacth the requests depending of their type. If the type of the request is not recognized or is not specified in any **on_message like function**, the dispatch system will send it to the `on_message` function.
659
-
660
- ### 6.8.2. The methods
661
- This class defines:
662
-
663
- `on_message`: Called when the business operation receives a message from another production component [that can not be dispatched to another function](#781-the-dispacth-system).<br>
664
- Typically, the operation will either send the message to the external system or forward it to a business process or another business operation.
665
- If the operation has an adapter, it uses the Adapter.invoke() method to call the method on the adapter that sends the message to the external system.
666
- If the operation is forwarding the message to another production component, it uses the SendRequestAsync() or the SendRequestSync() method.<br>
667
- **Parameters**:
668
- - **request**: An instance of either a subclass of Message or of IRISObject containing the incoming message for the business operation.
669
-
670
- **Returns**:
671
- The response object
672
-
673
- Example of a business operation ( situated in the src/python/demo/reddit/bo.py file ):
674
- ```python
675
- from iop import BusinessOperation
676
-
677
- from message import MyRequest,MyMessage
678
-
679
- import iris
680
-
681
- import os
682
- import datetime
683
- import smtplib
684
- from email.mime.text import MIMEText
685
-
686
- class EmailOperation(BusinessOperation):
687
- """
688
- This operation receive a PostMessage and send an email with all the
689
- important information to the concerned company ( dog or cat company )
690
- """
691
-
692
- def my_message(self,request:MyMessage):
693
- sender = 'admin@example.com'
694
- receivers = 'toto@example.com'
695
- port = 1025
696
- msg = MIMEText(request.toto)
697
-
698
- msg['Subject'] = 'MyMessage'
699
- msg['From'] = sender
700
- msg['To'] = receivers
701
-
702
- with smtplib.SMTP('localhost', port) as server:
703
- server.sendmail(sender, receivers, msg.as_string())
704
- print("Successfully sent email")
705
-
706
- def on_message(self, request):
707
-
708
- sender = 'admin@example.com'
709
- receivers = [ request.to_email_address ]
710
-
711
-
712
- port = 1025
713
- msg = MIMEText('This is test mail')
714
-
715
- msg['Subject'] = request.found+" found"
716
- msg['From'] = 'admin@example.com'
717
- msg['To'] = request.to_email_address
718
-
719
- with smtplib.SMTP('localhost', port) as server:
720
-
721
- # server.login('username', 'password')
722
- server.sendmail(sender, receivers, msg.as_string())
723
- print("Successfully sent email")
724
-
725
- ```
726
- If this operation is called using a MyRequest message, the my_message function will be called thanks to the dispatcher, otherwise the on_message function will be called.
727
-
728
- ## 6.9. The `director` class
729
- The Director class is used for nonpolling business services, that is, business services which are not automatically called by the production framework (through the inbound adapter) at the call interval.<br>
730
- Instead these business services are created by a custom application by calling the Director.create_business_service() method.<br>
731
- This class defines:
732
-
733
- `create_business_service`: The create_business_service() method initiates the specified business service.<br>
734
- **Parameters**:
735
- - **connection**: an IRISConnection object that specifies the connection to an IRIS instance for Java.
736
- - **target**: a string that specifies the name of the business service in the production definition.
737
-
738
- **Returns**:
739
- an object that contains an instance of IRISBusinessService
740
-
741
- `start_production`: The start_production() method starts the production.<br>
742
- **Parameters**:
743
- - **production_name**: a string that specifies the name of the production to start.
744
-
745
- `stop_production`: The stop_production() method stops the production.<br>
746
- **Parameters**:
747
- - **production_name**: a string that specifies the name of the production to stop.
748
-
749
- `restart_production`: The restart_production() method restarts the production.<br>
750
- **Parameters**:
751
- - **production_name**: a string that specifies the name of the production to restart.
752
-
753
- `list_productions`: The list_productions() method returns a dictionary of the names of the productions that are currently running.<br>
754
-
755
- ## 6.10. The `objects`
756
- We will use `dataclass` to hold information in our [messages](#711-the-messages) in a `obj.py` file.
757
-
758
- Example of an object ( situated in the src/python/demo/reddit/obj.py file ):
759
- ```python
760
- from dataclasses import dataclass
761
-
762
- @dataclass
763
- class PostClass:
764
- title: str
765
- selftext : str
766
- author: str
767
- url: str
768
- created_utc: float = None
769
- original_json: str = None
770
- ```
771
-
772
- ## 6.11. The `messages`
773
- The messages will contain one or more [objects](#710-the-objects), located in the `obj.py` file.<br>
774
- Messages, requests and responses all inherit from the `iop.Message` class.
775
-
776
- These messages will allow us to transfer information between any business service/process/operation.
777
-
778
- Example of a message ( situated in the src/python/demo/reddit/message.py file ):
779
- ```python
780
- from iop import Message
781
-
782
- from dataclasses import dataclass
783
-
784
- from obj import PostClass
785
-
786
- @dataclass
787
- class PostMessage(Message):
788
- post:PostClass = None
789
- to_email_address:str = None
790
- found:str = None
791
- ```
792
-
793
- WIP It is to be noted that it is needed to use types when you define an object or a message.
794
-
795
- ## 6.12. How to regsiter a component
796
-
797
- You can register a component to iris in many way :
798
- * Only one component with `register_component`
799
- * All the component in a file with `register_file`
800
- * All the component in a folder with `register_folder`
801
-
802
- ### 6.12.1. register_component
803
-
804
- Start an embedded python shell :
805
-
806
- ```sh
807
- /usr/irissys/bin/irispython
808
- ```
809
-
810
- Then use this class method to add a new py file to the component list for interoperability.
811
-
812
- ```python
813
- from iop import Utils
814
- Utils.register_component(<ModuleName>,<ClassName>,<PathToPyFile>,<OverWrite>,<NameOfTheComponent>)
815
- ```
816
-
817
- e.g :
818
- ```python
819
- from iop import Utils
820
- Utils.register_component("MyCombinedBusinessOperation","MyCombinedBusinessOperation","/irisdev/app/src/python/demo/",1,"PEX.MyCombinedBusinessOperation")
821
- ```
822
-
823
- ### 6.12.2. register_file
824
-
825
- Start an embedded python shell :
826
-
827
- ```sh
828
- /usr/irissys/bin/irispython
829
- ```
830
-
831
- Then use this class method to add a new py file to the component list for interoperability.
832
-
833
- ```python
834
- from iop import Utils
835
- Utils.register_file(<File>,<OverWrite>,<PackageName>)
836
- ```
837
-
838
- e.g :
839
- ```python
840
- from iop import Utils
841
- Utils.register_file("/irisdev/app/src/python/demo/bo.py",1,"PEX")
842
- ```
843
-
844
- ### 6.12.3. register_folder
845
-
846
- Start an embedded python shell :
847
-
848
- ```sh
849
- /usr/irissys/bin/irispython
850
- ```
851
-
852
- Then use this class method to add a new py file to the component list for interoperability.
853
-
854
- ```python
855
- from iop import Utils
856
- Utils.register_folder(<Path>,<OverWrite>,<PackageName>)
857
- ```
858
-
859
- e.g :
860
- ```python
861
- from iop import Utils
862
- Utils.register_folder("/irisdev/app/src/python/demo/",1,"PEX")
863
- ```
864
-
865
- ### 6.12.4. migrate
866
-
867
- Start an embedded python shell :
868
-
869
- ```sh
870
- /usr/irissys/bin/irispython
871
- ```
872
-
873
- Then use this static method to migrate the settings file to the iris framework.
874
-
875
- ```python
876
- from iop import Utils
877
- Utils.migrate()
878
- ```
879
-
880
- #### 6.12.4.1. setting.py file
881
-
882
- This file is used to store the settings of the interoperability components.
883
-
884
- It has two sections :
885
- * `CLASSES` : This section is used to store the classes of the interoperability components.
886
- * `PRODUCTIONS` : This section is used to store the productions of the interoperability components.
887
-
888
- e.g :
889
- ```python
890
- import bp
891
- from bo import *
892
- from bs import *
893
-
894
- CLASSES = {
895
- 'Python.RedditService': RedditService,
896
- 'Python.FilterPostRoutingRule': bp.FilterPostRoutingRule,
897
- 'Python.FileOperation': FileOperation,
898
- 'Python.FileOperationWithIrisAdapter': FileOperationWithIrisAdapter,
899
- }
900
-
901
- PRODUCTIONS = [
902
- {
903
- 'dc.Python.Production': {
904
- "@Name": "dc.Demo.Production",
905
- "@TestingEnabled": "true",
906
- "@LogGeneralTraceEvents": "false",
907
- "Description": "",
908
- "ActorPoolSize": "2",
909
- "Item": [
910
- {
911
- "@Name": "Python.FileOperation",
912
- "@Category": "",
913
- "@ClassName": "Python.FileOperation",
914
- "@PoolSize": "1",
915
- "@Enabled": "true",
916
- "@Foreground": "false",
917
- "@Comment": "",
918
- "@LogTraceEvents": "true",
919
- "@Schedule": "",
920
- "Setting": {
921
- "@Target": "Host",
922
- "@Name": "%settings",
923
- "#text": "path=/tmp"
924
- }
925
- },
926
- {
927
- "@Name": "Python.RedditService",
928
- "@Category": "",
929
- "@ClassName": "Python.RedditService",
930
- "@PoolSize": "1",
931
- "@Enabled": "true",
932
- "@Foreground": "false",
933
- "@Comment": "",
934
- "@LogTraceEvents": "false",
935
- "@Schedule": "",
936
- "Setting": [
937
- {
938
- "@Target": "Host",
939
- "@Name": "%settings",
940
- "#text": "limit=10\nother<10"
941
- }
942
- ]
943
- },
944
- {
945
- "@Name": "Python.FilterPostRoutingRule",
946
- "@Category": "",
947
- "@ClassName": "Python.FilterPostRoutingRule",
948
- "@PoolSize": "1",
949
- "@Enabled": "true",
950
- "@Foreground": "false",
951
- "@Comment": "",
952
- "@LogTraceEvents": "false",
953
- "@Schedule": ""
954
- }
955
- ]
956
- }
957
- }
958
- ]
959
- ```
960
-
961
- ##### 6.12.4.1.1. CLASSES section
962
-
963
- This section is used to store the classes of the interoperability components.
964
-
965
- It aims to help to register the components.
966
-
967
- This dictionary has the following structure :
968
- * Key : The name of the component
969
- * Value :
970
- * The class of the component (you have to import it before)
971
- * The module of the component (you have to import it before)
972
- * Another dictionary with the following structure :
973
- * `module` : Name of the module of the component (optional)
974
- * `class` : Name of the class of the component (optional)
975
- * `path` : The path of the component (mandatory)
976
-
977
- e.g :
978
-
979
- When Value is a class or a module:
980
- ```python
981
- import bo
982
- import bp
983
- from bs import RedditService
984
-
985
- CLASSES = {
986
- 'Python.RedditService': RedditService,
987
- 'Python.FilterPostRoutingRule': bp.FilterPostRoutingRule,
988
- 'Python.FileOperation': bo,
989
- }
990
- ```
991
-
992
- When Value is a dictionary :
993
- ```python
994
- CLASSES = {
995
- 'Python.RedditService': {
996
- 'module': 'bs',
997
- 'class': 'RedditService',
998
- 'path': '/irisdev/app/src/python/demo/'
999
- },
1000
- 'Python.Module': {
1001
- 'module': 'bp',
1002
- 'path': '/irisdev/app/src/python/demo/'
1003
- },
1004
- 'Python.Package': {
1005
- 'path': '/irisdev/app/src/python/demo/'
1006
- },
1007
- }
1008
- ```
1009
-
1010
- ##### 6.12.4.1.2. Productions section
1011
-
1012
- This section is used to store the productions of the interoperability components.
1013
-
1014
- It aims to help to register a production.
1015
-
1016
- This list has the following structure :
1017
- * A list of dictionary with the following structure :
1018
- * `dc.Python.Production` : The name of the production
1019
- * `@Name` : The name of the production
1020
- * `@TestingEnabled` : The testing enabled of the production
1021
- * `@LogGeneralTraceEvents` : The log general trace events of the production
1022
- * `Description` : The description of the production
1023
- * `ActorPoolSize` : The actor pool size of the production
1024
- * `Item` : The list of the items of the production
1025
- * `@Name` : The name of the item
1026
- * `@Category` : The category of the item
1027
- * `@ClassName` : The class name of the item
1028
- * `@PoolSize` : The pool size of the item
1029
- * `@Enabled` : The enabled of the item
1030
- * `@Foreground` : The foreground of the item
1031
- * `@Comment` : The comment of the item
1032
- * `@LogTraceEvents` : The log trace events of the item
1033
- * `@Schedule` : The schedule of the item
1034
- * `Setting` : The list of the settings of the item
1035
- * `@Target` : The target of the setting
1036
- * `@Name` : The name of the setting
1037
- * `#text` : The value of the setting
1038
-
1039
- The minimum structure of a production is :
1040
- ```python
1041
- PRODUCTIONS = [
1042
- {
1043
- 'UnitTest.Production': {
1044
- "Item": [
1045
- {
1046
- "@Name": "Python.FileOperation",
1047
- "@ClassName": "Python.FileOperation",
1048
- },
1049
- {
1050
- "@Name": "Python.EmailOperation",
1051
- "@ClassName": "UnitTest.Package.EmailOperation"
1052
- }
1053
- ]
1054
- }
1055
- }
1056
- ]
1057
- ```
1058
-
1059
- You can also set in `@ClassName` an item from the CLASSES section.
1060
-
1061
- e.g :
1062
- ```python
1063
- from bo import FileOperation
1064
- PRODUCTIONS = [
1065
- {
1066
- 'UnitTest.Production': {
1067
- "Item": [
1068
- {
1069
- "@Name": "Python.FileOperation",
1070
- "@ClassName": FileOperation,
1071
- }
1072
- ]
1073
- }
1074
- }
1075
- ]
1076
- ```
1077
-
1078
- As the production is a dictionary, you can add in value of the production dictionary an environment variable.
1079
-
1080
- e.g :
1081
- ```python
1082
- import os
1083
-
1084
- PRODUCTIONS = [
1085
- {
1086
- 'UnitTest.Production': {
1087
- "Item": [
1088
- {
1089
- "@Name": "Python.FileOperation",
1090
- "@ClassName": "Python.FileOperation",
1091
- "Setting": {
1092
- "@Target": "Host",
1093
- "@Name": "%settings",
1094
- "#text": os.environ['SETTINGS']
1095
- }
1096
- }
1097
- ]
1098
- }
1099
- }
1100
- ]
1101
- ```
1102
-
1103
- ## 6.13. Direct use of IOP
1104
-
1105
- If you don't want to use the register_component util. You can add a IOP.BusinessService component directly into the management portal and configure the properties :
1106
- - %module :
1107
- - Module name of your python code
1108
- - %classname :
1109
- - Classname of you component
1110
- - %classpaths
1111
- - Path where you component is.
1112
- - This can one or more Classpaths (separated by '|' character) needed in addition to PYTHON_PATH
1113
-
1114
- e.g :
1115
- <img width="800" alt="component-config" src="https://user-images.githubusercontent.com/47849411/131316308-e1898b19-11df-433b-b1c6-7f69d5cc9974.png">
1116
-
1117
- # 7. Command line
1118
-
1119
- Since version 2.3.1, you can use the command line to register your components and productions.
1120
-
1121
- To use it, you have to use the following command :
1122
- ```bash
1123
- iop
1124
- ```
1125
-
1126
- output :
1127
- ```bash
1128
- usage: python3 -m iop [-h] [-d DEFAULT] [-l] [-s START] [-k] [-S] [-r] [-M MIGRATE] [-e EXPORT] [-x] [-v] [-L]
1129
- optional arguments:
1130
- -h, --help display help and default production name
1131
- -d DEFAULT, --default DEFAULT
1132
- set the default production
1133
- -l, --lists list productions
1134
- -s START, --start START
1135
- start a production
1136
- -k, --kill kill a production (force stop)
1137
- -S, --stop stop a production
1138
- -r, --restart restart a production
1139
- -M MIGRATE, --migrate MIGRATE
1140
- migrate production and classes with settings file
1141
- -e EXPORT, --export EXPORT
1142
- export a production
1143
- -x, --status status a production
1144
- -v, --version display version
1145
- -L, --log display log
1146
-
1147
- default production: PEX.Production
1148
- ```
1149
-
1150
- ## 7.1. help
1151
-
1152
- The help command display the help and the default production name.
1153
-
1154
- ```bash
1155
- iop -h
1156
- ```
1157
-
1158
- output :
1159
- ```bash
1160
- usage: python3 -m iop [-h] [-d DEFAULT] [-l] [-s START] [-k] [-S] [-r] [-M MIGRATE] [-e EXPORT] [-x] [-v] [-L]
1161
- ...
1162
- default production: PEX.Production
1163
- ```
1164
-
1165
- ## 7.2. default
1166
-
1167
- The default command set the default production.
1168
-
1169
- With no argument, it display the default production.
1170
-
1171
- ```bash
1172
- iop -d
1173
- ```
1174
-
1175
- output :
1176
- ```bash
1177
- default production: PEX.Production
1178
- ```
1179
-
1180
- With an argument, it set the default production.
1181
-
1182
- ```bash
1183
- iop -d PEX.Production
1184
- ```
1185
-
1186
- ## 7.3. lists
1187
-
1188
- The lists command list productions.
1189
-
1190
- ```bash
1191
- iop -l
1192
- ```
1193
-
1194
- output :
1195
- ```bash
1196
- {
1197
- "PEX.Production": {
1198
- "Status": "Stopped",
1199
- "LastStartTime": "2023-05-31 11:13:51.000",
1200
- "LastStopTime": "2023-05-31 11:13:54.153",
1201
- "AutoStart": 0
1202
- }
1203
- }
1204
- ```
1205
-
1206
- ## 7.4. start
1207
-
1208
- The start command start a production.
1209
-
1210
- To exit the command, you have to press CTRL+C.
1211
-
1212
- ```bash
1213
- iop -s PEX.Production
1214
- ```
1215
-
1216
- output :
1217
- ```bash
1218
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting production
1219
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.FileOperation
1220
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.EmailOperation
1221
- ...
1222
- ```
1223
-
1224
- ## 7.5. kill
1225
-
1226
- The kill command kill a production (force stop).
1227
-
1228
- Kill command is the same as stop command but with a force stop.
1229
-
1230
- Kill command doesn't take an argument because only one production can be running.
1231
-
1232
- ```bash
1233
- iop -k
1234
- ```
1235
-
1236
- ## 7.6. stop
1237
-
1238
- The stop command stop a production.
1239
-
1240
- Stop command doesn't take an argument because only one production can be running.
1241
-
1242
- ```bash
1243
- iop -S
1244
- ```
1245
-
1246
- ## 7.7. restart
1247
-
1248
- The restart command restart a production.
1249
-
1250
- Restart command doesn't take an argument because only one production can be running.
1251
-
1252
- ```bash
1253
- iop -r
1254
- ```
1255
-
1256
- ## 7.8. migrate
1257
-
1258
- The migrate command migrate a production and classes with settings file.
1259
-
1260
- Migrate command must take the absolute path of the settings file.
1261
-
1262
- Settings file must be in the same folder as the python code.
1263
-
1264
- ```bash
1265
- iop -M /tmp/settings.py
1266
- ```
1267
-
1268
- ## 7.9. export
1269
-
1270
- The export command export a production.
1271
-
1272
- If no argument is given, the export command export the default production.
1273
-
1274
- ```bash
1275
- iop -e
1276
- ```
1277
-
1278
- If an argument is given, the export command export the production given in argument.
1279
-
1280
- ```bash
1281
- iop -e PEX.Production
1282
- ```
1283
-
1284
- output :
1285
- ```bash
1286
- {
1287
- "Production": {
1288
- "@Name": "PEX.Production",
1289
- "@TestingEnabled": "true",
1290
- "@LogGeneralTraceEvents": "false",
1291
- "Description": "",
1292
- "ActorPoolSize": "2",
1293
- "Item": [
1294
- {
1295
- "@Name": "Python.FileOperation",
1296
- "@Category": "",
1297
- "@ClassName": "Python.FileOperation",
1298
- "@PoolSize": "1",
1299
- "@Enabled": "true",
1300
- "@Foreground": "false",
1301
- "@Comment": "",
1302
- "@LogTraceEvents": "true",
1303
- "@Schedule": "",
1304
- "Setting": [
1305
- {
1306
- "@Target": "Adapter",
1307
- "@Name": "Charset",
1308
- "#text": "utf-8"
1309
- },
1310
- {
1311
- "@Target": "Adapter",
1312
- "@Name": "FilePath",
1313
- "#text": "/irisdev/app/output/"
1314
- },
1315
- {
1316
- "@Target": "Host",
1317
- "@Name": "%settings",
1318
- "#text": "path=/irisdev/app/output/"
1319
- }
1320
- ]
1321
- }
1322
- ]
1323
- }
1324
- }
1325
- ```
1326
-
1327
- ## 7.10. status
1328
-
1329
- The status command status a production.
1330
-
1331
- Status command doesn't take an argument because only one production can be running.
1332
-
1333
- ```bash
1334
- iop -x
1335
- ```
1336
-
1337
- output :
1338
- ```bash
1339
- {
1340
- "Production": "PEX.Production",
1341
- "Status": "stopped"
1342
- }
1343
- ```
1344
-
1345
- Status can be :
1346
- - stopped
1347
- - running
1348
- - suspended
1349
- - troubled
1350
-
1351
- ## 7.11. version
1352
-
1353
- The version command display the version.
1354
-
1355
- ```bash
1356
- iop -v
1357
- ```
1358
-
1359
- output :
1360
- ```bash
1361
- 2.3.0
1362
- ```
1363
-
1364
- ## 7.12. log
1365
-
1366
- The log command display the log.
1367
-
1368
- To exit the command, you have to press CTRL+C.
1369
-
1370
- ```bash
1371
- iop -L
1372
- ```
1373
-
1374
- output :
1375
- ```bash
1376
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting production
1377
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.FileOperation
1378
- 2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.EmailOperation
1379
- ...
1380
- ```
1381
-
1382
- # 8. Credits
1383
-
1384
- Most of the code came from PEX for Python by Mo Cheng and Summer Gerry.
1385
-
1386
- Works only on IRIS 2021.2 +
1387
-
1388
- # 9. Benchmarks
1389
-
1390
- 8 senarios with thoses parameters :
1391
- - 100 messages
1392
- - body : simple string `test`
1393
-
1394
- | Scenario | Time (s) |
1395
- | --- | --- |
1396
- | Python BP to Python BO with Iris Message | 0.739 |
1397
- | Python BP to Python BO with Python Message | 0.732 |
1398
- | ObjetScript BP to Python BO with Iris Message | 0.594 |
1399
- | ObjetScript BP to Python BO with Python Message | 0.642 |
1400
- | Python BP to ObjetScript BO with Iris Message | 0.642 |
1401
- | Python BP to ObjetScript BO with Python Message | 0.675 |
1402
- | ObjetScript BP to ObjetScript BO with Iris Message | 0.159 |
1403
- | ObjetScript BP to ObjetScript BO with Python Message | 0.182 |