ohra 0.1.0__tar.gz
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.
- ohra-0.1.0/LICENSE +201 -0
- ohra-0.1.0/NOTICE +39 -0
- ohra-0.1.0/PKG-INFO +175 -0
- ohra-0.1.0/README.md +131 -0
- ohra-0.1.0/pyproject.toml +74 -0
- ohra-0.1.0/setup.cfg +4 -0
- ohra-0.1.0/src/ohra/__init__.py +215 -0
- ohra-0.1.0/src/ohra/behavior.py +215 -0
- ohra-0.1.0/src/ohra/cell.py +667 -0
- ohra-0.1.0/src/ohra/cluster/__init__.py +72 -0
- ohra-0.1.0/src/ohra/cluster/core.py +1656 -0
- ohra-0.1.0/src/ohra/cluster/failure_detector.py +304 -0
- ohra-0.1.0/src/ohra/cluster/gossip.py +412 -0
- ohra-0.1.0/src/ohra/cluster/reachability.py +183 -0
- ohra-0.1.0/src/ohra/cluster/sbr.py +802 -0
- ohra-0.1.0/src/ohra/cluster/sharding/__init__.py +130 -0
- ohra-0.1.0/src/ohra/cluster/sharding/coordinator.py +817 -0
- ohra-0.1.0/src/ohra/cluster/sharding/region.py +392 -0
- ohra-0.1.0/src/ohra/cluster/sharding/shard.py +511 -0
- ohra-0.1.0/src/ohra/cluster/singleton.py +1007 -0
- ohra-0.1.0/src/ohra/cluster/vector_clock.py +46 -0
- ohra-0.1.0/src/ohra/context.py +163 -0
- ohra-0.1.0/src/ohra/coordinated_shutdown.py +224 -0
- ohra-0.1.0/src/ohra/discovery.py +59 -0
- ohra-0.1.0/src/ohra/ext/__init__.py +2 -0
- ohra-0.1.0/src/ohra/ext/fastapi.py +59 -0
- ohra-0.1.0/src/ohra/ext/postgres.py +140 -0
- ohra-0.1.0/src/ohra/ext/shm.py +80 -0
- ohra-0.1.0/src/ohra/mailbox.py +31 -0
- ohra-0.1.0/src/ohra/management/__init__.py +195 -0
- ohra-0.1.0/src/ohra/management/bootstrap.py +690 -0
- ohra-0.1.0/src/ohra/management/cluster_http.py +109 -0
- ohra-0.1.0/src/ohra/management/health.py +76 -0
- ohra-0.1.0/src/ohra/management/http.py +228 -0
- ohra-0.1.0/src/ohra/management/kubernetes.py +181 -0
- ohra-0.1.0/src/ohra/patterns.py +138 -0
- ohra-0.1.0/src/ohra/persistence.py +276 -0
- ohra-0.1.0/src/ohra/py.typed +0 -0
- ohra-0.1.0/src/ohra/receptionist.py +372 -0
- ohra-0.1.0/src/ohra/ref.py +95 -0
- ohra-0.1.0/src/ohra/remote/__init__.py +18 -0
- ohra-0.1.0/src/ohra/remote/remoting.py +442 -0
- ohra-0.1.0/src/ohra/remote/serialization.py +164 -0
- ohra-0.1.0/src/ohra/result.py +19 -0
- ohra-0.1.0/src/ohra/routers.py +73 -0
- ohra-0.1.0/src/ohra/signals.py +49 -0
- ohra-0.1.0/src/ohra/supervision.py +81 -0
- ohra-0.1.0/src/ohra/system.py +236 -0
- ohra-0.1.0/src/ohra.egg-info/PKG-INFO +175 -0
- ohra-0.1.0/src/ohra.egg-info/SOURCES.txt +69 -0
- ohra-0.1.0/src/ohra.egg-info/dependency_links.txt +1 -0
- ohra-0.1.0/src/ohra.egg-info/requires.txt +23 -0
- ohra-0.1.0/src/ohra.egg-info/top_level.txt +1 -0
- ohra-0.1.0/tests/test_batching.py +228 -0
- ohra-0.1.0/tests/test_compute.py +141 -0
- ohra-0.1.0/tests/test_coordinated_shutdown.py +237 -0
- ohra-0.1.0/tests/test_core.py +318 -0
- ohra-0.1.0/tests/test_discovery.py +32 -0
- ohra-0.1.0/tests/test_fastapi.py +94 -0
- ohra-0.1.0/tests/test_lifecycle.py +176 -0
- ohra-0.1.0/tests/test_persistence.py +520 -0
- ohra-0.1.0/tests/test_postgres_store.py +137 -0
- ohra-0.1.0/tests/test_receptionist.py +217 -0
- ohra-0.1.0/tests/test_remote.py +451 -0
- ohra-0.1.0/tests/test_routers.py +103 -0
- ohra-0.1.0/tests/test_serialization.py +132 -0
- ohra-0.1.0/tests/test_sharding.py +540 -0
- ohra-0.1.0/tests/test_shm.py +98 -0
- ohra-0.1.0/tests/test_stop_after_pending.py +162 -0
- ohra-0.1.0/tests/test_supervision.py +169 -0
- ohra-0.1.0/tests/test_timers_stash.py +279 -0
ohra-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Haruhiko Nishi
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
ohra-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
ohra
|
|
2
|
+
Copyright 2026 Haruhiko Nishi
|
|
3
|
+
|
|
4
|
+
ohra is not affiliated with or endorsed by the Apache Software Foundation
|
|
5
|
+
or the Apache Pekko project.
|
|
6
|
+
|
|
7
|
+
---------------
|
|
8
|
+
|
|
9
|
+
The following files are derived from examples in the Apache Pekko documentation
|
|
10
|
+
and test sources, which are licensed under the Apache License, Version 2.0:
|
|
11
|
+
|
|
12
|
+
examples/chatroom.py
|
|
13
|
+
examples/interaction_patterns/adapted_response.py
|
|
14
|
+
examples/interaction_patterns/aggregator.py
|
|
15
|
+
examples/interaction_patterns/ask_between_actors.py
|
|
16
|
+
examples/interaction_patterns/ask_from_outside.py
|
|
17
|
+
examples/interaction_patterns/fire_and_forget.py
|
|
18
|
+
examples/interaction_patterns/generic_response_wrapper.py
|
|
19
|
+
examples/interaction_patterns/ignoring_replies.py
|
|
20
|
+
examples/interaction_patterns/per_session_child.py
|
|
21
|
+
examples/interaction_patterns/pipe_to_self.py
|
|
22
|
+
examples/interaction_patterns/request_response.py
|
|
23
|
+
examples/interaction_patterns/scheduling_to_self.py
|
|
24
|
+
examples/interaction_patterns/tail_chopping.py
|
|
25
|
+
|
|
26
|
+
The attribution notices from the Apache Pekko NOTICE file that pertain to that
|
|
27
|
+
material follow.
|
|
28
|
+
|
|
29
|
+
Apache Pekko
|
|
30
|
+
Copyright 2022-2026 The Apache Software Foundation
|
|
31
|
+
|
|
32
|
+
This product includes software developed at
|
|
33
|
+
The Apache Software Foundation (https://www.apache.org/).
|
|
34
|
+
|
|
35
|
+
This product contains significant parts that were originally based on software from Lightbend (Akka <https://akka.io/>).
|
|
36
|
+
Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
|
|
37
|
+
|
|
38
|
+
Apache Pekko is derived from Akka 2.6.x, the last version that was distributed under the
|
|
39
|
+
Apache License, Version 2.0 License.
|
ohra-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ohra
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Apache Pekko Typed style actors on asyncio. Not affiliated with the Apache Software Foundation.
|
|
5
|
+
Author: Haruhiko Nishi
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/hanishi/ohra
|
|
8
|
+
Project-URL: Documentation, https://github.com/hanishi/ohra/tree/main/docs/book
|
|
9
|
+
Project-URL: Issues, https://github.com/hanishi/ohra/issues
|
|
10
|
+
Keywords: actors,asyncio,pekko,actor-model,cluster,sharding
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Framework :: AsyncIO
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
19
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
|
|
28
|
+
Requires-Dist: pyright>=1.1.380; extra == "dev"
|
|
29
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.17; extra == "dev"
|
|
31
|
+
Provides-Extra: numpy
|
|
32
|
+
Requires-Dist: numpy>=2.0; extra == "numpy"
|
|
33
|
+
Provides-Extra: web
|
|
34
|
+
Requires-Dist: fastapi>=0.115; extra == "web"
|
|
35
|
+
Requires-Dist: uvicorn>=0.30; extra == "web"
|
|
36
|
+
Requires-Dist: websockets>=13; extra == "web"
|
|
37
|
+
Provides-Extra: postgres
|
|
38
|
+
Requires-Dist: psycopg[binary]>=3.2; extra == "postgres"
|
|
39
|
+
Requires-Dist: psycopg-pool>=3.2; extra == "postgres"
|
|
40
|
+
Provides-Extra: torch
|
|
41
|
+
Requires-Dist: torch>=2.5; extra == "torch"
|
|
42
|
+
Requires-Dist: numpy>=2.0; extra == "torch"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
<p align="center"><img src="https://raw.githubusercontent.com/hanishi/ohra/main/docs/logo.png" width="160" alt="ohra logo: an ear of barley"></p>
|
|
46
|
+
|
|
47
|
+
# ohra
|
|
48
|
+
|
|
49
|
+
[](https://github.com/hanishi/ohra/actions/workflows/ci.yml)
|
|
50
|
+
[](https://github.com/hanishi/ohra/blob/main/pyproject.toml)
|
|
51
|
+
[](https://github.com/hanishi/ohra/blob/main/LICENSE)
|
|
52
|
+
[](https://github.com/astral-sh/ruff)
|
|
53
|
+
[](https://microsoft.github.io/pyright/)
|
|
54
|
+
[](https://github.com/hanishi/ohra/blob/main/pyproject.toml)
|
|
55
|
+
|
|
56
|
+
Apache Pekko Typed actors on asyncio, for Python 3.12+. No dependencies. *Ohra* is Finnish for barley, the crop of Pekko, the Finnish god of barley and brewing.
|
|
57
|
+
|
|
58
|
+
ohra is an independent project, built on the design of Apache Pekko and, before it, Akka, with thanks to both communities. It follows their semantics and names closely, but it is not part of the Apache Software Foundation.
|
|
59
|
+
|
|
60
|
+
An actor is a function from a message to the next behavior. Typed refs make wrong messages a type error under pyright strict. Everything runs on one event loop, so a handler can `await` without losing the guarantee that an actor handles one message at a time. numpy work goes to threads and comes back as a message.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import asyncio
|
|
64
|
+
from dataclasses import dataclass
|
|
65
|
+
from ohra import ActorRef, ActorSystem, Behavior, Behaviors
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@dataclass(frozen=True)
|
|
69
|
+
class Increment:
|
|
70
|
+
by: int
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@dataclass(frozen=True)
|
|
74
|
+
class GetTotal:
|
|
75
|
+
reply_to: ActorRef[int]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
type Command = Increment | GetTotal
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def counter(total: int = 0) -> Behavior[Command]:
|
|
82
|
+
@Behaviors.receive_message
|
|
83
|
+
def on_message(msg: Command) -> Behavior[Command]:
|
|
84
|
+
match msg:
|
|
85
|
+
case Increment(by):
|
|
86
|
+
return counter(total + by) # state is the next behavior
|
|
87
|
+
case GetTotal(reply_to):
|
|
88
|
+
reply_to.tell(total)
|
|
89
|
+
return Behaviors.same
|
|
90
|
+
|
|
91
|
+
return on_message
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async def main() -> None:
|
|
95
|
+
async with ActorSystem(counter(), "demo") as system:
|
|
96
|
+
system.tell(Increment(5))
|
|
97
|
+
print(await system.ask(GetTotal, timeout=1)) # 5
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
asyncio.run(main())
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
If you know Apache Pekko or Akka Typed, the names are the same in snake_case, and the semantics are checked against the Apache Pekko source. If you don't, [the book](https://github.com/hanishi/ohra/blob/main/docs/book/README.md) explains everything from the first actor to a sharded web app on Kubernetes.
|
|
104
|
+
|
|
105
|
+
## Install
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
pip install -e . # the library
|
|
109
|
+
pip install -e '.[numpy]' # plus numpy, for the examples that use it
|
|
110
|
+
pip install -e '.[web]' # plus FastAPI and uvicorn, for ohra.ext.fastapi and the fastapi_* examples
|
|
111
|
+
pip install -e '.[postgres]' # plus psycopg, for ohra.ext.postgres, the durable state store for clusters
|
|
112
|
+
pip install -e '.[torch]' # plus PyTorch, for the purchase predictor example
|
|
113
|
+
pip install -e '.[dev]' # plus pytest, pytest-asyncio, pyright, httpx
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## The book
|
|
117
|
+
|
|
118
|
+
[How ohra works](https://github.com/hanishi/ohra/blob/main/docs/book/README.md) is the guide and the reference, one chapter per layer, with diagrams:
|
|
119
|
+
|
|
120
|
+
1. [Actors](https://github.com/hanishi/ohra/blob/main/docs/book/01-actors.md): behaviors, ask, children and DeathWatch, supervision, timers and stash, routers, the runtime model
|
|
121
|
+
2. [The actor system](https://github.com/hanishi/ohra/blob/main/docs/book/02-actor-system.md): guardians, extensions, the receptionist, coordinated shutdown
|
|
122
|
+
3. [Persistence](https://github.com/hanishi/ohra/blob/main/docs/book/03-persistence.md): write, then install, then reply; recovery in one read
|
|
123
|
+
4. [Remoting](https://github.com/hanishi/ohra/blob/main/docs/book/04-remoting.md): addresses, `@remotable` messages, connections
|
|
124
|
+
5. [Cluster membership](https://github.com/hanishi/ohra/blob/main/docs/book/05-cluster.md): gossip, the member lifecycle, failure detection, the split-brain resolver
|
|
125
|
+
6. [Cluster singleton](https://github.com/hanishi/ohra/blob/main/docs/book/06-singleton.md): one actor on the oldest member, and the hand-over
|
|
126
|
+
7. [Sharding](https://github.com/hanishi/ohra/blob/main/docs/book/07-sharding.md): regions, shards and the coordinator, in one process and across nodes
|
|
127
|
+
8. [Management and Kubernetes](https://github.com/hanishi/ohra/blob/main/docs/book/08-management-and-kubernetes.md): health checks, bootstrap, discovery, running on Docker Desktop
|
|
128
|
+
9. [FastAPI](https://github.com/hanishi/ohra/blob/main/docs/book/09-fastapi.md): the actor system owned by the app, routes that ask actors
|
|
129
|
+
10. [numpy and shared memory](https://github.com/hanishi/ohra/blob/main/docs/book/10-numpy-and-shared-memory.md): blocking work in a thread, large arrays to another process without a copy
|
|
130
|
+
11. [Putting it together](https://github.com/hanishi/ohra/blob/main/docs/book/11-putting-it-together.md): one cart request through every layer
|
|
131
|
+
|
|
132
|
+
Appendices: [Apache Pekko names](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-pekko-names.md), [known deviations from Apache Pekko](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-deviations.md), [performance](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-performance.md), and a [glossary](https://github.com/hanishi/ohra/blob/main/docs/book/glossary.md).
|
|
133
|
+
|
|
134
|
+
## Examples
|
|
135
|
+
|
|
136
|
+
| File | Shows |
|
|
137
|
+
|---|---|
|
|
138
|
+
| `examples/counter.py` | the functional style, `ask`, supervision with `resume` |
|
|
139
|
+
| `examples/chatroom.py` | the ChatRoom from the Apache Pekko docs: sessions as children, narrowed refs, DeathWatch |
|
|
140
|
+
| `examples/remoting/` | two processes: `greeter_node.py` listens on 2552, `client_node.py` resolves it by path, tells and asks across the wire |
|
|
141
|
+
| `examples/cluster/` | `node.py NAME PORT [SEED_PORT ...]`, or `node.py NAME PORT --bootstrap PORT...` to form the cluster with no seeds through Pekko's bootstrap: start three in three terminals, watch them join, go Up and elect a leader, each node's greeter appear in every node's Receptionist listing, one counter singleton answer all of them, and the sharded counters for three ids spread over the nodes; ctrl-c a node, which leaves gracefully, and the singleton and the shards it hosted move to the others; management on port + 1000 (`curl localhost:3551/cluster/members`) |
|
|
142
|
+
| `examples/k8s/` | `node.py`, `Dockerfile` and `cluster.yaml`: a three-pod cluster on Docker Desktop Kubernetes that finds itself through the API server and spreads a simulated calculation over the pods with sharding; delete a pod and its tasks move, scale up and the new pods take shards; see [Running on Docker Desktop Kubernetes](https://github.com/hanishi/ohra/blob/main/docs/book/08-management-and-kubernetes.md#running-on-docker-desktop-kubernetes) |
|
|
143
|
+
| `examples/k8s/carts.py` | the FastAPI carts on a three-pod cluster: any pod serves any cart, each cart lives on one pod, persisted in Postgres, and moves with its items when that pod goes; `carts.yaml`, see [Carts](https://github.com/hanishi/ohra/blob/main/docs/book/08-management-and-kubernetes.md#carts-cluster-sharding-behind-a-web-app) |
|
|
144
|
+
| `examples/persisted_counter.py` | `Behaviors.persisted` with `SqliteStore`: the total survives a supervised restart and a new actor system; run it twice and it keeps counting |
|
|
145
|
+
| `examples/database_client.py` | backoff restarts of a failing setup, a stash that outlives restarts, timers, `ctx.ask` |
|
|
146
|
+
| `examples/interaction_patterns/` | one runnable file per pattern in Apache Pekko's [Interaction Patterns](https://pekko.apache.org/docs/pekko/current/typed/interaction-patterns.html) page: fire and forget, request-response, adapted response, ask between actors, ask from outside, generic response wrapper, ignoring replies, pipe to self, per-session child, aggregator, tail chopping, scheduling to self |
|
|
147
|
+
| `examples/fastapi_carts.py` | a FastAPI service over actors: one entity per cart id through `Sharding`, persisted in SQLite with `Behaviors.persisted` so carts survive passivation and restarts, typed `ask` from routes to entities |
|
|
148
|
+
| `examples/fastapi_chatroom.py` | the chat room over WebSockets: one connection actor per socket with an async handler that writes to it, rooms created on demand, and DeathWatch turning a closed socket into a "left" notice; serves a browser page at `/` |
|
|
149
|
+
| `examples/fastapi_online_learning.py` | a feedback loop behind FastAPI: predictions micro-batched into one numpy call, outcomes posted back, a learner actor taking gradient steps in a thread and hot-swapping the model; serves a playground page at `/`, and `python examples/fastapi_online_learning.py` runs the server with a demo client |
|
|
150
|
+
| `examples/fastapi_purchase_predictor.py` | the same loop with PyTorch: a model of which shopper buys which product, learned from simulated shoppers with hidden tastes; the learner trains its own copy in a thread and sends the predictor copies of the weights; the page at `/` shows the true tastes beside the model's predictions, accuracy over time, and a button that shifts the tastes so you can watch the model catch up. Needs the `web` and `torch` extras |
|
|
151
|
+
| `examples/bandit.py` | Thompson sampling over sharded arms: Beta posteriors as arrays, one vectorized draw per shard, `ctx.ask` fan-out, a progress timer |
|
|
152
|
+
| `examples/benchmark.py` | message throughput, round-trip latency and spawn cost of the runtime; the source of the [Performance](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-performance.md) table |
|
|
153
|
+
| `examples/compute.py` | numpy in threads via `pipe_to_self(asyncio.to_thread(...))`, with a latency probe |
|
|
154
|
+
| `examples/batching.py` | `batching` throughput and p99 latency curves |
|
|
155
|
+
| `examples/population.py` | 100k single-arm actors against 16 shards behind `Routers.pool` |
|
|
156
|
+
| `examples/shared_memory.py` | `SharedArray` against pickling for a 400MB array |
|
|
157
|
+
|
|
158
|
+
The last four need numpy: `uv run --extra numpy python examples/bandit.py`. The `fastapi_*` examples need the `web` extra and run under uvicorn: `uv run --extra web uvicorn examples.fastapi_carts:app --port 8000`.
|
|
159
|
+
|
|
160
|
+
## Development
|
|
161
|
+
|
|
162
|
+
Layout follows Apache Pekko's modules: `ohra` is the actor core, `ohra.remote` the transport and serialization, `ohra.cluster` membership and the singleton, `ohra.cluster.sharding` the Shard, region and coordinator, `ohra.ext` the FastAPI, Postgres and shared-memory integrations. Every public name is importable from `ohra` and from its own subpackage.
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
pytest # every test fails if any asyncio task outlives it
|
|
166
|
+
pyright # strict; tests/typing_check.py asserts type errors that must occur
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
See [CONTRIBUTING.md](https://github.com/hanishi/ohra/blob/main/CONTRIBUTING.md) for setup, the runtime invariants and how to port from Apache Pekko. Report vulnerabilities as described in [SECURITY.md](https://github.com/hanishi/ohra/blob/main/SECURITY.md).
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
Apache-2.0, the same as Apache Pekko. The chat room and interaction-pattern examples are derived from the Apache Pekko documentation; see [NOTICE](https://github.com/hanishi/ohra/blob/main/NOTICE).
|
|
174
|
+
|
|
175
|
+
ohra is an independent project, not affiliated with or endorsed by the Apache Software Foundation or the Apache Pekko project. Apache Pekko is a trademark of the Apache Software Foundation.
|
ohra-0.1.0/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<p align="center"><img src="https://raw.githubusercontent.com/hanishi/ohra/main/docs/logo.png" width="160" alt="ohra logo: an ear of barley"></p>
|
|
2
|
+
|
|
3
|
+
# ohra
|
|
4
|
+
|
|
5
|
+
[](https://github.com/hanishi/ohra/actions/workflows/ci.yml)
|
|
6
|
+
[](https://github.com/hanishi/ohra/blob/main/pyproject.toml)
|
|
7
|
+
[](https://github.com/hanishi/ohra/blob/main/LICENSE)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
[](https://microsoft.github.io/pyright/)
|
|
10
|
+
[](https://github.com/hanishi/ohra/blob/main/pyproject.toml)
|
|
11
|
+
|
|
12
|
+
Apache Pekko Typed actors on asyncio, for Python 3.12+. No dependencies. *Ohra* is Finnish for barley, the crop of Pekko, the Finnish god of barley and brewing.
|
|
13
|
+
|
|
14
|
+
ohra is an independent project, built on the design of Apache Pekko and, before it, Akka, with thanks to both communities. It follows their semantics and names closely, but it is not part of the Apache Software Foundation.
|
|
15
|
+
|
|
16
|
+
An actor is a function from a message to the next behavior. Typed refs make wrong messages a type error under pyright strict. Everything runs on one event loop, so a handler can `await` without losing the guarantee that an actor handles one message at a time. numpy work goes to threads and comes back as a message.
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import asyncio
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from ohra import ActorRef, ActorSystem, Behavior, Behaviors
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class Increment:
|
|
26
|
+
by: int
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class GetTotal:
|
|
31
|
+
reply_to: ActorRef[int]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
type Command = Increment | GetTotal
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def counter(total: int = 0) -> Behavior[Command]:
|
|
38
|
+
@Behaviors.receive_message
|
|
39
|
+
def on_message(msg: Command) -> Behavior[Command]:
|
|
40
|
+
match msg:
|
|
41
|
+
case Increment(by):
|
|
42
|
+
return counter(total + by) # state is the next behavior
|
|
43
|
+
case GetTotal(reply_to):
|
|
44
|
+
reply_to.tell(total)
|
|
45
|
+
return Behaviors.same
|
|
46
|
+
|
|
47
|
+
return on_message
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
async def main() -> None:
|
|
51
|
+
async with ActorSystem(counter(), "demo") as system:
|
|
52
|
+
system.tell(Increment(5))
|
|
53
|
+
print(await system.ask(GetTotal, timeout=1)) # 5
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
asyncio.run(main())
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If you know Apache Pekko or Akka Typed, the names are the same in snake_case, and the semantics are checked against the Apache Pekko source. If you don't, [the book](https://github.com/hanishi/ohra/blob/main/docs/book/README.md) explains everything from the first actor to a sharded web app on Kubernetes.
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
pip install -e . # the library
|
|
65
|
+
pip install -e '.[numpy]' # plus numpy, for the examples that use it
|
|
66
|
+
pip install -e '.[web]' # plus FastAPI and uvicorn, for ohra.ext.fastapi and the fastapi_* examples
|
|
67
|
+
pip install -e '.[postgres]' # plus psycopg, for ohra.ext.postgres, the durable state store for clusters
|
|
68
|
+
pip install -e '.[torch]' # plus PyTorch, for the purchase predictor example
|
|
69
|
+
pip install -e '.[dev]' # plus pytest, pytest-asyncio, pyright, httpx
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## The book
|
|
73
|
+
|
|
74
|
+
[How ohra works](https://github.com/hanishi/ohra/blob/main/docs/book/README.md) is the guide and the reference, one chapter per layer, with diagrams:
|
|
75
|
+
|
|
76
|
+
1. [Actors](https://github.com/hanishi/ohra/blob/main/docs/book/01-actors.md): behaviors, ask, children and DeathWatch, supervision, timers and stash, routers, the runtime model
|
|
77
|
+
2. [The actor system](https://github.com/hanishi/ohra/blob/main/docs/book/02-actor-system.md): guardians, extensions, the receptionist, coordinated shutdown
|
|
78
|
+
3. [Persistence](https://github.com/hanishi/ohra/blob/main/docs/book/03-persistence.md): write, then install, then reply; recovery in one read
|
|
79
|
+
4. [Remoting](https://github.com/hanishi/ohra/blob/main/docs/book/04-remoting.md): addresses, `@remotable` messages, connections
|
|
80
|
+
5. [Cluster membership](https://github.com/hanishi/ohra/blob/main/docs/book/05-cluster.md): gossip, the member lifecycle, failure detection, the split-brain resolver
|
|
81
|
+
6. [Cluster singleton](https://github.com/hanishi/ohra/blob/main/docs/book/06-singleton.md): one actor on the oldest member, and the hand-over
|
|
82
|
+
7. [Sharding](https://github.com/hanishi/ohra/blob/main/docs/book/07-sharding.md): regions, shards and the coordinator, in one process and across nodes
|
|
83
|
+
8. [Management and Kubernetes](https://github.com/hanishi/ohra/blob/main/docs/book/08-management-and-kubernetes.md): health checks, bootstrap, discovery, running on Docker Desktop
|
|
84
|
+
9. [FastAPI](https://github.com/hanishi/ohra/blob/main/docs/book/09-fastapi.md): the actor system owned by the app, routes that ask actors
|
|
85
|
+
10. [numpy and shared memory](https://github.com/hanishi/ohra/blob/main/docs/book/10-numpy-and-shared-memory.md): blocking work in a thread, large arrays to another process without a copy
|
|
86
|
+
11. [Putting it together](https://github.com/hanishi/ohra/blob/main/docs/book/11-putting-it-together.md): one cart request through every layer
|
|
87
|
+
|
|
88
|
+
Appendices: [Apache Pekko names](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-pekko-names.md), [known deviations from Apache Pekko](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-deviations.md), [performance](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-performance.md), and a [glossary](https://github.com/hanishi/ohra/blob/main/docs/book/glossary.md).
|
|
89
|
+
|
|
90
|
+
## Examples
|
|
91
|
+
|
|
92
|
+
| File | Shows |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `examples/counter.py` | the functional style, `ask`, supervision with `resume` |
|
|
95
|
+
| `examples/chatroom.py` | the ChatRoom from the Apache Pekko docs: sessions as children, narrowed refs, DeathWatch |
|
|
96
|
+
| `examples/remoting/` | two processes: `greeter_node.py` listens on 2552, `client_node.py` resolves it by path, tells and asks across the wire |
|
|
97
|
+
| `examples/cluster/` | `node.py NAME PORT [SEED_PORT ...]`, or `node.py NAME PORT --bootstrap PORT...` to form the cluster with no seeds through Pekko's bootstrap: start three in three terminals, watch them join, go Up and elect a leader, each node's greeter appear in every node's Receptionist listing, one counter singleton answer all of them, and the sharded counters for three ids spread over the nodes; ctrl-c a node, which leaves gracefully, and the singleton and the shards it hosted move to the others; management on port + 1000 (`curl localhost:3551/cluster/members`) |
|
|
98
|
+
| `examples/k8s/` | `node.py`, `Dockerfile` and `cluster.yaml`: a three-pod cluster on Docker Desktop Kubernetes that finds itself through the API server and spreads a simulated calculation over the pods with sharding; delete a pod and its tasks move, scale up and the new pods take shards; see [Running on Docker Desktop Kubernetes](https://github.com/hanishi/ohra/blob/main/docs/book/08-management-and-kubernetes.md#running-on-docker-desktop-kubernetes) |
|
|
99
|
+
| `examples/k8s/carts.py` | the FastAPI carts on a three-pod cluster: any pod serves any cart, each cart lives on one pod, persisted in Postgres, and moves with its items when that pod goes; `carts.yaml`, see [Carts](https://github.com/hanishi/ohra/blob/main/docs/book/08-management-and-kubernetes.md#carts-cluster-sharding-behind-a-web-app) |
|
|
100
|
+
| `examples/persisted_counter.py` | `Behaviors.persisted` with `SqliteStore`: the total survives a supervised restart and a new actor system; run it twice and it keeps counting |
|
|
101
|
+
| `examples/database_client.py` | backoff restarts of a failing setup, a stash that outlives restarts, timers, `ctx.ask` |
|
|
102
|
+
| `examples/interaction_patterns/` | one runnable file per pattern in Apache Pekko's [Interaction Patterns](https://pekko.apache.org/docs/pekko/current/typed/interaction-patterns.html) page: fire and forget, request-response, adapted response, ask between actors, ask from outside, generic response wrapper, ignoring replies, pipe to self, per-session child, aggregator, tail chopping, scheduling to self |
|
|
103
|
+
| `examples/fastapi_carts.py` | a FastAPI service over actors: one entity per cart id through `Sharding`, persisted in SQLite with `Behaviors.persisted` so carts survive passivation and restarts, typed `ask` from routes to entities |
|
|
104
|
+
| `examples/fastapi_chatroom.py` | the chat room over WebSockets: one connection actor per socket with an async handler that writes to it, rooms created on demand, and DeathWatch turning a closed socket into a "left" notice; serves a browser page at `/` |
|
|
105
|
+
| `examples/fastapi_online_learning.py` | a feedback loop behind FastAPI: predictions micro-batched into one numpy call, outcomes posted back, a learner actor taking gradient steps in a thread and hot-swapping the model; serves a playground page at `/`, and `python examples/fastapi_online_learning.py` runs the server with a demo client |
|
|
106
|
+
| `examples/fastapi_purchase_predictor.py` | the same loop with PyTorch: a model of which shopper buys which product, learned from simulated shoppers with hidden tastes; the learner trains its own copy in a thread and sends the predictor copies of the weights; the page at `/` shows the true tastes beside the model's predictions, accuracy over time, and a button that shifts the tastes so you can watch the model catch up. Needs the `web` and `torch` extras |
|
|
107
|
+
| `examples/bandit.py` | Thompson sampling over sharded arms: Beta posteriors as arrays, one vectorized draw per shard, `ctx.ask` fan-out, a progress timer |
|
|
108
|
+
| `examples/benchmark.py` | message throughput, round-trip latency and spawn cost of the runtime; the source of the [Performance](https://github.com/hanishi/ohra/blob/main/docs/book/appendix-performance.md) table |
|
|
109
|
+
| `examples/compute.py` | numpy in threads via `pipe_to_self(asyncio.to_thread(...))`, with a latency probe |
|
|
110
|
+
| `examples/batching.py` | `batching` throughput and p99 latency curves |
|
|
111
|
+
| `examples/population.py` | 100k single-arm actors against 16 shards behind `Routers.pool` |
|
|
112
|
+
| `examples/shared_memory.py` | `SharedArray` against pickling for a 400MB array |
|
|
113
|
+
|
|
114
|
+
The last four need numpy: `uv run --extra numpy python examples/bandit.py`. The `fastapi_*` examples need the `web` extra and run under uvicorn: `uv run --extra web uvicorn examples.fastapi_carts:app --port 8000`.
|
|
115
|
+
|
|
116
|
+
## Development
|
|
117
|
+
|
|
118
|
+
Layout follows Apache Pekko's modules: `ohra` is the actor core, `ohra.remote` the transport and serialization, `ohra.cluster` membership and the singleton, `ohra.cluster.sharding` the Shard, region and coordinator, `ohra.ext` the FastAPI, Postgres and shared-memory integrations. Every public name is importable from `ohra` and from its own subpackage.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
pytest # every test fails if any asyncio task outlives it
|
|
122
|
+
pyright # strict; tests/typing_check.py asserts type errors that must occur
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
See [CONTRIBUTING.md](https://github.com/hanishi/ohra/blob/main/CONTRIBUTING.md) for setup, the runtime invariants and how to port from Apache Pekko. Report vulnerabilities as described in [SECURITY.md](https://github.com/hanishi/ohra/blob/main/SECURITY.md).
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
Apache-2.0, the same as Apache Pekko. The chat room and interaction-pattern examples are derived from the Apache Pekko documentation; see [NOTICE](https://github.com/hanishi/ohra/blob/main/NOTICE).
|
|
130
|
+
|
|
131
|
+
ohra is an independent project, not affiliated with or endorsed by the Apache Software Foundation or the Apache Pekko project. Apache Pekko is a trademark of the Apache Software Foundation.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ohra"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Apache Pekko Typed style actors on asyncio. Not affiliated with the Apache Software Foundation."
|
|
5
|
+
license = "Apache-2.0"
|
|
6
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
authors = [{ name = "Haruhiko Nishi" }]
|
|
9
|
+
requires-python = ">=3.12"
|
|
10
|
+
dependencies = []
|
|
11
|
+
keywords = ["actors", "asyncio", "pekko", "actor-model", "cluster", "sharding"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Framework :: AsyncIO",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Topic :: Software Development :: Libraries",
|
|
21
|
+
"Topic :: System :: Distributed Computing",
|
|
22
|
+
"Typing :: Typed",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/hanishi/ohra"
|
|
27
|
+
Documentation = "https://github.com/hanishi/ohra/tree/main/docs/book"
|
|
28
|
+
Issues = "https://github.com/hanishi/ohra/issues"
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
dev = ["pytest>=8", "pytest-asyncio>=0.24", "pyright>=1.1.380", "httpx>=0.27", "ruff>=0.17"]
|
|
32
|
+
numpy = ["numpy>=2.0"]
|
|
33
|
+
web = ["fastapi>=0.115", "uvicorn>=0.30", "websockets>=13"]
|
|
34
|
+
postgres = ["psycopg[binary]>=3.2", "psycopg-pool>=3.2"]
|
|
35
|
+
torch = ["torch>=2.5", "numpy>=2.0"]
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["setuptools>=68"]
|
|
39
|
+
build-backend = "setuptools.build_meta"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
where = ["src"]
|
|
43
|
+
|
|
44
|
+
[tool.setuptools.package-data]
|
|
45
|
+
ohra = ["py.typed"]
|
|
46
|
+
|
|
47
|
+
# The torch extra installs PyTorch's CPU-only build, small enough for CI. Only uv in this
|
|
48
|
+
# repository uses this index; pip install ohra[torch] gets the default PyTorch build.
|
|
49
|
+
[tool.uv.sources]
|
|
50
|
+
torch = [{ index = "pytorch-cpu" }]
|
|
51
|
+
|
|
52
|
+
[[tool.uv.index]]
|
|
53
|
+
name = "pytorch-cpu"
|
|
54
|
+
url = "https://download.pytorch.org/whl/cpu"
|
|
55
|
+
explicit = true
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
asyncio_mode = "auto"
|
|
59
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
60
|
+
pythonpath = ["src"]
|
|
61
|
+
testpaths = ["tests"]
|
|
62
|
+
|
|
63
|
+
[tool.pyright]
|
|
64
|
+
include = ["src", "tests/typing_check.py", "examples"]
|
|
65
|
+
typeCheckingMode = "strict"
|
|
66
|
+
pythonVersion = "3.12"
|
|
67
|
+
reportUnnecessaryTypeIgnoreComment = "error"
|
|
68
|
+
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
line-length = 99
|
|
71
|
+
target-version = "py312"
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint]
|
|
74
|
+
select = ["E", "W", "N"]
|
ohra-0.1.0/setup.cfg
ADDED