taskflow-meter 1.0.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.
Files changed (113) hide show
  1. taskflow_meter-1.0.0/.gitignore +26 -0
  2. taskflow_meter-1.0.0/LICENSE +176 -0
  3. taskflow_meter-1.0.0/PKG-INFO +258 -0
  4. taskflow_meter-1.0.0/README.md +208 -0
  5. taskflow_meter-1.0.0/docs/PLAN.md +439 -0
  6. taskflow_meter-1.0.0/docs/guide.md +392 -0
  7. taskflow_meter-1.0.0/docs/releasing.md +77 -0
  8. taskflow_meter-1.0.0/pyproject.toml +223 -0
  9. taskflow_meter-1.0.0/taskflow_meter/__init__.py +47 -0
  10. taskflow_meter-1.0.0/taskflow_meter/_version.py +24 -0
  11. taskflow_meter-1.0.0/taskflow_meter/api/__init__.py +35 -0
  12. taskflow_meter-1.0.0/taskflow_meter/api/asgi.py +236 -0
  13. taskflow_meter-1.0.0/taskflow_meter/api/dispatch.py +128 -0
  14. taskflow_meter-1.0.0/taskflow_meter/api/http.py +210 -0
  15. taskflow_meter-1.0.0/taskflow_meter/api/router.py +113 -0
  16. taskflow_meter-1.0.0/taskflow_meter/api/routes.py +53 -0
  17. taskflow_meter-1.0.0/taskflow_meter/api/serializers.py +137 -0
  18. taskflow_meter-1.0.0/taskflow_meter/api/service.py +189 -0
  19. taskflow_meter-1.0.0/taskflow_meter/api/sse.py +222 -0
  20. taskflow_meter-1.0.0/taskflow_meter/api/wsgi.py +145 -0
  21. taskflow_meter-1.0.0/taskflow_meter/cli.py +287 -0
  22. taskflow_meter-1.0.0/taskflow_meter/collect/__init__.py +31 -0
  23. taskflow_meter-1.0.0/taskflow_meter/collect/attachment.py +208 -0
  24. taskflow_meter-1.0.0/taskflow_meter/collect/listener.py +161 -0
  25. taskflow_meter-1.0.0/taskflow_meter/collect/pipeline.py +229 -0
  26. taskflow_meter-1.0.0/taskflow_meter/collect/progress.py +170 -0
  27. taskflow_meter-1.0.0/taskflow_meter/conf.py +173 -0
  28. taskflow_meter-1.0.0/taskflow_meter/contrib/__init__.py +18 -0
  29. taskflow_meter-1.0.0/taskflow_meter/contrib/django.py +160 -0
  30. taskflow_meter-1.0.0/taskflow_meter/contrib/fastapi.py +149 -0
  31. taskflow_meter-1.0.0/taskflow_meter/contrib/flask.py +140 -0
  32. taskflow_meter-1.0.0/taskflow_meter/contrib/paste.py +96 -0
  33. taskflow_meter-1.0.0/taskflow_meter/contrib/pecan.py +84 -0
  34. taskflow_meter-1.0.0/taskflow_meter/datasource/__init__.py +33 -0
  35. taskflow_meter-1.0.0/taskflow_meter/datasource/base.py +154 -0
  36. taskflow_meter-1.0.0/taskflow_meter/datasource/memory.py +232 -0
  37. taskflow_meter-1.0.0/taskflow_meter/datasource/persistence.py +311 -0
  38. taskflow_meter-1.0.0/taskflow_meter/datasource/sqlalchemy/__init__.py +21 -0
  39. taskflow_meter-1.0.0/taskflow_meter/datasource/sqlalchemy/migrations/env.py +68 -0
  40. taskflow_meter-1.0.0/taskflow_meter/datasource/sqlalchemy/migrations/script.py.mako +25 -0
  41. taskflow_meter-1.0.0/taskflow_meter/datasource/sqlalchemy/migrations/versions/0001_initial.py +71 -0
  42. taskflow_meter-1.0.0/taskflow_meter/datasource/sqlalchemy/models.py +63 -0
  43. taskflow_meter-1.0.0/taskflow_meter/datasource/sqlalchemy/source.py +367 -0
  44. taskflow_meter-1.0.0/taskflow_meter/diff.py +223 -0
  45. taskflow_meter-1.0.0/taskflow_meter/events.py +129 -0
  46. taskflow_meter-1.0.0/taskflow_meter/fold.py +137 -0
  47. taskflow_meter-1.0.0/taskflow_meter/meter.py +255 -0
  48. taskflow_meter-1.0.0/taskflow_meter/models.py +143 -0
  49. taskflow_meter-1.0.0/taskflow_meter/poller.py +191 -0
  50. taskflow_meter-1.0.0/taskflow_meter/py.typed +0 -0
  51. taskflow_meter-1.0.0/taskflow_meter/states.py +60 -0
  52. taskflow_meter-1.0.0/taskflow_meter/transports/__init__.py +21 -0
  53. taskflow_meter-1.0.0/taskflow_meter/transports/amqp.py +204 -0
  54. taskflow_meter-1.0.0/taskflow_meter/transports/base.py +105 -0
  55. taskflow_meter-1.0.0/taskflow_meter/transports/http.py +97 -0
  56. taskflow_meter-1.0.0/taskflow_meter/transports/memory.py +83 -0
  57. taskflow_meter-1.0.0/tests/__init__.py +0 -0
  58. taskflow_meter-1.0.0/tests/asgi_client.py +148 -0
  59. taskflow_meter-1.0.0/tests/conformance/__init__.py +0 -0
  60. taskflow_meter-1.0.0/tests/conformance/test_hosts.py +164 -0
  61. taskflow_meter-1.0.0/tests/conformance/test_parity.py +197 -0
  62. taskflow_meter-1.0.0/tests/conftest.py +120 -0
  63. taskflow_meter-1.0.0/tests/functional/__init__.py +0 -0
  64. taskflow_meter-1.0.0/tests/functional/test_cross_process.py +244 -0
  65. taskflow_meter-1.0.0/tests/functional/test_examples.py +74 -0
  66. taskflow_meter-1.0.0/tests/functional/test_migrations.py +101 -0
  67. taskflow_meter-1.0.0/tests/functional/test_packaging.py +105 -0
  68. taskflow_meter-1.0.0/tests/functional/test_serve.py +195 -0
  69. taskflow_meter-1.0.0/tests/functional/test_tooling.py +122 -0
  70. taskflow_meter-1.0.0/tests/hosts.py +201 -0
  71. taskflow_meter-1.0.0/tests/integration/__init__.py +0 -0
  72. taskflow_meter-1.0.0/tests/integration/test_attach.py +329 -0
  73. taskflow_meter-1.0.0/tests/integration/test_collector.py +212 -0
  74. taskflow_meter-1.0.0/tests/unit/__init__.py +0 -0
  75. taskflow_meter-1.0.0/tests/unit/api/__init__.py +0 -0
  76. taskflow_meter-1.0.0/tests/unit/api/test_asgi.py +398 -0
  77. taskflow_meter-1.0.0/tests/unit/api/test_http.py +136 -0
  78. taskflow_meter-1.0.0/tests/unit/api/test_router.py +113 -0
  79. taskflow_meter-1.0.0/tests/unit/api/test_routes.py +116 -0
  80. taskflow_meter-1.0.0/tests/unit/api/test_serializers.py +128 -0
  81. taskflow_meter-1.0.0/tests/unit/api/test_service.py +282 -0
  82. taskflow_meter-1.0.0/tests/unit/api/test_sse.py +182 -0
  83. taskflow_meter-1.0.0/tests/unit/api/test_wsgi.py +217 -0
  84. taskflow_meter-1.0.0/tests/unit/collect/__init__.py +0 -0
  85. taskflow_meter-1.0.0/tests/unit/collect/test_attachment.py +233 -0
  86. taskflow_meter-1.0.0/tests/unit/collect/test_listener.py +185 -0
  87. taskflow_meter-1.0.0/tests/unit/collect/test_pipeline.py +405 -0
  88. taskflow_meter-1.0.0/tests/unit/collect/test_progress.py +245 -0
  89. taskflow_meter-1.0.0/tests/unit/contrib/__init__.py +0 -0
  90. taskflow_meter-1.0.0/tests/unit/contrib/test_django.py +144 -0
  91. taskflow_meter-1.0.0/tests/unit/contrib/test_fastapi.py +155 -0
  92. taskflow_meter-1.0.0/tests/unit/contrib/test_flask.py +152 -0
  93. taskflow_meter-1.0.0/tests/unit/contrib/test_paste.py +126 -0
  94. taskflow_meter-1.0.0/tests/unit/contrib/test_pecan.py +191 -0
  95. taskflow_meter-1.0.0/tests/unit/datasource/__init__.py +0 -0
  96. taskflow_meter-1.0.0/tests/unit/datasource/sqlalchemy/__init__.py +0 -0
  97. taskflow_meter-1.0.0/tests/unit/datasource/sqlalchemy/test_source.py +527 -0
  98. taskflow_meter-1.0.0/tests/unit/datasource/test_base.py +148 -0
  99. taskflow_meter-1.0.0/tests/unit/datasource/test_memory.py +536 -0
  100. taskflow_meter-1.0.0/tests/unit/datasource/test_persistence.py +420 -0
  101. taskflow_meter-1.0.0/tests/unit/test_cli.py +154 -0
  102. taskflow_meter-1.0.0/tests/unit/test_conf.py +184 -0
  103. taskflow_meter-1.0.0/tests/unit/test_diff.py +384 -0
  104. taskflow_meter-1.0.0/tests/unit/test_events.py +127 -0
  105. taskflow_meter-1.0.0/tests/unit/test_meter.py +297 -0
  106. taskflow_meter-1.0.0/tests/unit/test_models.py +147 -0
  107. taskflow_meter-1.0.0/tests/unit/test_poller.py +393 -0
  108. taskflow_meter-1.0.0/tests/unit/test_states.py +62 -0
  109. taskflow_meter-1.0.0/tests/unit/transports/__init__.py +0 -0
  110. taskflow_meter-1.0.0/tests/unit/transports/test_amqp.py +348 -0
  111. taskflow_meter-1.0.0/tests/unit/transports/test_http.py +141 -0
  112. taskflow_meter-1.0.0/tests/unit/transports/test_memory.py +79 -0
  113. taskflow_meter-1.0.0/tests/wsgi_client.py +112 -0
