Skip to content

Commit 45a7995

Browse files
committed
Add documentation and setup files for IoP (Interoperability On Python)
1 parent 384187a commit 45a7995

File tree

7 files changed

+554
-0
lines changed

7 files changed

+554
-0
lines changed

.github/workflows/docs.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Docs
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the master branch
8+
push:
9+
branches: [ master ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a single job called "build"
17+
build:
18+
# The type of runner that the job will run on
19+
runs-on: ubuntu-latest
20+
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24+
- uses: actions/checkout@v2
25+
with:
26+
fetch-depth: 0
27+
- uses: actions/setup-python@v2
28+
- run: pip install --upgrade pip && pip install mkdocs mkdocs-gen-files
29+
- run: git config user.name 'github-actions[bot]' && git config user.email 'github-actions[bot]@users.noreply.github.com'
30+
- name: Publish docs
31+
run: mkdocs gh-deploy

docs/command-line.md

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
# Command line
2+
3+
Since version 2.3.1, you can use the command line to register your components and productions.
4+
5+
To use it, you have to use the following command :
6+
```bash
7+
iop
8+
```
9+
10+
output :
11+
```bash
12+
usage: python3 -m iop [-h] [-d DEFAULT] [-l] [-s START] [-k] [-S] [-r] [-M MIGRATE] [-e EXPORT] [-x] [-v] [-L]
13+
optional arguments:
14+
-h, --help display help and default production name
15+
-d DEFAULT, --default DEFAULT
16+
set the default production
17+
-l, --lists list productions
18+
-s START, --start START
19+
start a production
20+
-k, --kill kill a production (force stop)
21+
-S, --stop stop a production
22+
-r, --restart restart a production
23+
-M MIGRATE, --migrate MIGRATE
24+
migrate production and classes with settings file
25+
-e EXPORT, --export EXPORT
26+
export a production
27+
-x, --status status a production
28+
-v, --version display version
29+
-L, --log display log
30+
31+
default production: PEX.Production
32+
```
33+
34+
## help
35+
36+
The help command display the help and the default production name.
37+
38+
```bash
39+
iop -h
40+
```
41+
42+
output :
43+
```bash
44+
usage: python3 -m iop [-h] [-d DEFAULT] [-l] [-s START] [-k] [-S] [-r] [-M MIGRATE] [-e EXPORT] [-x] [-v] [-L]
45+
...
46+
default production: PEX.Production
47+
```
48+
49+
## default
50+
51+
The default command set the default production.
52+
53+
With no argument, it display the default production.
54+
55+
```bash
56+
iop -d
57+
```
58+
59+
output :
60+
```bash
61+
default production: PEX.Production
62+
```
63+
64+
With an argument, it set the default production.
65+
66+
```bash
67+
iop -d PEX.Production
68+
```
69+
70+
## lists
71+
72+
The lists command list productions.
73+
74+
```bash
75+
iop -l
76+
```
77+
78+
output :
79+
```bash
80+
{
81+
"PEX.Production": {
82+
"Status": "Stopped",
83+
"LastStartTime": "2023-05-31 11:13:51.000",
84+
"LastStopTime": "2023-05-31 11:13:54.153",
85+
"AutoStart": 0
86+
}
87+
}
88+
```
89+
90+
## start
91+
92+
The start command start a production.
93+
94+
To exit the command, you have to press CTRL+C.
95+
96+
```bash
97+
iop -s PEX.Production
98+
```
99+
100+
output :
101+
```bash
102+
2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting production
103+
2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.FileOperation
104+
2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.EmailOperation
105+
...
106+
```
107+
108+
## kill
109+
110+
The kill command kill a production (force stop).
111+
112+
Kill command is the same as stop command but with a force stop.
113+
114+
Kill command doesn't take an argument because only one production can be running.
115+
116+
```bash
117+
iop -k
118+
```
119+
120+
## stop
121+
122+
The stop command stop a production.
123+
124+
Stop command doesn't take an argument because only one production can be running.
125+
126+
```bash
127+
iop -S
128+
```
129+
130+
## restart
131+
132+
The restart command restart a production.
133+
134+
Restart command doesn't take an argument because only one production can be running.
135+
136+
```bash
137+
iop -r
138+
```
139+
140+
## migrate
141+
142+
The migrate command migrate a production and classes with settings file.
143+
144+
Migrate command must take the absolute path of the settings file.
145+
146+
Settings file must be in the same folder as the python code.
147+
148+
```bash
149+
iop -M /tmp/settings.py
150+
```
151+
152+
## export
153+
154+
The export command export a production.
155+
156+
If no argument is given, the export command export the default production.
157+
158+
```bash
159+
iop -e
160+
```
161+
162+
If an argument is given, the export command export the production given in argument.
163+
164+
```bash
165+
iop -e PEX.Production
166+
```
167+
168+
output :
169+
```bash
170+
{
171+
"Production": {
172+
"@Name": "PEX.Production",
173+
"@TestingEnabled": "true",
174+
"@LogGeneralTraceEvents": "false",
175+
"Description": "",
176+
"ActorPoolSize": "2",
177+
"Item": [
178+
{
179+
"@Name": "Python.FileOperation",
180+
"@Category": "",
181+
"@ClassName": "Python.FileOperation",
182+
"@PoolSize": "1",
183+
"@Enabled": "true",
184+
"@Foreground": "false",
185+
"@Comment": "",
186+
"@LogTraceEvents": "true",
187+
"@Schedule": "",
188+
"Setting": [
189+
{
190+
"@Target": "Adapter",
191+
"@Name": "Charset",
192+
"#text": "utf-8"
193+
},
194+
{
195+
"@Target": "Adapter",
196+
"@Name": "FilePath",
197+
"#text": "/irisdev/app/output/"
198+
},
199+
{
200+
"@Target": "Host",
201+
"@Name": "%settings",
202+
"#text": "path=/irisdev/app/output/"
203+
}
204+
]
205+
}
206+
]
207+
}
208+
}
209+
```
210+
211+
## status
212+
213+
The status command status a production.
214+
215+
Status command doesn't take an argument because only one production can be running.
216+
217+
```bash
218+
iop -x
219+
```
220+
221+
output :
222+
```bash
223+
{
224+
"Production": "PEX.Production",
225+
"Status": "stopped"
226+
}
227+
```
228+
229+
Status can be :
230+
- stopped
231+
- running
232+
- suspended
233+
- troubled
234+
235+
## version
236+
237+
The version command display the version.
238+
239+
```bash
240+
iop -v
241+
```
242+
243+
output :
244+
```bash
245+
2.3.0
246+
```
247+
248+
## log
249+
250+
The log command display the log.
251+
252+
To exit the command, you have to press CTRL+C.
253+
254+
```bash
255+
iop -L
256+
```
257+
258+
output :
259+
```bash
260+
2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting production
261+
2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.FileOperation
262+
2021-08-30 15:13:51.000 [PEX.Production] INFO: Starting item Python.EmailOperation
263+
...
264+
```

docs/example.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Example
2+
3+
Add an example of a business operation and messages in Python.
4+
5+
## Business Operation
6+
7+
Here is an example of a business operation in Python:
8+
9+
```python
10+
from iop import BusinessOperation, Message
11+
from dataclasses import dataclass
12+
13+
class MyBusinessOperation(BusinessOperation):
14+
15+
def on_init(self):
16+
# This method is called when the component is becoming active in the production
17+
self.log_info("[Python] ...MyBusinessOperation:on_init() is called")
18+
return
19+
20+
def on_teardown(self):
21+
# This method is called when the component is becoming inactive in the production
22+
self.log_info("[Python] ...MyBusinessOperation:on_teardown() is called")
23+
return
24+
25+
def on_message(self, message_input: 'MyRequest'):
26+
# Called from service/process/operation, message is of type MyRequest with property request_string
27+
self.log_info("[Python] ...MyBusinessOperation:on_message() is called with message:" + message_input.request_string)
28+
response = MyResponse("...MyBusinessOperation:on_message() echos")
29+
return response
30+
31+
@dataclass
32+
class MyRequest(Message):
33+
request_string: str = None
34+
35+
@dataclass
36+
class MyResponse(Message):
37+
my_string: str = None
38+
```
39+
40+
## Register a Component
41+
42+
To register a component, you need to create a setting.py file in the root of your project.
43+
44+
This file will be used to register your classes and productions.
45+
46+
Example of setting.py:
47+
48+
```python
49+
import bo
50+
51+
CLASSES = {
52+
"Python.MyBusinessOperation": bo.MyBusinessOperation
53+
}
54+
```
55+
56+
Then you can use the iop command line to register your component:
57+
58+
```bash
59+
iop --migrate /path/to/your/project/setting.py
60+
```

0 commit comments

Comments
 (0)