allgreen-sdk-beans 0.0.1__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.
Files changed (171) hide show
  1. allgreen_sdk_beans-0.0.1/.github/workflows/release.yml +26 -0
  2. allgreen_sdk_beans-0.0.1/.gitignore +11 -0
  3. allgreen_sdk_beans-0.0.1/LICENSE +21 -0
  4. allgreen_sdk_beans-0.0.1/PKG-INFO +128 -0
  5. allgreen_sdk_beans-0.0.1/README.md +76 -0
  6. allgreen_sdk_beans-0.0.1/examples/README.md +8 -0
  7. allgreen_sdk_beans-0.0.1/examples/adminui/README.md +31 -0
  8. allgreen_sdk_beans-0.0.1/examples/adminui/config.template.yml +25 -0
  9. allgreen_sdk_beans-0.0.1/examples/adminui/main.py +43 -0
  10. allgreen_sdk_beans-0.0.1/examples/adminui/materials/paas/file-example.txt +1 -0
  11. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/README.md +38 -0
  12. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/config.template.yml +28 -0
  13. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/main.py +45 -0
  14. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/materials/paas/notes/counter.txt +2 -0
  15. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/materials/paas/overview.txt +4 -0
  16. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/src/allgreen/example/app.py +19 -0
  17. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/src/allgreen/example/backend/counter.py +53 -0
  18. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/src/allgreen/example/backend/pulse.py +51 -0
  19. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/src/allgreen/example/frontend/home.py +70 -0
  20. allgreen_sdk_beans-0.0.1/examples/example-fastapi-beans/src/allgreen/example/frontend/server.py +55 -0
  21. allgreen_sdk_beans-0.0.1/hatch_build.py +48 -0
  22. allgreen_sdk_beans-0.0.1/pyproject.toml +70 -0
  23. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/__init__.py +31 -0
  24. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/assets/allgreenlogo.png +0 -0
  25. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/assets/index.html +142 -0
  26. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/bootstrap.py +30 -0
  27. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/brand.py +92 -0
  28. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/__init__.py +6 -0
  29. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/downloads.py +47 -0
  30. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/file_explorer.py +777 -0
  31. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/gallery.py +42 -0
  32. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/gallery_samples/docs/readme.txt +2 -0
  33. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/gallery_samples/packs/example.zip +0 -0
  34. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/gallery_samples/packs/note.txt +1 -0
  35. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/log_table.py +251 -0
  36. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/components/log_view.py +103 -0
  37. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/frontend/__init__.py +6 -0
  38. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/frontend/paths.py +10 -0
  39. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/frontend/support.py +69 -0
  40. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/infra/__init__.py +1 -0
  41. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/infra/db.py +61 -0
  42. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/infra/password.py +15 -0
  43. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/__init__.py +30 -0
  44. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/catalog.py +92 -0
  45. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/__init__.py +21 -0
  46. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/base.py +90 -0
  47. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/generic.py +37 -0
  48. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/http.py +57 -0
  49. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/outgoing.py +47 -0
  50. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/outgoing_http.py +64 -0
  51. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/shell.py +38 -0
  52. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/mappers/sql.py +46 -0
  53. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/models.py +35 -0
  54. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/query.py +98 -0
  55. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/logs/reader.py +268 -0
  56. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/__init__.py +26 -0
  57. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/files.py +46 -0
  58. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/login.py +200 -0
  59. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/logs.py +206 -0
  60. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/main.py +71 -0
  61. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/misc.py +296 -0
  62. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/nav.py +145 -0
  63. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/router.py +47 -0
  64. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/shell.py +151 -0
  65. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/pages/users.py +273 -0
  66. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/presenter/__init__.py +1 -0
  67. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/presenter/server.py +46 -0
  68. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/process_runtime.py +462 -0
  69. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/repo/__init__.py +1 -0
  70. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/repo/user.py +75 -0
  71. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/roles.py +16 -0
  72. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/runner.py +30 -0
  73. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/test/__init__.py +1 -0
  74. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/test/app.py +17 -0
  75. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/theme.py +46 -0
  76. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/ui_title.py +20 -0
  77. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/usecase/__init__.py +1 -0
  78. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/usecase/login.py +83 -0
  79. allgreen_sdk_beans-0.0.1/src/allgreen/adminui/usecase/users.py +95 -0
  80. allgreen_sdk_beans-0.0.1/src/allgreen/apis/alerts/__main__.py +0 -0
  81. allgreen_sdk_beans-0.0.1/src/allgreen/apis/alerts/alerts.py +49 -0
  82. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/hc/backend/hc.py +300 -0
  83. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/hc/frontend/controller.py +65 -0
  84. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/hc/frontend/support.py +42 -0
  85. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/mbclient/mbclient.py +66 -0
  86. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/paas/frontend/support.py +80 -0
  87. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/webui/__init__.py +1 -0
  88. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/webui/frontend/__init__.py +1 -0
  89. allgreen_sdk_beans-0.0.1/src/allgreen/apis/common/webui/frontend/support.py +22 -0
  90. allgreen_sdk_beans-0.0.1/src/allgreen/db/__init__.py +0 -0
  91. allgreen_sdk_beans-0.0.1/src/allgreen/db/peewee_log.py +49 -0
  92. allgreen_sdk_beans-0.0.1/src/allgreen/err_sink.py +86 -0
  93. allgreen_sdk_beans-0.0.1/src/allgreen/infra_middleware.py +96 -0
  94. allgreen_sdk_beans-0.0.1/src/allgreen/jwt.py +65 -0
  95. allgreen_sdk_beans-0.0.1/src/allgreen/lifecycle.py +21 -0
  96. allgreen_sdk_beans-0.0.1/src/allgreen/log_compressor.py +118 -0
  97. allgreen_sdk_beans-0.0.1/src/allgreen/log_utils.py +15 -0
  98. allgreen_sdk_beans-0.0.1/src/allgreen/moments.py +92 -0
  99. allgreen_sdk_beans-0.0.1/src/allgreen/object_storage.py +146 -0
  100. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/__main__.py +1 -0
  101. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/alerts.py +149 -0
  102. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/app.py +12 -0
  103. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/atomic.py +27 -0
  104. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/batcher.py +119 -0
  105. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/cache.py +25 -0
  106. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/curl/builder.py +980 -0
  107. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/curl/executor.py +117 -0
  108. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/di.py +20 -0
  109. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/email.py +62 -0
  110. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/events.py +7 -0
  111. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/fr.py +49 -0
  112. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/generate.py +11 -0
  113. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/info/backend/info.py +37 -0
  114. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/info/frontend/controller.py +28 -0
  115. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/info/frontend/support.py +24 -0
  116. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/jwt.py +124 -0
  117. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/logger.py +578 -0
  118. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/metrics_export.py +70 -0
  119. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/orm.py +128 -0
  120. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/otp/otp.py +146 -0
  121. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/pydantic_utils.py +56 -0
  122. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/queue/rabbitmq/batcher_transport.py +79 -0
  123. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/queue/rabbitmq/consumer.py +499 -0
  124. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/rate_limiter.py +92 -0
  125. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/redis_service.py +269 -0
  126. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/retrying.py +382 -0
  127. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/shell.py +86 -0
  128. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/ssh.py +572 -0
  129. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/stats/async_circular_window_counter.py +175 -0
  130. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/stats/stats_window.py +82 -0
  131. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/stats/sync_circular_window_counter.py +224 -0
  132. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/structures.py +82 -0
  133. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/utils.py +1263 -0
  134. allgreen_sdk_beans-0.0.1/src/mybootstrap_core_itskovichanton/validation.py +69 -0
  135. allgreen_sdk_beans-0.0.1/src/mybootstrap_ioc_itskovichanton/config.py +89 -0
  136. allgreen_sdk_beans-0.0.1/src/mybootstrap_ioc_itskovichanton/context.py +5 -0
  137. allgreen_sdk_beans-0.0.1/src/mybootstrap_ioc_itskovichanton/di.py +31 -0
  138. allgreen_sdk_beans-0.0.1/src/mybootstrap_ioc_itskovichanton/env.py +21 -0
  139. allgreen_sdk_beans-0.0.1/src/mybootstrap_ioc_itskovichanton/ioc.py +187 -0
  140. allgreen_sdk_beans-0.0.1/src/mybootstrap_ioc_itskovichanton/utils.py +169 -0
  141. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/__main__.py +0 -0
  142. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/client/http.py +60 -0
  143. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/error_handler.py +23 -0
  144. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/_rate.py +38 -0
  145. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/_wrap.py +16 -0
  146. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/context.py +47 -0
  147. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/flags.py +113 -0
  148. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/identifier.py +64 -0
  149. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/rate_limit.py +103 -0
  150. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/rate_limit_simple.py +134 -0
  151. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/request_id.py +16 -0
  152. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/s2s.py +116 -0
  153. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/saga.py +85 -0
  154. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/infra/upload.py +91 -0
  155. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/middleware_logging.py +158 -0
  156. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/middleware_stats.py +308 -0
  157. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/presenters.py +180 -0
  158. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_fastapi_itskovichanton/utils.py +293 -0
  159. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_itskovichanton/__main__.py +0 -0
  160. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_itskovichanton/error_provider.py +66 -0
  161. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_itskovichanton/exceptions.py +57 -0
  162. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_itskovichanton/pipeline.py +83 -0
  163. allgreen_sdk_beans-0.0.1/src/mybootstrap_mvc_itskovichanton/result_presenter.py +41 -0
  164. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/backend/auth.py +142 -0
  165. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/backend/session_storage.py +360 -0
  166. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/backend/user_repo.py +32 -0
  167. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/backend/utils.py +17 -0
  168. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/entities.py +56 -0
  169. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/frontend/controller.py +211 -0
  170. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/frontend/support.py +51 -0
  171. allgreen_sdk_beans-0.0.1/src/mybootstrap_pyauth_itskovichanton/frontend/utils.py +40 -0