@@ -0,0 +1,26 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Generated by hatch-vcs at build time
13
+ taskflow_meter/_version.py
14
+
15
+ # Tooling caches and reports
16
+ .tox/
17
+ .pytest_cache/
18
+ .ruff_cache/
19
+ .mypy_cache/
20
+ .coverage
21
+ .coverage.*
22
+ coverage.xml
23
+ htmlcov/
24
+
25
+ # Resolved by uv on demand; this is a library, so the lock is not pinned
26
+ uv.lock
@@ -0,0 +1,176 @@
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
+
@@ -0,0 +1,258 @@
1
+ Metadata-Version: 2.5
2
+ Name: taskflow-meter
3
+ Version: 1.0.0
4
+ Summary: Monitoring interfaces (ASGI, WSGI, datasource) for OpenStack TaskFlow flow execution progress
5
+ Project-URL: Homepage, https://github.com/daipham3213/taskflow-meter
6
+ Project-URL: Source, https://github.com/daipham3213/taskflow-meter
7
+ Project-URL: Issues, https://github.com/daipham3213/taskflow-meter/issues
8
+ Project-URL: Changelog, https://github.com/daipham3213/taskflow-meter/releases
9
+ Author-email: Pham Le Gia Dai <daipham.3213@gmail.com>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: asgi,monitoring,openstack,taskflow,workflow,wsgi
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: System :: Monitoring
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: oslo-cache>=3.0.0
26
+ Requires-Dist: oslo-config>=9.0.0
27
+ Requires-Dist: oslo-serialization>=2.18.0
28
+ Requires-Dist: oslo-utils>=3.33.0
29
+ Requires-Dist: stevedore>=1.20.0
30
+ Requires-Dist: taskflow>=6.4.0
31
+ Provides-Extra: all
32
+ Requires-Dist: alembic>=1.13; extra == 'all'
33
+ Requires-Dist: kombu>=5.0; extra == 'all'
34
+ Requires-Dist: oslo-cache[dogpile]>=3.0.0; extra == 'all'
35
+ Requires-Dist: oslo-cache[etcd3gw]>=3.0.0; extra == 'all'
36
+ Requires-Dist: prometheus-client>=0.20; extra == 'all'
37
+ Requires-Dist: sqlalchemy>=2.0; extra == 'all'
38
+ Provides-Extra: amqp
39
+ Requires-Dist: kombu>=5.0; extra == 'amqp'
40
+ Provides-Extra: etcd
41
+ Requires-Dist: oslo-cache[etcd3gw]>=3.0.0; extra == 'etcd'
42
+ Provides-Extra: memcache
43
+ Requires-Dist: oslo-cache[dogpile]>=3.0.0; extra == 'memcache'
44
+ Provides-Extra: prometheus
45
+ Requires-Dist: prometheus-client>=0.20; extra == 'prometheus'
46
+ Provides-Extra: sqlalchemy
47
+ Requires-Dist: alembic>=1.13; extra == 'sqlalchemy'
48
+ Requires-Dist: sqlalchemy>=2.0; extra == 'sqlalchemy'
49
+ Description-Content-Type: text/markdown
50
+
51
+ # taskflow-meter
52
+
53
+ Monitoring interfaces — ASGI, WSGI, datasources, transports — for observing
54
+ [OpenStack TaskFlow](https://opendev.org/openstack/taskflow) flow execution
55
+ progress.
56
+
57
+ > **Status: pre-alpha.** The packaging, tooling and CI skeleton are in place
58
+ > (milestone M0). The design is specified in [`docs/PLAN.md`](docs/PLAN.md);
59
+ > functionality lands milestone by milestone against it.
60
+
61
+ ## What it is for
62
+
63
+ TaskFlow knows exactly where a flow is — which atoms have run, which are
64
+ running, how far along each task reports itself — but it offers no way to
65
+ *look* at that from outside the process running the flow. `taskflow-meter`
66
+ provides that view:
67
+
68
+ - **Read-only over your existing persistence backend.** Task progress is
69
+ written through to the persistence layer on every `update_progress()` call,
70
+ so an existing deployment can be monitored with *no changes to flow code*.
71
+ - **Embeddable anywhere.** Ships a hand-rolled ASGI callable and a hand-rolled
72
+ WSGI callable with no web framework dependency, mountable at any sub-path
73
+ inside FastAPI, Starlette, Flask, Django, or served standalone.
74
+ - **Live, in-process option.** Attach a listener plus a per-atom progress tap
75
+ to an engine for sub-second latency and full DAG topology.
76
+
77
+ ## Using it
78
+
79
+ Point a meter at a taskflow persistence backend and serve it:
80
+
81
+ ```python
82
+ from taskflow_meter.api.asgi import ASGIApp
83
+ from taskflow_meter.datasource.persistence import PersistenceDataSource
84
+ from taskflow_meter.meter import Meter
85
+
86
+ source = PersistenceDataSource(conf={"connection": "sqlite:///taskflow.db"})
87
+ meter = Meter(source) # polls the backend, keeps an event stream
88
+ app = ASGIApp(meter) # a plain ASGI 3 callable
89
+ ```
90
+
91
+ `app` runs under any ASGI server (`uvicorn module:app`), or mounts inside an
92
+ application you already have:
93
+
94
+ ```python
95
+ host.mount("/taskflow", ASGIApp(meter)) # Starlette / FastAPI
96
+ ```
97
+
98
+ There is a WSGI callable too, with identical behaviour -- a conformance suite
99
+ compares the two byte for byte:
100
+
101
+ ```python
102
+ from taskflow_meter.api.wsgi import WSGIApp
103
+
104
+ application = WSGIApp(meter) # gunicorn module:application
105
+
106
+ app.wsgi_app = DispatcherMiddleware( # Flask / werkzeug
107
+ app.wsgi_app, {"/taskflow": WSGIApp(meter)}
108
+ )
109
+ ```
110
+
111
+ Or serve it straight away, with no server dependency at all:
112
+
113
+ ```bash
114
+ taskflow-meter serve --connection sqlite:///taskflow.db
115
+ ```
116
+
117
+ That runs on `wsgiref` from the standard library and binds localhost. It is a
118
+ development server -- put the WSGI callable behind gunicorn for anything real.
119
+
120
+ For a fleet, run the collector: the flows publish to a broker, one process
121
+ writes to the meter's own database, and the API workers read it without
122
+ polling anything.
123
+
124
+ ```bash
125
+ taskflow-meter upgrade --store-url postgresql://host/meter
126
+ taskflow-meter collect --amqp-url amqp://broker// --store-url postgresql://host/meter
127
+ taskflow-meter serve --store-url postgresql://host/meter
128
+ ```
129
+ One caveat for WSGI deployments: a synchronous worker holds a thread for as
130
+ long as an SSE stream stays open, so use gevent or eventlet workers for
131
+ streaming, or let clients poll `/events?since_seq=` instead.
132
+
133
+ Mounted apps never receive the ASGI lifespan scope, so the meter also starts
134
+ itself on the first request. If your host application has a lifespan of its
135
+ own, prefer `meter.start()` / `meter.stop()` from it.
136
+
137
+ ### Inside a service you already run
138
+
139
+ If your service composes its WSGI stack from `api-paste.ini`, dispatch a
140
+ prefix to the meter and configure it in the service's own config file:
141
+
142
+ ```ini
143
+ [composite:main]
144
+ use = egg:Paste#urlmap
145
+ /: your_api
146
+ /taskflow-meter: taskflow_meter
147
+
148
+ [app:taskflow_meter]
149
+ paste.app_factory = taskflow_meter.contrib.paste:app_factory
150
+ ```
151
+
152
+ ```ini
153
+ [taskflow_meter]
154
+ connection = mysql+pymysql://user:password@host/taskflow
155
+ ```
156
+
157
+ Native adapters exist for the frameworks where the routes should live inside
158
+ the host application rather than beside it, so its auth and middleware apply
159
+ to them:
160
+
161
+ | Host | Adapter |
162
+ | --- | --- |
163
+ | FastAPI | `contrib.fastapi.meter_router(meter)` |
164
+ | Flask | `contrib.flask.meter_blueprint(meter)` |
165
+ | Django | `contrib.django.meter_urlpatterns(meter)` |
166
+ | Pecan | `contrib.pecan.MeterController()` |
167
+ | paste | `contrib.paste:app_factory` |
168
+
169
+ See [the guide](docs/guide.md) for all of them, and for how to read completion
170
+ and current-task out of the API.
171
+
172
+ ### Watching from inside the process running the flow
173
+
174
+ If you control the code that runs the flow, attaching to the engine gets you
175
+ what reading persistence cannot: progress readable in single-digit
176
+ milliseconds instead of a poll interval, and the flow's graph, which taskflow
177
+ never persists.
178
+
179
+ ```python
180
+ from taskflow_meter.collect import attach
181
+
182
+ with attach(engine) as watched:
183
+ engine.run()
184
+ meter = Meter(watched.store, poll=False)
185
+ ```
186
+
187
+ Delivery happens on its own thread behind a bounded queue, so a task never
188
+ waits on a publisher, and no failure downstream -- a broken webhook, a full
189
+ queue, a publisher that raises -- can fail a task.
190
+
191
+ ### Endpoints
192
+
193
+ | Path | What it returns |
194
+ | --- | --- |
195
+ | `GET /healthz` | Liveness, version, and poller counters |
196
+ | `GET /api/v1/flows` | Flows, newest first, filterable and paged |
197
+ | `GET /api/v1/flows/{run_id}` | One flow with its atoms |
198
+ | `GET /api/v1/flows/{run_id}/atoms` | Just the atoms |
199
+ | `GET /api/v1/flows/{run_id}/events` | Event history from `?since_seq=` |
200
+ | `GET /api/v1/flows/{run_id}/stream` | The same events as SSE, live |
201
+
202
+ The stream honours `Last-Event-ID`, so a dropped connection resumes where it
203
+ left off rather than leaving a hole. If the datasource keeps no history, the
204
+ two event endpoints answer 501 and flow payloads omit their links, rather than
205
+ serving an empty stream that cannot be told apart from silence.
206
+
207
+ ## Requirements
208
+
209
+ - Python 3.11+
210
+ - taskflow 6.4.0+
211
+
212
+ ## Examples
213
+
214
+ Runnable, and covered by the test suite so they cannot rot:
215
+ [`examples/`](examples/).
216
+
217
+ ## Development
218
+
219
+ This project builds with [Hatch](https://hatch.pypa.io) (`hatchling` +
220
+ `hatch-vcs`, so the version comes from git tags) and is developed with
221
+ [uv](https://docs.astral.sh/uv/).
222
+
223
+ ```bash
224
+ uv run --group dev pytest # tests
225
+ uv run --group dev ruff check . # lint
226
+ uv run --group dev ruff format . # format
227
+ uv run --group dev mypy # type check
228
+ uv build # build sdist + wheel
229
+ ```
230
+
231
+ `tox` is available too, and is what CI reproduces:
232
+
233
+ ```bash
234
+ uvx tox -e pep8 # ruff, hacking, mypy, and the test-tree check
235
+ uvx tox -e py312 # tests on one interpreter
236
+ uvx tox # the whole matrix
237
+ ```
238
+
239
+ Because the version is derived from git history, a shallow clone or a checkout
240
+ with no tags will build as `0.0.0`. CI checks out with full history.
241
+
242
+ ### Where tests go
243
+
244
+ A unit test module mirrors the module it targets, so finding the tests for a
245
+ file is mechanical rather than a search:
246
+
247
+ | Module | Its tests |
248
+ | --- | --- |
249
+ | `taskflow_meter/diff.py` | `tests/unit/test_diff.py` |
250
+ | `taskflow_meter/datasource/memory.py` | `tests/unit/datasource/test_memory.py` |
251
+
252
+ Tests that do not target a single module go in a sibling tree instead --
253
+ `tests/functional/`, `tests/integration/` or `tests/conformance/`. Anything
254
+ misplaced fails `tox -e pep8`.
255
+
256
+ ## License
257
+
258
+ Apache-2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,208 @@
1
+ # taskflow-meter
2
+
3
+ Monitoring interfaces — ASGI, WSGI, datasources, transports — for observing
4
+ [OpenStack TaskFlow](https://opendev.org/openstack/taskflow) flow execution
5
+ progress.
6
+
7
+ > **Status: pre-alpha.** The packaging, tooling and CI skeleton are in place
8
+ > (milestone M0). The design is specified in [`docs/PLAN.md`](docs/PLAN.md);
9
+ > functionality lands milestone by milestone against it.
10
+
11
+ ## What it is for
12
+
13
+ TaskFlow knows exactly where a flow is — which atoms have run, which are
14
+ running, how far along each task reports itself — but it offers no way to
15
+ *look* at that from outside the process running the flow. `taskflow-meter`
16
+ provides that view:
17
+
18
+ - **Read-only over your existing persistence backend.** Task progress is
19
+ written through to the persistence layer on every `update_progress()` call,
20
+ so an existing deployment can be monitored with *no changes to flow code*.
21
+ - **Embeddable anywhere.** Ships a hand-rolled ASGI callable and a hand-rolled
22
+ WSGI callable with no web framework dependency, mountable at any sub-path
23
+ inside FastAPI, Starlette, Flask, Django, or served standalone.
24
+ - **Live, in-process option.** Attach a listener plus a per-atom progress tap
25
+ to an engine for sub-second latency and full DAG topology.
26
+
27
+ ## Using it
28
+
29
+ Point a meter at a taskflow persistence backend and serve it:
30
+
31
+ ```python
32
+ from taskflow_meter.api.asgi import ASGIApp
33
+ from taskflow_meter.datasource.persistence import PersistenceDataSource
34
+ from taskflow_meter.meter import Meter
35
+
36
+ source = PersistenceDataSource(conf={"connection": "sqlite:///taskflow.db"})
37
+ meter = Meter(source) # polls the backend, keeps an event stream
38
+ app = ASGIApp(meter) # a plain ASGI 3 callable
39
+ ```
40
+
41
+ `app` runs under any ASGI server (`uvicorn module:app`), or mounts inside an
42
+ application you already have:
43
+
44
+ ```python
45
+ host.mount("/taskflow", ASGIApp(meter)) # Starlette / FastAPI
46
+ ```
47
+
48
+ There is a WSGI callable too, with identical behaviour -- a conformance suite
49
+ compares the two byte for byte:
50
+
51
+ ```python
52
+ from taskflow_meter.api.wsgi import WSGIApp
53
+
54
+ application = WSGIApp(meter) # gunicorn module:application
55
+
56
+ app.wsgi_app = DispatcherMiddleware( # Flask / werkzeug
57
+ app.wsgi_app, {"/taskflow": WSGIApp(meter)}
58
+ )
59
+ ```
60
+
61
+ Or serve it straight away, with no server dependency at all:
62
+
63
+ ```bash
64
+ taskflow-meter serve --connection sqlite:///taskflow.db
65
+ ```
66
+
67
+ That runs on `wsgiref` from the standard library and binds localhost. It is a
68
+ development server -- put the WSGI callable behind gunicorn for anything real.
69
+
70
+ For a fleet, run the collector: the flows publish to a broker, one process
71
+ writes to the meter's own database, and the API workers read it without
72
+ polling anything.
73
+
74
+ ```bash
75
+ taskflow-meter upgrade --store-url postgresql://host/meter
76
+ taskflow-meter collect --amqp-url amqp://broker// --store-url postgresql://host/meter
77
+ taskflow-meter serve --store-url postgresql://host/meter
78
+ ```
79
+ One caveat for WSGI deployments: a synchronous worker holds a thread for as
80
+ long as an SSE stream stays open, so use gevent or eventlet workers for
81
+ streaming, or let clients poll `/events?since_seq=` instead.
82
+
83
+ Mounted apps never receive the ASGI lifespan scope, so the meter also starts
84
+ itself on the first request. If your host application has a lifespan of its
85
+ own, prefer `meter.start()` / `meter.stop()` from it.
86
+
87
+ ### Inside a service you already run
88
+
89
+ If your service composes its WSGI stack from `api-paste.ini`, dispatch a
90
+ prefix to the meter and configure it in the service's own config file:
91
+
92
+ ```ini
93
+ [composite:main]
94
+ use = egg:Paste#urlmap
95
+ /: your_api
96
+ /taskflow-meter: taskflow_meter
97
+
98
+ [app:taskflow_meter]
99
+ paste.app_factory = taskflow_meter.contrib.paste:app_factory
100
+ ```
101
+
102
+ ```ini
103
+ [taskflow_meter]
104
+ connection = mysql+pymysql://user:password@host/taskflow
105
+ ```
106
+
107
+ Native adapters exist for the frameworks where the routes should live inside
108
+ the host application rather than beside it, so its auth and middleware apply
109
+ to them:
110
+
111
+ | Host | Adapter |
112
+ | --- | --- |
113
+ | FastAPI | `contrib.fastapi.meter_router(meter)` |
114
+ | Flask | `contrib.flask.meter_blueprint(meter)` |
115
+ | Django | `contrib.django.meter_urlpatterns(meter)` |
116
+ | Pecan | `contrib.pecan.MeterController()` |
117
+ | paste | `contrib.paste:app_factory` |
118
+
119
+ See [the guide](docs/guide.md) for all of them, and for how to read completion
120
+ and current-task out of the API.
121
+
122
+ ### Watching from inside the process running the flow
123
+
124
+ If you control the code that runs the flow, attaching to the engine gets you
125
+ what reading persistence cannot: progress readable in single-digit
126
+ milliseconds instead of a poll interval, and the flow's graph, which taskflow
127
+ never persists.
128
+
129
+ ```python
130
+ from taskflow_meter.collect import attach
131
+
132
+ with attach(engine) as watched:
133
+ engine.run()
134
+ meter = Meter(watched.store, poll=False)
135
+ ```
136
+
137
+ Delivery happens on its own thread behind a bounded queue, so a task never
138
+ waits on a publisher, and no failure downstream -- a broken webhook, a full
139
+ queue, a publisher that raises -- can fail a task.
140
+
141
+ ### Endpoints
142
+
143
+ | Path | What it returns |
144
+ | --- | --- |
145
+ | `GET /healthz` | Liveness, version, and poller counters |
146
+ | `GET /api/v1/flows` | Flows, newest first, filterable and paged |
147
+ | `GET /api/v1/flows/{run_id}` | One flow with its atoms |
148
+ | `GET /api/v1/flows/{run_id}/atoms` | Just the atoms |
149
+ | `GET /api/v1/flows/{run_id}/events` | Event history from `?since_seq=` |
150
+ | `GET /api/v1/flows/{run_id}/stream` | The same events as SSE, live |
151
+
152
+ The stream honours `Last-Event-ID`, so a dropped connection resumes where it
153
+ left off rather than leaving a hole. If the datasource keeps no history, the
154
+ two event endpoints answer 501 and flow payloads omit their links, rather than
155
+ serving an empty stream that cannot be told apart from silence.
156
+
157
+ ## Requirements
158
+
159
+ - Python 3.11+
160
+ - taskflow 6.4.0+
161
+
162
+ ## Examples
163
+
164
+ Runnable, and covered by the test suite so they cannot rot:
165
+ [`examples/`](examples/).
166
+
167
+ ## Development
168
+
169
+ This project builds with [Hatch](https://hatch.pypa.io) (`hatchling` +
170
+ `hatch-vcs`, so the version comes from git tags) and is developed with
171
+ [uv](https://docs.astral.sh/uv/).
172
+
173
+ ```bash
174
+ uv run --group dev pytest # tests
175
+ uv run --group dev ruff check . # lint
176
+ uv run --group dev ruff format . # format
177
+ uv run --group dev mypy # type check
178
+ uv build # build sdist + wheel
179
+ ```
180
+
181
+ `tox` is available too, and is what CI reproduces:
182
+
183
+ ```bash
184
+ uvx tox -e pep8 # ruff, hacking, mypy, and the test-tree check
185
+ uvx tox -e py312 # tests on one interpreter
186
+ uvx tox # the whole matrix
187
+ ```
188
+
189
+ Because the version is derived from git history, a shallow clone or a checkout
190
+ with no tags will build as `0.0.0`. CI checks out with full history.
191
+
192
+ ### Where tests go
193
+
194
+ A unit test module mirrors the module it targets, so finding the tests for a
195
+ file is mechanical rather than a search:
196
+
197
+ | Module | Its tests |
198
+ | --- | --- |
199
+ | `taskflow_meter/diff.py` | `tests/unit/test_diff.py` |
200
+ | `taskflow_meter/datasource/memory.py` | `tests/unit/datasource/test_memory.py` |
201
+
202
+ Tests that do not target a single module go in a sibling tree instead --
203
+ `tests/functional/`, `tests/integration/` or `tests/conformance/`. Anything
204
+ misplaced fails `tox -e pep8`.
205
+
206
+ ## License
207
+
208
+ Apache-2.0. See [`LICENSE`](LICENSE).