keepup-admin 0.4.0__tar.gz → 0.5.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 (102) hide show
  1. {keepup_admin-0.4.0/keepup_admin.egg-info → keepup_admin-0.5.0}/PKG-INFO +77 -36
  2. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/README.md +60 -23
  3. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/__init__.py +20 -10
  4. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/builtin/audit.py +46 -7
  5. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/builtin/auth.py +37 -5
  6. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/builtin/db.py +8 -5
  7. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/builtin/postgres.py +11 -3
  8. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/builtin/sqlite.py +11 -3
  9. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/builtin/ui.py +3 -3
  10. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/builtin/users.py +6 -7
  11. keepup_admin-0.5.0/clock.py +28 -0
  12. {keepup_admin-0.4.0 → keepup_admin-0.5.0/keepup_admin.egg-info}/PKG-INFO +77 -36
  13. keepup_admin-0.5.0/keepup_admin.egg-info/SOURCES.txt +85 -0
  14. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/keepup_admin.egg-info/requires.txt +21 -12
  15. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/contributions.py +2 -0
  16. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/lifecycle.py +1 -1
  17. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/services.py +36 -13
  18. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/locks.py +29 -152
  19. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/logging_setup.py +7 -43
  20. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/notification_bus.py +85 -115
  21. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/plugins/builtin.json +6 -0
  22. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/plugins/registry.py +90 -33
  23. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/pyproject.toml +45 -30
  24. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/security.py +1 -1
  25. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/settings.py +0 -9
  26. keepup_admin-0.4.0/admin_trail.py +0 -60
  27. keepup_admin-0.4.0/api_docs.py +0 -76
  28. keepup_admin-0.4.0/audit.py +0 -461
  29. keepup_admin-0.4.0/body_limit.py +0 -156
  30. keepup_admin-0.4.0/builtin/integration_logs.py +0 -297
  31. keepup_admin-0.4.0/builtin/metrics.py +0 -226
  32. keepup_admin-0.4.0/cluster.py +0 -655
  33. keepup_admin-0.4.0/compat.py +0 -270
  34. keepup_admin-0.4.0/events_api.py +0 -236
  35. keepup_admin-0.4.0/factory.py +0 -668
  36. keepup_admin-0.4.0/integrations.py +0 -227
  37. keepup_admin-0.4.0/keepup_admin.egg-info/SOURCES.txt +0 -187
  38. keepup_admin-0.4.0/log_shipping.py +0 -695
  39. keepup_admin-0.4.0/metrics.py +0 -587
  40. keepup_admin-0.4.0/metrics_api.py +0 -280
  41. keepup_admin-0.4.0/metrics_retention.py +0 -379
  42. keepup_admin-0.4.0/modules.py +0 -697
  43. keepup_admin-0.4.0/plugins/admin.py +0 -273
  44. keepup_admin-0.4.0/plugins/routes.py +0 -549
  45. keepup_admin-0.4.0/retention.py +0 -87
  46. keepup_admin-0.4.0/scheduler.py +0 -124
  47. keepup_admin-0.4.0/schema.py +0 -214
  48. keepup_admin-0.4.0/static/css/aos.css +0 -1
  49. keepup_admin-0.4.0/static/css/main_nebula.css +0 -232
  50. keepup_admin-0.4.0/static/css/main_new.css +0 -869
  51. keepup_admin-0.4.0/static/css/tailwind.css +0 -1
  52. keepup_admin-0.4.0/static/index_nebula.html +0 -282
  53. keepup_admin-0.4.0/static/index_new.html +0 -275
  54. keepup_admin-0.4.0/static/js/aos.js +0 -1
  55. keepup_admin-0.4.0/static/js/feather-icons.js +0 -13
  56. keepup_admin-0.4.0/static/js/layout_bootstrap.js +0 -29
  57. keepup_admin-0.4.0/static/js/main_new.js +0 -2076
  58. keepup_admin-0.4.0/static/js/tailwind.js +0 -83
  59. keepup_admin-0.4.0/static/modules/css/background_tasks.css +0 -233
  60. keepup_admin-0.4.0/static/modules/css/cluster.css +0 -16
  61. keepup_admin-0.4.0/static/modules/css/event_manager.css +0 -386
  62. keepup_admin-0.4.0/static/modules/css/integration_logs.css +0 -33
  63. keepup_admin-0.4.0/static/modules/css/metrics.css +0 -115
  64. keepup_admin-0.4.0/static/modules/css/modules.css +0 -189
  65. keepup_admin-0.4.0/static/modules/css/themes.css +0 -563
  66. keepup_admin-0.4.0/static/modules/css/users.css +0 -278
  67. keepup_admin-0.4.0/static/modules/js/background_tasks.js +0 -679
  68. keepup_admin-0.4.0/static/modules/js/chart.js +0 -14
  69. keepup_admin-0.4.0/static/modules/js/chartjs-adapter-date-fns.bundle.min.js +0 -7
  70. keepup_admin-0.4.0/static/modules/js/cluster.js +0 -374
  71. keepup_admin-0.4.0/static/modules/js/event_manager.js +0 -1007
  72. keepup_admin-0.4.0/static/modules/js/integration_logs.js +0 -795
  73. keepup_admin-0.4.0/static/modules/js/metrics.js +0 -929
  74. keepup_admin-0.4.0/static/modules/js/modules.js +0 -1128
  75. keepup_admin-0.4.0/static/modules/js/themes.js +0 -684
  76. keepup_admin-0.4.0/static/modules/js/users.js +0 -898
  77. keepup_admin-0.4.0/themes.py +0 -535
  78. keepup_admin-0.4.0/web.py +0 -201
  79. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/LICENSE +0 -0
  80. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/NOTICE +0 -0
  81. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/THIRD-PARTY.md +0 -0
  82. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/api_versions.py +0 -0
  83. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/cache.py +0 -0
  84. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/instance.py +0 -0
  85. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/keepup_admin.egg-info/dependency_links.txt +0 -0
  86. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/keepup_admin.egg-info/top_level.txt +0 -0
  87. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/__init__.py +0 -0
  88. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/call.py +0 -0
  89. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/catalogue.py +0 -0
  90. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/datasource.py +0 -0
  91. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/descriptor.py +0 -0
  92. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/loader.py +0 -0
  93. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/observability.py +0 -0
  94. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/security.py +0 -0
  95. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/kernel/transports.py +0 -0
  96. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/plugins/__init__.py +0 -0
  97. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/plugins/base.py +0 -0
  98. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/plugins/enablement.py +0 -0
  99. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/plugins/route_mask.py +0 -0
  100. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/roles.py +0 -0
  101. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/sections.json +0 -0
  102. {keepup_admin-0.4.0 → keepup_admin-0.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keepup-admin
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: An admin framework over FastAPI: plugins, panel, users, replicas
5
5
  Author-email: Fedor Sergeev <fksergeev@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -18,24 +18,13 @@ Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  License-File: NOTICE
20
20
  License-File: THIRD-PARTY.md
21
- Requires-Dist: fastapi<1,>=0.128
22
- Requires-Dist: starlette<2,>=1.3.1
23
- Requires-Dist: pydantic<3,>=2.11
24
- Requires-Dist: sqlalchemy<3,>=2.0
25
- Requires-Dist: apscheduler<4,>=3.10
26
21
  Requires-Dist: python-multipart>=0.0.31
27
- Requires-Dist: PyYAML<7,>=6.0
28
- Requires-Dist: psutil>=7.0
29
- Requires-Dist: prometheus-client>=0.24
30
- Requires-Dist: requests>=2.33
31
- Requires-Dist: httpx>=0.28
32
- Requires-Dist: cryptography>=50.0
33
- Requires-Dist: urllib3>=2.8
34
22
  Provides-Extra: test
35
23
  Requires-Dist: pytest>=8; extra == "test"
36
24
  Requires-Dist: pytest-asyncio>=0.24; extra == "test"
37
25
  Requires-Dist: pytest-cov>=5; extra == "test"
38
26
  Requires-Dist: uvicorn>=0.30; extra == "test"
27
+ Requires-Dist: fastapi<1,>=0.128; extra == "test"
39
28
  Provides-Extra: db
40
29
  Requires-Dist: keepup-db>=0.4.0; extra == "db"
41
30
  Provides-Extra: auth
@@ -48,6 +37,16 @@ Provides-Extra: audit
48
37
  Requires-Dist: keepup-audit>=0.4.0; extra == "audit"
49
38
  Provides-Extra: metrics
50
39
  Requires-Dist: keepup-metrics>=0.4.0; extra == "metrics"
40
+ Provides-Extra: tasks
41
+ Requires-Dist: keepup-tasks>=0.4.0; extra == "tasks"
42
+ Provides-Extra: modules
43
+ Requires-Dist: keepup-modules>=0.4.0; extra == "modules"
44
+ Provides-Extra: cluster
45
+ Requires-Dist: keepup-cluster>=0.4.0; extra == "cluster"
46
+ Provides-Extra: log-shipping
47
+ Requires-Dist: keepup-log-shipping>=0.4.0; extra == "log-shipping"
48
+ Provides-Extra: http
49
+ Requires-Dist: keepup-http>=0.4.0; extra == "http"
51
50
  Provides-Extra: integration-log
52
51
  Requires-Dist: keepup-integration-log>=0.4.0; extra == "integration-log"
53
52
  Provides-Extra: panel
@@ -57,6 +56,11 @@ Requires-Dist: keepup-users>=0.4.0; extra == "panel"
57
56
  Requires-Dist: keepup-ui>=0.4.0; extra == "panel"
58
57
  Requires-Dist: keepup-audit>=0.4.0; extra == "panel"
59
58
  Requires-Dist: keepup-metrics>=0.4.0; extra == "panel"
59
+ Requires-Dist: keepup-tasks>=0.4.0; extra == "panel"
60
+ Requires-Dist: keepup-modules>=0.4.0; extra == "panel"
61
+ Requires-Dist: keepup-http>=0.4.0; extra == "panel"
62
+ Requires-Dist: keepup-cluster>=0.4.0; extra == "panel"
63
+ Requires-Dist: keepup-log-shipping>=0.4.0; extra == "panel"
60
64
  Requires-Dist: keepup-integration-log>=0.4.0; extra == "panel"
61
65
  Provides-Extra: postgres
62
66
  Requires-Dist: keepup-postgres>=0.4.0; extra == "postgres"
@@ -73,17 +77,9 @@ Dynamic: license-file
73
77
 
74
78
  [Project page](https://fedorsergeev.github.io/keepup-admin/) ·
75
79
  [Package](https://pypi.org/project/keepup-admin/) ·
80
+ [Install](INSTALL.md) ·
76
81
  [Changes](CHANGELOG.md)
77
82
 
78
- Four badges, not six checks. These answer what somebody deciding whether to
79
- install asks: does it run on my Python, is there a known vulnerability in what
80
- it pulls in, what will I get, and may I use it. `quality`, `build` and `codeql`
81
- are housekeeping and live on the Actions page -- six badges in a row stop being
82
- read at all.
83
-
84
- A badge shows; it does not require. What keeps a red check from being merged is
85
- a branch rule, not a picture -- see `doc/keepup.md`.
86
-
87
83
  An admin framework over FastAPI. You give it settings; it gives you an
88
84
  application with a panel, a plugin runtime, users, a database layer, an audit,
89
85
  metrics and coordination between replicas already wired.
@@ -94,14 +90,40 @@ from keepup import KeepupSettings, create_app
94
90
  app = create_app(KeepupSettings(title="Your product", project_name="yours"))
95
91
  ```
96
92
 
97
- That is a running application with a working panel at `/selfcare`: the shell,
98
- the themes and eight administrative sections ship inside the package, so there
99
- is nothing to copy into your tree to see them.
93
+ That is a running application with a working panel at `/selfcare` once the
94
+ capabilities are installed: the shell, the themes and eight administrative
95
+ sections ship with them, so there is nothing to copy into your tree to see them.
100
96
 
101
97
  Installed as `keepup-admin`; imported as `keepup`. The name `keepup` on PyPI
102
98
  belongs to an unrelated project from 2015 that installs a script and no module,
103
99
  so the import name is free.
104
100
 
101
+ ## Install
102
+
103
+ Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
104
+ development.
105
+
106
+ ```bash
107
+ pip install "keepup-admin[panel,postgres]"
108
+ ```
109
+
110
+ That is the base plus the capabilities the panel profile enables and the
111
+ PostgreSQL driver. The base alone is the constructor:
112
+
113
+ ```bash
114
+ pip install keepup-admin
115
+ ```
116
+
117
+ — the kernel, the catalogue, the service registry, the lifecycle and the
118
+ transport seam, carrying no capability of its own. Each capability is an extra:
119
+ `db`, `auth`, `users`, `ui`, `audit`, `metrics`, `tasks`, `modules`, `cluster`,
120
+ `log_shipping`, `http`, `integration_log`, and one driver, `postgres` or
121
+ `sqlite` — one, because two drivers of one required service stop the start on
122
+ purpose.
123
+
124
+ `INSTALL.md` has the long form: every extra and what it brings, installing from
125
+ the repository, the build and the release.
126
+
105
127
  ## What it gives you
106
128
 
107
129
  | | |
@@ -137,17 +159,33 @@ with an underscore, whatever module it sits in.
137
159
  repository: a name taken out of the framework and not declared public fails the
138
160
  run, and the failure says what to do about it.
139
161
 
140
- ## Requirements
162
+ ## Build
141
163
 
142
- Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
143
- development. `pip install keepup-admin[postgres]` adds the driver the bus
144
- between replicas needs.
164
+ A release is one distribution per capability, and `build.yml` checks on every
165
+ change that they are publishable rather than discovering it at a tag:
166
+
167
+ ```bash
168
+ python -m pip install --upgrade build twine
169
+
170
+ python -m build # the base, keepup-admin
171
+ for package in packages/*; do # each capability
172
+ python -m build --outdir dist "$package"
173
+ done
174
+
175
+ python -m twine check --strict dist/*
176
+ ```
177
+
178
+ The same job then installs the built wheels into an empty virtual environment
179
+ and imports the framework there: a version on PyPI cannot be replaced, and a
180
+ wheel that installs and does not import is the one failure a metadata check
181
+ cannot see. The tag is the release's number and the job refuses one the metadata
182
+ disagrees with; see `.github/workflows/release.yml` and `INSTALL.md`.
145
183
 
146
184
  ## Tests
147
185
 
148
186
  ```bash
149
187
  pip install -e ".[test]" -e packages/keepup-*
150
- pytest tests/
188
+ python -m pytest tests/ -q --cov --cov-config=pyproject.toml
151
189
  ```
152
190
 
153
191
  **Install first, then test.** Pointing pytest at the checkout does not work on
@@ -161,12 +199,15 @@ from the index.
161
199
  The suite runs against SQLite with no network, needs no application beside the
162
200
  package, and holds a coverage floor declared in `pyproject.toml`. Checks that
163
201
  genuinely need a consumer of the framework find one by trait and skip with a
164
- reason when there is none, so a skip here always says what is missing.
165
-
166
- Every one of these runs on push and on a pull request; see `.github/workflows/`.
167
- `security.yml` also runs weekly, because that check goes red without anybody
168
- touching the repository — an advisory gets published against a version that was
169
- fine yesterday.
202
+ reason when there is none, so a skip here always says what is missing. A test is
203
+ named `*_tests.py` and run by path — `python -m pytest tests/runtime_tests.py -v`.
204
+
205
+ Every one of these runs on push and on a pull request, on Python 3.11, 3.12 and
206
+ 3.13; see `.github/workflows/`. `security.yml` also runs weekly, because that
207
+ check goes red without anybody touching the repository — an advisory gets
208
+ published against a version that was fine yesterday. `INSTALL.md` carries the
209
+ heavier checks: the wheel installed into a throwaway environment, and the
210
+ security audit.
170
211
 
171
212
  ## Licence
172
213
 
@@ -7,17 +7,9 @@
7
7
 
8
8
  [Project page](https://fedorsergeev.github.io/keepup-admin/) ·
9
9
  [Package](https://pypi.org/project/keepup-admin/) ·
10
+ [Install](INSTALL.md) ·
10
11
  [Changes](CHANGELOG.md)
11
12
 
12
- Four badges, not six checks. These answer what somebody deciding whether to
13
- install asks: does it run on my Python, is there a known vulnerability in what
14
- it pulls in, what will I get, and may I use it. `quality`, `build` and `codeql`
15
- are housekeeping and live on the Actions page -- six badges in a row stop being
16
- read at all.
17
-
18
- A badge shows; it does not require. What keeps a red check from being merged is
19
- a branch rule, not a picture -- see `doc/keepup.md`.
20
-
21
13
  An admin framework over FastAPI. You give it settings; it gives you an
22
14
  application with a panel, a plugin runtime, users, a database layer, an audit,
23
15
  metrics and coordination between replicas already wired.
@@ -28,14 +20,40 @@ from keepup import KeepupSettings, create_app
28
20
  app = create_app(KeepupSettings(title="Your product", project_name="yours"))
29
21
  ```
30
22
 
31
- That is a running application with a working panel at `/selfcare`: the shell,
32
- the themes and eight administrative sections ship inside the package, so there
33
- is nothing to copy into your tree to see them.
23
+ That is a running application with a working panel at `/selfcare` once the
24
+ capabilities are installed: the shell, the themes and eight administrative
25
+ sections ship with them, so there is nothing to copy into your tree to see them.
34
26
 
35
27
  Installed as `keepup-admin`; imported as `keepup`. The name `keepup` on PyPI
36
28
  belongs to an unrelated project from 2015 that installs a script and no module,
37
29
  so the import name is free.
38
30
 
31
+ ## Install
32
+
33
+ Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
34
+ development.
35
+
36
+ ```bash
37
+ pip install "keepup-admin[panel,postgres]"
38
+ ```
39
+
40
+ That is the base plus the capabilities the panel profile enables and the
41
+ PostgreSQL driver. The base alone is the constructor:
42
+
43
+ ```bash
44
+ pip install keepup-admin
45
+ ```
46
+
47
+ — the kernel, the catalogue, the service registry, the lifecycle and the
48
+ transport seam, carrying no capability of its own. Each capability is an extra:
49
+ `db`, `auth`, `users`, `ui`, `audit`, `metrics`, `tasks`, `modules`, `cluster`,
50
+ `log_shipping`, `http`, `integration_log`, and one driver, `postgres` or
51
+ `sqlite` — one, because two drivers of one required service stop the start on
52
+ purpose.
53
+
54
+ `INSTALL.md` has the long form: every extra and what it brings, installing from
55
+ the repository, the build and the release.
56
+
39
57
  ## What it gives you
40
58
 
41
59
  | | |
@@ -71,17 +89,33 @@ with an underscore, whatever module it sits in.
71
89
  repository: a name taken out of the framework and not declared public fails the
72
90
  run, and the failure says what to do about it.
73
91
 
74
- ## Requirements
92
+ ## Build
75
93
 
76
- Python 3.11 or newer. PostgreSQL in production; SQLite works and is meant for
77
- development. `pip install keepup-admin[postgres]` adds the driver the bus
78
- between replicas needs.
94
+ A release is one distribution per capability, and `build.yml` checks on every
95
+ change that they are publishable rather than discovering it at a tag:
96
+
97
+ ```bash
98
+ python -m pip install --upgrade build twine
99
+
100
+ python -m build # the base, keepup-admin
101
+ for package in packages/*; do # each capability
102
+ python -m build --outdir dist "$package"
103
+ done
104
+
105
+ python -m twine check --strict dist/*
106
+ ```
107
+
108
+ The same job then installs the built wheels into an empty virtual environment
109
+ and imports the framework there: a version on PyPI cannot be replaced, and a
110
+ wheel that installs and does not import is the one failure a metadata check
111
+ cannot see. The tag is the release's number and the job refuses one the metadata
112
+ disagrees with; see `.github/workflows/release.yml` and `INSTALL.md`.
79
113
 
80
114
  ## Tests
81
115
 
82
116
  ```bash
83
117
  pip install -e ".[test]" -e packages/keepup-*
84
- pytest tests/
118
+ python -m pytest tests/ -q --cov --cov-config=pyproject.toml
85
119
  ```
86
120
 
87
121
  **Install first, then test.** Pointing pytest at the checkout does not work on
@@ -95,12 +129,15 @@ from the index.
95
129
  The suite runs against SQLite with no network, needs no application beside the
96
130
  package, and holds a coverage floor declared in `pyproject.toml`. Checks that
97
131
  genuinely need a consumer of the framework find one by trait and skip with a
98
- reason when there is none, so a skip here always says what is missing.
99
-
100
- Every one of these runs on push and on a pull request; see `.github/workflows/`.
101
- `security.yml` also runs weekly, because that check goes red without anybody
102
- touching the repository — an advisory gets published against a version that was
103
- fine yesterday.
132
+ reason when there is none, so a skip here always says what is missing. A test is
133
+ named `*_tests.py` and run by path — `python -m pytest tests/runtime_tests.py -v`.
134
+
135
+ Every one of these runs on push and on a pull request, on Python 3.11, 3.12 and
136
+ 3.13; see `.github/workflows/`. `security.yml` also runs weekly, because that
137
+ check goes red without anybody touching the repository — an advisory gets
138
+ published against a version that was fine yesterday. `INSTALL.md` carries the
139
+ heavier checks: the wheel installed into a throwaway environment, and the
140
+ security audit.
104
141
 
105
142
  ## Licence
106
143
 
@@ -1,13 +1,13 @@
1
1
  """KeepUP — a framework over FastAPI for applications built like this one.
2
2
 
3
3
  An application supplies a :class:`~keepup.settings.KeepupSettings` and gets an
4
- application back from :func:`~keepup.factory.create_app`. Everything the
4
+ application back from :func:`~keepup_http.factory.create_app`. Everything the
5
5
  framework cannot know -- the product's name, the collector its logs go to,
6
6
  which fields of a request are secret, what a password must look like, which
7
7
  tables belong to the product -- travels in those settings, never as a default
8
8
  in here. See ``doc/keepup.md``.
9
9
 
10
- Imported lazily: ``keepup.factory`` pulls in the database layer and the
10
+ Imported lazily: ``keepup_http.factory`` pulls in the database layer and the
11
11
  authentication provider, and importing the package to reach one constant
12
12
  should not do that.
13
13
  """
@@ -26,13 +26,25 @@ except Exception:
26
26
  # itself, until the applications switch to installing by version.
27
27
  __version__ = "0.0.0+source"
28
28
 
29
- # Names that moved into a distribution of their own keep working for one
30
- # release, and say where they went (keepup-114, keepup-124).
31
- from keepup import compat as _compat
29
+ __all__ = ["KeepupSettings", "StaticMount", "create_app", "__version__"]
32
30
 
33
- _compat.install()
34
31
 
35
- __all__ = ["KeepupSettings", "StaticMount", "create_app", "__version__"]
32
+ def _create_app():
33
+ """The application, built by the HTTP transport that owns it (keepup-121).
34
+
35
+ `create_app` stays the public name and the base keeps it: the assembly --
36
+ FastAPI, the routes, the middleware, the panel shell -- is
37
+ `keepup-http`'s, because a deployment that serves something other than HTTP
38
+ must not install a web framework to build its runtime.
39
+ """
40
+ try:
41
+ from keepup_http.factory import create_app
42
+ except ImportError as error: # pragma: no cover - the message is the point
43
+ raise ImportError(
44
+ "create_app needs the HTTP transport: install keepup-http "
45
+ "(pip install 'keepup-admin[http]')"
46
+ ) from error
47
+ return create_app
36
48
 
37
49
 
38
50
  def __getattr__(name):
@@ -41,7 +53,5 @@ def __getattr__(name):
41
53
 
42
54
  return getattr(settings, name)
43
55
  if name == "create_app":
44
- from keepup.factory import create_app
45
-
46
- return create_app
56
+ return _create_app()
47
57
  raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -14,14 +14,15 @@ The routes of the event log and the section that shows it travel with the panel
14
14
  names.
15
15
  """
16
16
 
17
+ import asyncio
17
18
  import logging
18
19
  from typing import Any, Dict, List
19
20
 
20
21
  from keepup.kernel.datasource import SERVICE_DATASOURCE
21
22
  from keepup.kernel.descriptor import KIND_OPTIONAL, PluginDescriptor
22
23
  from keepup.kernel.observability import SERVICE_AUDIT, SERVICE_EVENTS, Recording
23
- from keepup.audit import INCOMING_REQUESTS
24
- from keepup.events import APP_EVENTS
24
+ from keepup_audit.tables import INCOMING_REQUESTS
25
+ from keepup_audit.events import APP_EVENTS
25
26
  from keepup.plugins.base import BasePlugin
26
27
 
27
28
  logger = logging.getLogger(__name__)
@@ -32,13 +33,13 @@ __all__ = ["AuditPlugin", "AuditRecording"]
32
33
  class AuditRecording(Recording):
33
34
  """The framework's own recording, behind the kernel's two names.
34
35
 
35
- It delegates to the modules that already do the work (``keepup.audit``,
36
- ``keepup.events``) so that nothing changes for a deployment today; those
36
+ It delegates to the modules that already do the work (``keepup_audit.audit``,
37
+ ``keepup_audit.events``) so that nothing changes for a deployment today; those
37
38
  modules travel into this capability's distribution in keepup-124.
38
39
  """
39
40
 
40
41
  def __init__(self, datasource: Any = None):
41
- from keepup.audit import IncomingRequestLogger, log_api_request
42
+ from keepup_audit.audit import IncomingRequestLogger, log_api_request
42
43
 
43
44
  super().__init__(start=log_api_request, end=IncomingRequestLogger.end_request,
44
45
  name="keepup audit")
@@ -54,7 +55,7 @@ class AuditPlugin(BasePlugin):
54
55
  descriptor = PluginDescriptor(
55
56
  id="audit",
56
57
  name="Event audit",
57
- version="0.4.0",
58
+ version="0.5.0",
58
59
  distribution="keepup-audit",
59
60
  kind=KIND_OPTIONAL,
60
61
  priority=60,
@@ -84,6 +85,44 @@ class AuditPlugin(BasePlugin):
84
85
  self.recording = AuditRecording(self.services.require(SERVICE_DATASOURCE))
85
86
  return True
86
87
 
88
+ async def post_construct(self):
89
+ """Start this capability's loops: the buffer, the audit sweep, the events'.
90
+
91
+ They were `asyncio.create_task` calls in the kernel's lifespan, so a
92
+ deployment that never installed the audit still flushed and swept
93
+ (keepup-109).
94
+ """
95
+ from keepup_audit.audit import audit_retention_background, background_buffer_flusher
96
+ from keepup_audit.events import events_retention_background
97
+
98
+ self._tasks = [
99
+ asyncio.create_task(background_buffer_flusher()),
100
+ asyncio.create_task(audit_retention_background()),
101
+ asyncio.create_task(events_retention_background()),
102
+ ]
103
+
104
+ async def cleanup(self):
105
+ """Stop them, and ship what the buffer still holds.
106
+
107
+ The flush used to be the kernel's, after its own cancellations; the
108
+ owner of the buffer is the one that empties it (keepup-109).
109
+ """
110
+ tasks, self._tasks = getattr(self, "_tasks", []), []
111
+ for task in tasks:
112
+ task.cancel()
113
+ for task in tasks:
114
+ try:
115
+ await task
116
+ except asyncio.CancelledError:
117
+ pass
118
+ from keepup_audit import audit as recording
119
+
120
+ try:
121
+ flushed = await recording.IncomingRequestLogger.flush_buffer(include_in_flight=True)
122
+ logger.info("Flushed %s remaining incoming-request rows", flushed)
123
+ except Exception as error: # noqa: BLE001 - shutdown must not raise
124
+ logger.error("Could not flush the remaining incoming-request rows: %s", error)
125
+
87
126
  def get_declared_tables(self):
88
127
  """The two tables this capability owns, declared once, until keepup-124."""
89
128
  return [INCOMING_REQUESTS, APP_EVENTS]
@@ -94,7 +133,7 @@ class AuditPlugin(BasePlugin):
94
133
 
95
134
  async def emit(self, event_type: str, payload: Dict[str, Any] = None) -> None:
96
135
  """Write one event through the module that still owns the table."""
97
- from keepup.events import emit_event
136
+ from keepup_audit.events import emit_event
98
137
 
99
138
  await emit_event(event_type, payload or {})
100
139
 
@@ -12,6 +12,7 @@ routes, the sockets and the CSRF middleware it contributes. What is here is the
12
12
  claim: two services, two tables, and an identity the runtime adopts.
13
13
  """
14
14
 
15
+ import asyncio
15
16
  import logging
16
17
  from typing import Any, Dict, List
17
18
 
@@ -34,8 +35,8 @@ def build_identity(name: str = "keepup-auth") -> Identity:
34
35
  Returns:
35
36
  The identity: how a caller is found, and what decides a right.
36
37
  """
37
- from keepup.auth.dependencies import get_panel_user
38
- from keepup.auth.identity import access
38
+ from keepup_auth.dependencies import get_panel_user
39
+ from keepup_auth.identity import access
39
40
 
40
41
  return Identity(subject_dependency=get_panel_user, checker=access.check, name=name)
41
42
 
@@ -46,7 +47,7 @@ class AuthPlugin(BasePlugin):
46
47
  descriptor = PluginDescriptor(
47
48
  id="auth",
48
49
  name="Sign-in and sessions",
49
- version="0.4.0",
50
+ version="0.5.0",
50
51
  distribution="keepup-auth",
51
52
  kind=KIND_OPTIONAL,
52
53
  priority=30,
@@ -75,10 +76,41 @@ class AuthPlugin(BasePlugin):
75
76
  self.identity = build_identity()
76
77
  return True
77
78
 
79
+ async def post_construct(self):
80
+ """Start the sweep that closes a socket whose session was revoked, and
81
+ give the accounts that predate the role set the role they were created
82
+ with.
83
+
84
+ Both are the capability's: the kernel's task became the sign-in's when
85
+ the loops moved (keepup-65, keepup-109), and the one-time read of the
86
+ legacy ``users.role`` column is nobody else's business (keepup-157).
87
+ """
88
+ from keepup_auth import seed_accounts, socket_sessions, user_roles
89
+
90
+ try:
91
+ # The first accounts and the legacy roles: one place creates them,
92
+ # and it is the capability that signs people in (keepup-158).
93
+ await asyncio.to_thread(seed_accounts.create_first_accounts)
94
+ await asyncio.to_thread(user_roles.backfill_from_legacy_column)
95
+ except Exception as error: # noqa: BLE001 - a start that cannot seed still serves
96
+ logger.warning("Could not create the first accounts: %s", error)
97
+ self._socket_sweep = asyncio.create_task(socket_sessions.run_forever())
98
+
99
+ async def cleanup(self):
100
+ """Stop the sweep with the application that started it."""
101
+ task, self._socket_sweep = getattr(self, "_socket_sweep", None), None
102
+ if task is None:
103
+ return
104
+ task.cancel()
105
+ try:
106
+ await task
107
+ except asyncio.CancelledError:
108
+ pass
109
+
78
110
  def get_declared_tables(self) -> List[Any]:
79
111
  """The two tables this capability owns, declared once, until keepup-124."""
80
- from keepup.auth.login_throttle import LOGIN_ATTEMPTS
81
- from keepup.auth.panel_session import AUTH_SESSION
112
+ from keepup_auth.login_throttle import LOGIN_ATTEMPTS
113
+ from keepup_auth.panel_session import AUTH_SESSION
82
114
 
83
115
  return [AUTH_SESSION, LOGIN_ATTEMPTS]
84
116
 
@@ -4,7 +4,7 @@ Task keepup-124, first slice. `keepup/kernel/datasource.py` owns the shapes and
4
4
  the two names (keepup-106), the drivers answer with `spec()` (keepup-107,
5
5
  keepup-108) -- and nobody published `datasource`, so no capability could reach
6
6
  storage through it. This is the plugin that does: it requires a driver, publishes
7
- the service built on the framework's current manager (`keepup.db`), and creates
7
+ the service built on the framework's current manager (`keepup_db`), and creates
8
8
  nothing itself except what capabilities declare.
9
9
 
10
10
  It answers the abstraction with the manager, so the dialect, the pool and the
@@ -17,7 +17,6 @@ deployment that talks to a database, and every capability asks it by name.
17
17
  import logging
18
18
  from typing import Any, Dict, List, Mapping, Optional
19
19
 
20
- from keepup.db import DatabaseManagerV2, db_config
21
20
  from keepup.kernel.datasource import (
22
21
  SERVICE_DATASOURCE,
23
22
  SERVICE_DATASOURCE_DRIVER,
@@ -48,6 +47,8 @@ class DatabaseSource:
48
47
  """The dialect the driver named, or the configured one."""
49
48
  if self.spec is not None and self.spec.dialect:
50
49
  return self.spec.dialect
50
+ from keepup_db import db_config
51
+
51
52
  return "postgresql" if db_config.is_postgres() else "sqlite"
52
53
 
53
54
  async def execute(self, statement: str, params: Optional[Mapping[str, Any]] = None) -> Any:
@@ -74,7 +75,7 @@ class DatabaseSource:
74
75
  The declarations come from the capabilities that own them, which is why
75
76
  this takes them as arguments rather than knowing any itself.
76
77
  """
77
- from keepup import tables as table_language
78
+ from keepup_db import tables as table_language
78
79
 
79
80
  flat = []
80
81
  for table in tables:
@@ -86,7 +87,7 @@ class DatabaseSource:
86
87
 
87
88
  def ensure_columns(self, table: Any) -> None:
88
89
  """Add the columns an existing table lacks."""
89
- from keepup import tables as table_language
90
+ from keepup_db import tables as table_language
90
91
 
91
92
  table_language.ensure_columns(table)
92
93
 
@@ -114,7 +115,7 @@ class DbPlugin(BasePlugin):
114
115
  descriptor = PluginDescriptor(
115
116
  id="db",
116
117
  name="Database abstraction",
117
- version="0.4.0",
118
+ version="0.5.0",
118
119
  distribution="keepup-db",
119
120
  kind=KIND_REQUIRED,
120
121
  priority=10,
@@ -136,6 +137,8 @@ class DbPlugin(BasePlugin):
136
137
  if services.has(SERVICE_DATASOURCE_DRIVER):
137
138
  driver = services.require(SERVICE_DATASOURCE_DRIVER)
138
139
  spec = driver.spec() if callable(getattr(driver, "spec", None)) else None
140
+ from keepup_db import DatabaseManagerV2
141
+
139
142
  self.source = DatabaseSource(DatabaseManagerV2, spec)
140
143
  services.provide(SERVICE_DATASOURCE, self.source, version=1, plugin_id="db")
141
144
  logger.info("The data source is %s", self.source.dialect)
@@ -5,12 +5,11 @@ creates nothing itself: the pool, the dialect registry and the creation of
5
5
  declared tables are the abstraction's business
6
6
  (``doc/capabilities-out-of-the-kernel.md``, card 3).
7
7
 
8
- The knowledge is the framework's current configuration (``keepup.db.db_config``)
8
+ The knowledge is the framework's current configuration (``keepup_db.db_config``)
9
9
  until the driver travels in a distribution of its own and keeps its own
10
10
  (keepup-124).
11
11
  """
12
12
 
13
- from keepup.db import db_config
14
13
  from keepup.kernel.datasource import SERVICE_DATASOURCE_DRIVER, DriverSpec
15
14
  from keepup.kernel.descriptor import KIND_REQUIRED, PluginDescriptor
16
15
  from keepup.plugins.base import BasePlugin
@@ -22,7 +21,7 @@ class PostgresPlugin(BasePlugin):
22
21
  descriptor = PluginDescriptor(
23
22
  id="postgres",
24
23
  name="PostgreSQL driver",
25
- version="0.4.0",
24
+ version="0.5.0",
26
25
  distribution="keepup-postgres",
27
26
  kind=KIND_REQUIRED,
28
27
  priority=6,
@@ -42,6 +41,13 @@ class PostgresPlugin(BasePlugin):
42
41
  services: the runtime's registry.
43
42
  """
44
43
  services.provide(SERVICE_DATASOURCE_DRIVER, self, version=1, plugin_id="postgres")
44
+ # Delivery between replicas is this driver's: LISTEN/NOTIFY needs
45
+ # asyncpg, and asyncpg comes with this distribution (keepup-117).
46
+ from keepup_postgres.transport import PostgresTransport
47
+ from keepup.notification_bus import SERVICE_NOTIFY_TRANSPORT
48
+
49
+ services.provide(SERVICE_NOTIFY_TRANSPORT, PostgresTransport(), version=1,
50
+ plugin_id="postgres")
45
51
 
46
52
  async def initialize(self):
47
53
  """Nothing to open: the abstraction owns the pool (keepup-106)."""
@@ -55,6 +61,8 @@ class PostgresPlugin(BasePlugin):
55
61
  things a capability may ask about: whether ``RETURNING`` answers the
56
62
  new row, and whether the database carries a message between replicas.
57
63
  """
64
+ from keepup_db import db_config
65
+
58
66
  return DriverSpec(
59
67
  dialect="postgresql",
60
68
  connection_url=db_config.get_connection_string(),