@@ -0,0 +1,26 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ id-token: write
10
+ contents: read
11
+
12
+ jobs:
13
+ publish:
14
+ runs-on: ubuntu-latest
15
+ environment: pypi
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.12"
21
+ - name: Build the wheel
22
+ run: |
23
+ python -m pip install --upgrade build
24
+ python -m build
25
+ - name: Publish
26
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ .vendor/
3
+ dist/
4
+ build/
5
+ *.egg-info/
6
+ __pycache__/
7
+ *.pyc
8
+ config.yml
9
+ examples/example-fastapi-beans/allgreen-example-*/
10
+ *.sqlite
11
+ *.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anton Itskovich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,128 @@
1
+ Metadata-Version: 2.5
2
+ Name: allgreen-sdk-beans
3
+ Version: 0.0.1
4
+ Summary: Allgreen SDK for a FastAPI service: health, alerts, files, and the admin UI
5
+ Author-email: Anton Itskovich <itskovichae@gmail.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: ago
10
+ Requires-Dist: aio-pika
11
+ Requires-Dist: argon2-cffi
12
+ Requires-Dist: basicauth
13
+ Requires-Dist: boto3
14
+ Requires-Dist: dacite
15
+ Requires-Dist: dataclasses-json
16
+ Requires-Dist: event-bus
17
+ Requires-Dist: fastapi
18
+ Requires-Dist: flet
19
+ Requires-Dist: flet-web
20
+ Requires-Dist: greenletio
21
+ Requires-Dist: httpx
22
+ Requires-Dist: imapclient
23
+ Requires-Dist: numpy
24
+ Requires-Dist: opyoid
25
+ Requires-Dist: paprika
26
+ Requires-Dist: paramiko
27
+ Requires-Dist: patool
28
+ Requires-Dist: peewee
29
+ Requires-Dist: pika
30
+ Requires-Dist: prometheus-client
31
+ Requires-Dist: psutil
32
+ Requires-Dist: py-healthcheck
33
+ Requires-Dist: pydantic
34
+ Requires-Dist: python-benedict
35
+ Requires-Dist: python-dateutil
36
+ Requires-Dist: python-jose
37
+ Requires-Dist: python-json-logger
38
+ Requires-Dist: pyyaml
39
+ Requires-Dist: redis
40
+ Requires-Dist: requests
41
+ Requires-Dist: requests-toolbelt
42
+ Requires-Dist: retrying
43
+ Requires-Dist: schedule
44
+ Requires-Dist: six
45
+ Requires-Dist: starlette
46
+ Requires-Dist: urllib3
47
+ Requires-Dist: uvicorn
48
+ Requires-Dist: xsdata
49
+ Provides-Extra: examples
50
+ Requires-Dist: fastcore; extra == 'examples'
51
+ Description-Content-Type: text/markdown
52
+
53
+ # allgreen-sdk-beans
54
+
55
+ Python library for a service that talks to an Allgreen stand. One install brings the SDK and the `mybootstrap_*` packages it is built on.
56
+
57
+ Import it as `src.allgreen`. The admin shell is `src.allgreen.adminui`.
58
+
59
+ Author: [Anton Itskovich](https://github.com/itskovichanton/)
60
+
61
+ ## Install
62
+
63
+ ```bash
64
+ python3.12 -m pip install allgreen-sdk-beans
65
+ ```
66
+
67
+ The examples in this repository also need `fastcore`:
68
+
69
+ ```bash
70
+ python3.12 -m pip install "allgreen-sdk-beans[examples]"
71
+ ```
72
+
73
+ From a checkout, before the package is on PyPI:
74
+
75
+ ```bash
76
+ python3.12 -m pip install ".[examples]"
77
+ ```
78
+
79
+ That command builds a wheel. The build clones these repositories and copies their packages into the wheel, so they are not installed from PyPI:
80
+
81
+ | Repository | Package inside the wheel |
82
+ | --- | --- |
83
+ | [pycore](https://github.com/itskovichanton/pycore) | `src.mybootstrap_core_itskovichanton` |
84
+ | [pyioc](https://github.com/itskovichanton/pyioc) | `src.mybootstrap_ioc_itskovichanton` |
85
+ | [pymvc](https://github.com/itskovichanton/pymvc) | `src.mybootstrap_mvc_itskovichanton` |
86
+ | [pymvc-fastapi](https://github.com/itskovichanton/pymvc-fastapi) | `src.mybootstrap_mvc_fastapi_itskovichanton` |
87
+ | [pyauth](https://github.com/itskovichanton/pyauth) | `src.mybootstrap_pyauth_itskovichanton` |
88
+
89
+ Third-party libraries (`fastapi`, `redis`, `flet`, and the rest) are ordinary dependencies and come from PyPI.
90
+
91
+ `examples/` is not installed. It stays in the source tree.
92
+
93
+ ## What you get
94
+
95
+ - `infra_middleware` mounts health, CORS, the HTTP log, paas files, and, when `infra.webui_on` is true, the admin UI
96
+ - `jwt` signs and checks PIN tokens (`jwt-generator.secret`)
97
+ - `db.peewee_log` writes each SQL statement to the service log
98
+ - `apis.alerts` posts to the alerts service (`alerts.url`)
99
+ - `err_sink` forwards 5xx responses to RabbitMQ when `infra.err_queue_url` is set
100
+ - `adminui` is the Flet admin shell: login, logs, files, users
101
+
102
+ A service still needs its own `main.py`, `@bean` application, and `config.yml`. Point `alerts.url`, Redis, `adminapi.url`, and `infra.err_queue_url` at the stand, and register the service in the Allgreen catalog so the stand can call its URL.
103
+
104
+ ## Examples
105
+
106
+ | Directory | What it shows |
107
+ | --- | --- |
108
+ | [examples/example-fastapi-beans](examples/example-fastapi-beans/README.md) | FastAPI service: counter, healthcheck, admin home, files in `materials/paas` |
109
+ | [examples/adminui](examples/adminui/README.md) | The admin shell by itself on port 8550 |
110
+
111
+ ## Publish
112
+
113
+ The workflow `.github/workflows/release.yml` runs on a tag `v*`. It builds the wheel and uploads it to PyPI with a trusted publisher. Before the first tag:
114
+
115
+ 1. Create the project `allgreen-sdk-beans` on [pypi.org](https://pypi.org). The account needs two-factor authentication.
116
+ 2. Add a trusted publisher: owner `itskovichanton`, repository of this checkout, workflow `release.yml`, environment `pypi`.
117
+ 3. Create the GitHub environment `pypi` on the repository.
118
+ 4. Set the same version in `pyproject.toml` and push a tag, for example `v0.0.1`. PyPI keeps every version; the next release needs a new number.
119
+
120
+ A local check before tagging:
121
+
122
+ ```bash
123
+ python3.12 -m pip install build
124
+ python3.12 -m build
125
+ python3.12 -m venv .venv
126
+ .venv/bin/pip install dist/allgreen_sdk_beans-*.whl
127
+ .venv/bin/python -c "import src.allgreen.infra_middleware, src.mybootstrap_ioc_itskovichanton.ioc"
128
+ ```
@@ -0,0 +1,76 @@
1
+ # allgreen-sdk-beans
2
+
3
+ Python library for a service that talks to an Allgreen stand. One install brings the SDK and the `mybootstrap_*` packages it is built on.
4
+
5
+ Import it as `src.allgreen`. The admin shell is `src.allgreen.adminui`.
6
+
7
+ Author: [Anton Itskovich](https://github.com/itskovichanton/)
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ python3.12 -m pip install allgreen-sdk-beans
13
+ ```
14
+
15
+ The examples in this repository also need `fastcore`:
16
+
17
+ ```bash
18
+ python3.12 -m pip install "allgreen-sdk-beans[examples]"
19
+ ```
20
+
21
+ From a checkout, before the package is on PyPI:
22
+
23
+ ```bash
24
+ python3.12 -m pip install ".[examples]"
25
+ ```
26
+
27
+ That command builds a wheel. The build clones these repositories and copies their packages into the wheel, so they are not installed from PyPI:
28
+
29
+ | Repository | Package inside the wheel |
30
+ | --- | --- |
31
+ | [pycore](https://github.com/itskovichanton/pycore) | `src.mybootstrap_core_itskovichanton` |
32
+ | [pyioc](https://github.com/itskovichanton/pyioc) | `src.mybootstrap_ioc_itskovichanton` |
33
+ | [pymvc](https://github.com/itskovichanton/pymvc) | `src.mybootstrap_mvc_itskovichanton` |
34
+ | [pymvc-fastapi](https://github.com/itskovichanton/pymvc-fastapi) | `src.mybootstrap_mvc_fastapi_itskovichanton` |
35
+ | [pyauth](https://github.com/itskovichanton/pyauth) | `src.mybootstrap_pyauth_itskovichanton` |
36
+
37
+ Third-party libraries (`fastapi`, `redis`, `flet`, and the rest) are ordinary dependencies and come from PyPI.
38
+
39
+ `examples/` is not installed. It stays in the source tree.
40
+
41
+ ## What you get
42
+
43
+ - `infra_middleware` mounts health, CORS, the HTTP log, paas files, and, when `infra.webui_on` is true, the admin UI
44
+ - `jwt` signs and checks PIN tokens (`jwt-generator.secret`)
45
+ - `db.peewee_log` writes each SQL statement to the service log
46
+ - `apis.alerts` posts to the alerts service (`alerts.url`)
47
+ - `err_sink` forwards 5xx responses to RabbitMQ when `infra.err_queue_url` is set
48
+ - `adminui` is the Flet admin shell: login, logs, files, users
49
+
50
+ A service still needs its own `main.py`, `@bean` application, and `config.yml`. Point `alerts.url`, Redis, `adminapi.url`, and `infra.err_queue_url` at the stand, and register the service in the Allgreen catalog so the stand can call its URL.
51
+
52
+ ## Examples
53
+
54
+ | Directory | What it shows |
55
+ | --- | --- |
56
+ | [examples/example-fastapi-beans](examples/example-fastapi-beans/README.md) | FastAPI service: counter, healthcheck, admin home, files in `materials/paas` |
57
+ | [examples/adminui](examples/adminui/README.md) | The admin shell by itself on port 8550 |
58
+
59
+ ## Publish
60
+
61
+ The workflow `.github/workflows/release.yml` runs on a tag `v*`. It builds the wheel and uploads it to PyPI with a trusted publisher. Before the first tag:
62
+
63
+ 1. Create the project `allgreen-sdk-beans` on [pypi.org](https://pypi.org). The account needs two-factor authentication.
64
+ 2. Add a trusted publisher: owner `itskovichanton`, repository of this checkout, workflow `release.yml`, environment `pypi`.
65
+ 3. Create the GitHub environment `pypi` on the repository.
66
+ 4. Set the same version in `pyproject.toml` and push a tag, for example `v0.0.1`. PyPI keeps every version; the next release needs a new number.
67
+
68
+ A local check before tagging:
69
+
70
+ ```bash
71
+ python3.12 -m pip install build
72
+ python3.12 -m build
73
+ python3.12 -m venv .venv
74
+ .venv/bin/pip install dist/allgreen_sdk_beans-*.whl
75
+ .venv/bin/python -c "import src.allgreen.infra_middleware, src.mybootstrap_ioc_itskovichanton.ioc"
76
+ ```
@@ -0,0 +1,8 @@
1
+ # Examples
2
+
3
+ These processes are not part of the installed package. Install the SDK first (`pip install ".[examples]"` from the repository root), then run an example from its own directory.
4
+
5
+ | Directory | What it shows |
6
+ | --- | --- |
7
+ | [example-fastapi-beans](example-fastapi-beans/README.md) | FastAPI service on `@bean`: counter, healthcheck, admin home, and files from `materials/paas` |
8
+ | [adminui](adminui/README.md) | Demo of the Flet admin shell |
@@ -0,0 +1,31 @@
1
+ # adminui
2
+
3
+ Flet admin shell for a Python service: login, logs, files, and users. Accounts are rows in a local SQLite database. The UI is served in the browser on the same port as the HTTP API.
4
+
5
+ Author: [Anton Itskovich](https://github.com/itskovichanton/)
6
+
7
+ The library is `src.allgreen.adminui`, installed with `allgreen-sdk-beans`. This directory is only the demo process. It uses the SDK checkout when you run it from this repository, and opens the shell on port 8550. Import `src.allgreen.adminui.bootstrap`, then mount `AdminUiApiSupport`.
8
+
9
+ ## Run the demo
10
+
11
+ From the repository root: `python3.12 -m pip install .`, then from `examples/adminui`:
12
+
13
+ ```bash
14
+ cp config.template.yml config.yml
15
+ python main.py
16
+ ```
17
+
18
+ Browser: http://127.0.0.1:8550
19
+
20
+ ## Mount it on another FastAPI app
21
+
22
+ ```python
23
+ import src.allgreen.adminui.bootstrap # registers the beans
24
+ from src.allgreen.adminui.frontend.support import AdminUiApiSupport
25
+
26
+ # AdminUiApiSupport is an injected bean.
27
+ # support.mount(app) adds the login API.
28
+ # support.mount_ui(app) adds the Flet UI after your own routes.
29
+ ```
30
+
31
+ `ui.title` in `config.yml` is the name on the login screen.
@@ -0,0 +1,25 @@
1
+ app:
2
+ version: 1.0.0
3
+ name: allgreen-adminui
4
+
5
+ server:
6
+ host: 127.0.0.1
7
+ port: 8550
8
+
9
+ adminapi:
10
+ url: http://localhost:8082
11
+
12
+ ui:
13
+ title: Allgreen
14
+ developer: Anton Itskovich (https://github.com/itskovichanton/)
15
+
16
+ loggers:
17
+ http:
18
+ backup_count: 7
19
+ level: INFO
20
+
21
+ dev: {}
22
+ prod:
23
+ server:
24
+ host: 0.0.0.0
25
+ port: 8550
@@ -0,0 +1,43 @@
1
+ """Demo admin UI. Run from this directory: python main.py"""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+
6
+
7
+ def _bootstrap() -> None:
8
+ """Use the SDK checkout when this demo sits inside it."""
9
+ here = Path(__file__).resolve().parent
10
+ repo = here.parents[1]
11
+ if (repo / "src" / "allgreen" / "adminui" / "bootstrap.py").is_file():
12
+ entry = str(repo)
13
+ if entry not in sys.path:
14
+ sys.path.insert(0, entry)
15
+
16
+
17
+ _bootstrap()
18
+
19
+ from src.mybootstrap_core_itskovichanton.di import injector # noqa: E402
20
+
21
+ from src.allgreen.adminui.test.app import UITestApp # noqa: E402
22
+
23
+
24
+ def main() -> None:
25
+ app = injector().inject(UITestApp)
26
+ app.run()
27
+
28
+
29
+ def quit_handler(signo, _frame):
30
+ print("Interrupted by %d, shutting down" % signo)
31
+ raise SystemExit(0)
32
+
33
+
34
+ if __name__ == "__main__":
35
+ import signal
36
+
37
+ for sig in ("TERM", "HUP", "INT"):
38
+ sig_name = "SIG" + sig
39
+ if hasattr(signal, sig_name):
40
+ sig_obj = getattr(signal, sig_name)
41
+ if sig_obj:
42
+ signal.signal(sig_obj, quit_handler)
43
+ main()
@@ -0,0 +1,38 @@
1
+ # Example service (FastAPI, `@bean`)
2
+
3
+ A small Python service that shows how an Allgreen service is put together. The directory is `examples/example-fastapi-beans`. The catalog name on a stand is still `example`.
4
+
5
+ ## What to look at
6
+
7
+ - `main.py` puts this directory on `sys.path`, and the SDK checkout too when you run it from this repository. Then it asks the IoC container for `ExampleApp`.
8
+ - `app.py` is the `@bean` application. The `counter` field is why the background thread exists: the container creates every field.
9
+ - `frontend/server.py` builds a FastAPI app and calls `InfraFastAPISupport.mount`. That one call adds `/healthcheck`, error handling, request logging, and, because `infra.webui_on` is true, the admin UI.
10
+ - `frontend/home.py` is the product body of that admin. It is a `MainContent` bean registered after `adminui` bootstrap, so the home page shows Start and Stop instead of the default gallery. The buttons call the same `Counter` the HTTP routes use.
11
+ - `backend/counter.py` is a `@threaded` loop. While the counter is started it moves from 1 to 100 and back to 1, once every 10 seconds, and records a moment. Moments live in Redis. `/healthcheck` warns when the moment is older than 10 seconds. The warning text is `Counter has not been updated for 10 seconds`.
12
+ - `backend/pulse.py` registers its own check, `example_pulse`, on the same health object. For five minutes the output starts with `warning:` and the check still passes. The next five minutes the output is a plain healthy message. Then it repeats. The clock starts when the process starts. `POST /killme` stops that cycle: the check returns false and the message you sent, so the service is asking to be restarted. Restart the process to clear it.
13
+ - `materials/paas/` is the published file set. `InfraFastAPISupport` mounts `PaasFastAPISupport`, which serves that directory at `GET /paas/files` and `GET /paas/files/{path}` with no sign-in. serviceapi copies those bytes into S3 about once a minute. The service page then lists them under Files. `overview.txt` and `notes/counter.txt` are the sample.
14
+
15
+ ## HTTP
16
+
17
+ | Method | Path | What it does |
18
+ | --- | --- | --- |
19
+ | POST | `/counter/start` | Start the counter and record the moment |
20
+ | POST | `/counter/stop` | Stop the counter. After 10 seconds `/healthcheck` shows the warning |
21
+ | GET | `/healthcheck` | Readiness, overdue moments, and `example_pulse` (5 minutes warning, 5 minutes healthy) |
22
+ | POST | `/killme` | Optional JSON `{"msg": "..."}`. `example_pulse` then fails with that phrase until the process restarts |
23
+ | GET | `/` | Admin UI. Sign in with an Allgreen username and PIN (permission `service_adminui`), or with a local account added on the Users page. Home has Start and Stop for the counter |
24
+ | GET | `/paas/files` | JSON list of `materials/paas`: name, size, sha256 |
25
+ | GET | `/paas/files/{path}` | One file from that directory |
26
+
27
+ ## Run
28
+
29
+ From the repository root, with Redis on `localhost:6379`:
30
+
31
+ ```bash
32
+ python3.12 -m pip install ".[examples]"
33
+ cd examples/example-fastapi-beans
34
+ cp config.template.yml config.yml
35
+ python3.12 main.py
36
+ ```
37
+
38
+ The process listens on port 8090. On a stand, register this service in the catalog so Allgreen can call its URL. The user `admin` needs the role `admin` on it.
@@ -0,0 +1,28 @@
1
+ # Copy to config.yml for a local run outside Docker.
2
+ # Docker renders config.yml from environment variables (deploy/render_config.py).
3
+
4
+ app:
5
+ version: 1.0.0
6
+ name: allgreen-example
7
+
8
+ server:
9
+ host: 0.0.0.0
10
+ port: 8090
11
+
12
+ redis:
13
+ host: localhost
14
+ port: 6379
15
+
16
+ adminapi:
17
+ url: http://localhost:8082
18
+
19
+ ui:
20
+ title: Example
21
+ developer: Anton Itskovich (https://github.com/itskovichanton/)
22
+
23
+ infra:
24
+ webui_on: true
25
+ err_queue_url: ""
26
+
27
+ dev: {}
28
+ prod: {}
@@ -0,0 +1,45 @@
1
+ import sys
2
+ from pathlib import Path
3
+
4
+
5
+ def _bootstrap() -> None:
6
+ """This example's package, plus the SDK checkout when it sits two levels up."""
7
+ here = Path(__file__).resolve().parent
8
+ repo = here.parents[1]
9
+ entries = [here]
10
+ if (repo / "src" / "allgreen" / "infra_middleware.py").is_file():
11
+ entries.append(repo)
12
+ for path in reversed(entries):
13
+ entry = str(path)
14
+ if entry not in sys.path:
15
+ sys.path.insert(0, entry)
16
+
17
+
18
+ _bootstrap()
19
+
20
+ from src.mybootstrap_core_itskovichanton.di import injector # noqa: E402
21
+ from src.mybootstrap_core_itskovichanton.events import exit_signal # noqa: E402
22
+
23
+ from src.allgreen.example.app import ExampleApp # noqa: E402
24
+
25
+
26
+ def main() -> None:
27
+ app = injector().inject(ExampleApp)
28
+ app.run()
29
+
30
+
31
+ def quit(signo, _frame):
32
+ print("Interrupted by %d, shutting down" % signo)
33
+ exit_signal.set()
34
+
35
+
36
+ if __name__ == "__main__":
37
+ import signal
38
+
39
+ for sig in ("TERM", "HUP", "INT"):
40
+ sig_name = "SIG" + sig
41
+ if hasattr(signal, sig_name):
42
+ sig_obj = getattr(signal, sig_name)
43
+ if sig_obj:
44
+ signal.signal(sig_obj, quit)
45
+ main()
@@ -0,0 +1,2 @@
1
+ The counter moves from 1 to 100 and back, one step every 10 seconds.
2
+ Stopping it makes the healthcheck warn that the counter moment is overdue.
@@ -0,0 +1,4 @@
1
+ Example publishes this file from materials/paas.
2
+
3
+ Allgreen reads GET /paas/files on the running service, stores the bytes in S3,
4
+ and shows the names on the service page under Files.
@@ -0,0 +1,19 @@
1
+ from src.mybootstrap_core_itskovichanton.app import Application
2
+ from src.mybootstrap_ioc_itskovichanton.ioc import bean
3
+
4
+ from src.allgreen.example.backend.counter import Counter
5
+ from src.allgreen.example.backend.pulse import Pulse
6
+ from src.allgreen.example.frontend.home import ExampleHome # noqa: F401 — replaces the admin home page
7
+ from src.allgreen.example.frontend.server import Server
8
+
9
+
10
+ @bean
11
+ class ExampleApp(Application):
12
+ """The process root. Listing Counter and Pulse here starts them."""
13
+
14
+ server: Server
15
+ counter: Counter
16
+ pulse: Pulse
17
+
18
+ def run(self):
19
+ self.server.start()
@@ -0,0 +1,53 @@
1
+ """A looping counter, and a moment that goes stale when the counter stops."""
2
+
3
+ import time
4
+
5
+ from fastcore.parallel import threaded
6
+ from src.mybootstrap_core_itskovichanton.events import exit_signal
7
+ from src.mybootstrap_ioc_itskovichanton.ioc import bean
8
+
9
+ from src.allgreen.moments import Moments
10
+
11
+ # Moments stores the allowed gap in hours. Ten seconds is 10/3600 of an hour.
12
+ GAP_HOURS = 10 / 3600
13
+ MOMENT = "Counter has not been updated for 10 seconds"
14
+ MESSAGE = MOMENT
15
+
16
+
17
+ @bean
18
+ class Counter:
19
+ moments: Moments
20
+
21
+ def init(self):
22
+ self.value = 0
23
+ self.running = False
24
+ self.moments.register(MOMENT, next_moment_within_dur_hours=GAP_HOURS)
25
+ self._tick()
26
+
27
+ def start(self, _call=None) -> dict:
28
+ self.running = True
29
+ self._mark()
30
+ return self.status()
31
+
32
+ def stop(self, _call=None) -> dict:
33
+ self.running = False
34
+ return self.status()
35
+
36
+ def status(self) -> dict:
37
+ return {"running": self.running, "value": self.value, "message": MESSAGE}
38
+
39
+ def _mark(self):
40
+ self.moments.happened(
41
+ MOMENT,
42
+ extra=MESSAGE,
43
+ next_moment_within_dur_hours=GAP_HOURS,
44
+ )
45
+
46
+ @threaded
47
+ def _tick(self):
48
+ while not exit_signal.is_set():
49
+ time.sleep(10)
50
+ if exit_signal.is_set() or not self.running:
51
+ continue
52
+ self.value = 1 if self.value >= 100 else self.value + 1
53
+ self._mark()
@@ -0,0 +1,51 @@
1
+ """A custom health check that alternates warning and healthy, five minutes each.
2
+
3
+ POST /killme makes the same check fail, which is how a service asks to be restarted.
4
+ """
5
+
6
+ import time
7
+
8
+ from src.mybootstrap_ioc_itskovichanton.ioc import bean
9
+
10
+ from src.allgreen.apis.common.hc.backend.hc import HealthCheckUsecase, warn
11
+
12
+ # One phase. Even phases (0, 2, ...) are a warning; odd phases are healthy.
13
+ PHASE_SECONDS = 5 * 60
14
+ WARNING = "Example pulse is in its warning phase for 5 minutes"
15
+ HEALTHY = "Example pulse is healthy for 5 minutes"
16
+ DEFAULT_RESTART = "allgreen, please restart me.... i'm feeling bad... (caused by POST /killme)"
17
+
18
+
19
+ def pulse_phase(elapsed_seconds: float) -> bool:
20
+ """True while the check should report a warning."""
21
+ return int(elapsed_seconds // PHASE_SECONDS) % 2 == 0
22
+
23
+
24
+ @bean
25
+ class Pulse:
26
+ """Registers ``example_pulse`` on the service health check."""
27
+
28
+ healthcheck_uc: HealthCheckUsecase
29
+
30
+ def init(self):
31
+ self._restart_message = None
32
+ started = time.monotonic()
33
+
34
+ def example_pulse():
35
+ if self._restart_message:
36
+ return False, self._restart_message
37
+ if pulse_phase(time.monotonic() - started):
38
+ # True keeps the service up. The warning: prefix is what the UI shows as a warning.
39
+ return True, warn(WARNING)
40
+ return True, HEALTHY
41
+
42
+ self.healthcheck_uc.get_health().add_check(example_pulse)
43
+
44
+ def ask_restart(self, msg: str | None = None, _call=None) -> dict:
45
+ """Fail example_pulse until the process is restarted."""
46
+ text = (msg or "").strip() or DEFAULT_RESTART
47
+ self._restart_message = text
48
+ cache = getattr(self.healthcheck_uc.get_health(), "cache", None)
49
+ if isinstance(cache, dict):
50
+ cache.clear()
51
+ return {"restart": True, "message": text}