|
1 | | -# compas_eve |
| 1 | +# COMPAS EVE |
2 | 2 |
|
3 | | -COMPAS Event Extensions: adds event-based communication infrastructure to the COMPAS framework. |
| 3 | +Event-based communication for the COMPAS framework. |
4 | 4 |
|
| 5 | +```python |
| 6 | +>>> import compas_eve as eve |
| 7 | +>>> pub = eve.Publisher("/hello_world") |
| 8 | +>>> sub = eve.EchoSubscriber("/hello_world") |
| 9 | +>>> sub.subscribe() |
| 10 | +>>> for i in range(10): |
| 11 | +... pub.publish(dict(text=f"Hello World {i}")) |
| 12 | +``` |
5 | 13 |
|
6 | | -## Getting started with this project |
| 14 | +It is extremely easy to send messages around. COMPAS EVE supports |
| 15 | +different transport mechanisms to send messages between different threads, processes, computers, etc. |
7 | 16 |
|
8 | | -### Setup code editor |
| 17 | +## Installation |
9 | 18 |
|
10 | | -1. Open project folder in VS Code |
11 | | -2. Select python environment for the project |
12 | | -3. First time using VS Code and on Windows? Make sure select the correct terminal profile: `Ctrl+Shift+P`, `Terminal: Select Default Profile` and select `Command Prompt`. |
| 19 | +Install using `pip`: |
13 | 20 |
|
14 | | -> All terminal commands in the following sections can be run from the VS Code integrated terminal. |
| 21 | +```bash |
15 | 22 |
|
| 23 | + pip install compas_eve |
| 24 | +``` |
16 | 25 |
|
17 | | -### First steps with git |
| 26 | +Or using `conda`: |
18 | 27 |
|
19 | | -1. Go to the `Source control` tab |
20 | | -2. Make an initial commit with all newly created files |
| 28 | +```bash |
21 | 29 |
|
| 30 | + conda install compas_eve |
| 31 | +``` |
22 | 32 |
|
23 | | -### First steps with code |
| 33 | +## Supported features |
24 | 34 |
|
25 | | -1. Install the newly created project |
| 35 | +* Publisher/subscriber communication model (N-to-N communication) |
| 36 | +* In-process events |
| 37 | +* MQTT support |
| 38 | +* CPython & IronPython support |
26 | 39 |
|
27 | | - pip install -e . |
| 40 | +## Examples |
28 | 41 |
|
29 | | -2. Install it on Rhino |
| 42 | +### In-process events |
30 | 43 |
|
31 | | - python -m compas_rhino.install |
| 44 | +The simplest option is to use in-process events. This works for |
| 45 | +simple applications and allows to communicate between threads. |
32 | 46 |
|
| 47 | +```python |
| 48 | +import compas_eve as eve |
33 | 49 |
|
34 | | -### Code conventions |
| 50 | +pub = eve.Publisher("/hello_world") |
| 51 | +sub = eve.EchoSubscriber("/hello_world") |
| 52 | +sub.subscribe() |
35 | 53 |
|
36 | | -Code convention follows [PEP8](https://pep8.org/) style guidelines and line length of 120 characters. |
| 54 | +for i in range(10): |
| 55 | + pub.publish(dict(text=f"Hello World {i}")) |
| 56 | +``` |
37 | 57 |
|
38 | | -1. Check adherence to style guidelines |
| 58 | +### MQTT |
39 | 59 |
|
40 | | - invoke lint |
| 60 | +MQTT is a protocol that allows to send messages between different |
| 61 | +systems/computers. Using MQTT is very simple as well: |
41 | 62 |
|
42 | | -2. Format code automatically |
| 63 | +```python |
| 64 | +import compas_eve as eve |
| 65 | +from compas_eve.mqtt import MqttTransport |
43 | 66 |
|
44 | | - invoke format |
| 67 | +tx = MqttTransport("broker.hivemq.com") |
| 68 | +eve.set_default_transport(tx) |
45 | 69 |
|
| 70 | +pub = eve.Publisher("/hello_world") |
| 71 | +sub = eve.EchoSubscriber("/hello_world") |
| 72 | +sub.subscribe() |
46 | 73 |
|
47 | | -### Documentation |
| 74 | +for i in range(10): |
| 75 | + pub.publish(dict(text=f"Hello World {i}")) |
| 76 | +``` |
48 | 77 |
|
49 | | -Documentation is generated automatically out of docstrings and [RST](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html) files in this repository |
| 78 | +This example shows how to send and receive from a single script, but |
| 79 | +running publishers and subscribers on different scripts, different processes, or even different computers will work the exact same way. |
50 | 80 |
|
51 | | -1. Generate the docs |
52 | 81 |
|
53 | | - invoke docs |
| 82 | +### Usage from Rhinoceros 3D |
54 | 83 |
|
55 | | -2. Check links in docs are valid |
| 84 | +It is possible to use the same code from within Rhino/Grasshopper. |
56 | 85 |
|
57 | | - invoke linkcheck |
| 86 | +Make sure you have installed it to Rhino using the COMPAS installation mechanism: |
58 | 87 |
|
59 | | -3. Open docs in your browser (file explorer -> `dist/docs/index.html`) |
60 | | - |
61 | | - |
62 | | -### Testing |
63 | | - |
64 | | -Tests are written using the [pytest](https://docs.pytest.org/) framework |
65 | | - |
66 | | -1. Run all tests from terminal |
67 | | - |
68 | | - invoke test |
69 | | - |
70 | | -2. Or run them from VS Code from the `Testing` tab |
71 | | - |
72 | | - |
73 | | -### Developing Grasshopper components |
74 | | - |
75 | | -We use [Grasshopper Componentizer](https://github.com/compas-dev/compas-actions.ghpython_components) to develop Python components that can be stored and edited on git. |
76 | | - |
77 | | -1. Build components |
78 | | - |
79 | | - invoke build-ghuser-components |
80 | | - |
81 | | -2. Install components on Rhino |
82 | | - |
83 | | - python -m compas_rhino.install |
84 | | - |
85 | | - |
86 | | -### Publish release |
87 | | - |
88 | | -Releases follow the [semver](https://semver.org/spec/v2.0.0.html) versioning convention. |
89 | | - |
90 | | -1. Create a new release |
91 | | - |
92 | | - invoke release major |
| 88 | +```bash |
| 89 | + python -m compas_rhino.install -v 7.0 |
| 90 | +``` |
0 commit comments