swisstip-builder 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swisstip_builder-0.1.0/LICENSE +202 -0
- swisstip_builder-0.1.0/NOTICE +17 -0
- swisstip_builder-0.1.0/PKG-INFO +81 -0
- swisstip_builder-0.1.0/README.md +44 -0
- swisstip_builder-0.1.0/pyproject.toml +88 -0
- swisstip_builder-0.1.0/setup.cfg +4 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/__init__.py +11 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/app.py +218 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/calls.py +115 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/checks.py +188 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/data.py +408 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/jobs.py +211 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/__init__.py +5 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/documents.py +206 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/operations.py +97 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/packs.py +75 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/release.py +159 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/review.py +356 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/runs.py +163 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/sandbox.py +166 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/sources.py +239 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/screens/workbench.py +479 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/static/console.css +124 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/static/console.js +149 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/static/htmx.min.js +2 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/base.html +40 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/conflict.html +11 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/documents/diff.html +57 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/documents/excerpt.html +2 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/documents/excerpt_body.html +38 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/documents/index.html +115 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/documents/reading.html +111 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/fragment.html +2 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/macros.html +44 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/operations/index.html +131 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/packs/audit.html +28 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/packs/index.html +110 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/refused.html +16 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/release/index.html +131 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/review/index.html +229 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/runs/index.html +123 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/runs/job.html +15 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/runs/preview.html +7 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/runs/relocation.html +113 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/sandbox/checks.html +22 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/sandbox/index.html +144 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/sandbox/result.html +118 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/sources/form.html +83 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/sources/index.html +138 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/workbench/concept.html +90 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/workbench/fact.html +112 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/workbench/index.html +64 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/workbench/pack.html +44 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/views/workbench/topic.html +16 -0
- swisstip_builder-0.1.0/src/swisstip/admin_console/writes.py +202 -0
- swisstip_builder-0.1.0/src/swisstip/build/__init__.py +6 -0
- swisstip_builder-0.1.0/src/swisstip/build/acceptance.py +29 -0
- swisstip_builder-0.1.0/src/swisstip/build/build_cli.py +48 -0
- swisstip_builder-0.1.0/src/swisstip/build/curation.py +111 -0
- swisstip_builder-0.1.0/src/swisstip/build/release_build.py +213 -0
- swisstip_builder-0.1.0/src/swisstip/build/source_terms.py +71 -0
- swisstip_builder-0.1.0/src/swisstip/builder/__init__.py +8 -0
- swisstip_builder-0.1.0/src/swisstip/builder/cli.py +60 -0
- swisstip_builder-0.1.0/src/swisstip/builder/pipeline.py +354 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/__init__.py +6 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/budget.py +141 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/checkpoints.py +201 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/chunks.py +115 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/concepts_cli.py +292 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/extract.py +287 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/legacy.py +173 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/package.py +269 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/package_cli.py +65 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/prompts/concept_extraction_v2.md +31 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/prompts/concept_extraction_v3_extension.md +11 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/prompts/concept_review_v3.md +28 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/prompts.py +52 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/__init__.py +6 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/base.py +340 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/config.py +170 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/deepseek.py +17 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/exchange.py +216 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/groq.py +21 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/huggingface.py +47 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/providers/ollama.py +50 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/results.py +172 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/schemas.py +46 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/sections.py +111 -0
- swisstip_builder-0.1.0/src/swisstip/concepts/validation.py +146 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/__init__.py +10 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/anchors.py +134 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/dataset.py +214 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/extract_cli.py +129 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/html_blocks.py +363 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/legacy.py +77 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/office_text.py +154 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/pdf_text.py +95 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/reading_view.py +75 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/records.py +163 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/run_reader.py +161 -0
- swisstip_builder-0.1.0/src/swisstip/extraction/validate.py +133 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/__init__.py +8 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/acquisition.py +302 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/catalog.py +173 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/crawler.py +782 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/discovery.py +101 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/download_cli.py +152 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/fedlex.py +64 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/gap_report.py +280 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/plugin_downloads.py +139 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/plugins.py +107 -0
- swisstip_builder-0.1.0/src/swisstip/ingestion/review_decisions.py +128 -0
- swisstip_builder-0.1.0/src/swisstip_builder.egg-info/PKG-INFO +81 -0
- swisstip_builder-0.1.0/src/swisstip_builder.egg-info/SOURCES.txt +116 -0
- swisstip_builder-0.1.0/src/swisstip_builder.egg-info/dependency_links.txt +1 -0
- swisstip_builder-0.1.0/src/swisstip_builder.egg-info/entry_points.txt +10 -0
- swisstip_builder-0.1.0/src/swisstip_builder.egg-info/requires.txt +14 -0
- swisstip_builder-0.1.0/src/swisstip_builder.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Swiss TIP - Swisscom Trusted Information Platform
|
|
2
|
+
Copyright 2026 The UBS Hackathon 2026 team: Alexander Bobrovsky and contributors
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
The source catalogues under releases/ contain URLs and planning metadata
|
|
7
|
+
only. Any future release bundle that quotes excerpts of official publications
|
|
8
|
+
of the Swiss Confederation, the cantons or municipalities reproduces those
|
|
9
|
+
texts as cited evidence with their source URLs and access times; they remain
|
|
10
|
+
the property of their publishers and are not relicensed under the Apache
|
|
11
|
+
License. Consult the publishers' terms of use before redistributing them.
|
|
12
|
+
|
|
13
|
+
The admin console vendors HTMX 2.0.7
|
|
14
|
+
(apps/admin-console/src/swisstip/admin_console/static/htmx.min.js), which is
|
|
15
|
+
distributed by the htmx authors under the Zero-Clause BSD licence. It is
|
|
16
|
+
included verbatim so the console needs no network access and no JavaScript
|
|
17
|
+
build step.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swisstip-builder
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Swiss TIP workstation tools: source acquisition, text extraction, release build and the admin console
|
|
5
|
+
Author: Alexander Bobrovsky
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/bobrovsky420/hackathon2026
|
|
8
|
+
Project-URL: Source, https://github.com/bobrovsky420/hackathon2026
|
|
9
|
+
Project-URL: Issues, https://github.com/bobrovsky420/hackathon2026/issues
|
|
10
|
+
Keywords: mcp,grounding,switzerland,crawler,curation
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Framework :: FastAPI
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Requires-Python: >=3.14
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
License-File: NOTICE
|
|
23
|
+
Requires-Dist: fastapi<1,>=0.115
|
|
24
|
+
Requires-Dist: jinja2<4,>=3.1
|
|
25
|
+
Requires-Dist: lxml==6.1.3
|
|
26
|
+
Requires-Dist: pydantic<3,>=2.11
|
|
27
|
+
Requires-Dist: pypdf==6.18.0
|
|
28
|
+
Requires-Dist: pypdfium2==5.13.0
|
|
29
|
+
Requires-Dist: python-multipart<1,>=0.0.20
|
|
30
|
+
Requires-Dist: pyyaml==6.0.3
|
|
31
|
+
Requires-Dist: swisstip-core==0.1.0
|
|
32
|
+
Requires-Dist: uvicorn<1,>=0.30
|
|
33
|
+
Provides-Extra: office
|
|
34
|
+
Requires-Dist: olefile==0.47; extra == "office"
|
|
35
|
+
Requires-Dist: striprtf==0.0.33; extra == "office"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# swisstip-builder
|
|
39
|
+
|
|
40
|
+
**Last update:** 15 September 2026
|
|
41
|
+
|
|
42
|
+
The workstation tools of Swiss TIP, the grounding MCP server for Swiss public
|
|
43
|
+
information. They turn a source catalogue into a validated, reviewed knowledge
|
|
44
|
+
release that `swisstip-mcp` serves.
|
|
45
|
+
|
|
46
|
+
| Command | Does |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `swisstip-admin` | Local web console: sources, saved documents, reading view, review queue, tool sandbox, release |
|
|
49
|
+
| `swisstip-build` | The whole pipeline of a pack: acquire, gaps, extract, validate, build, accept, ready |
|
|
50
|
+
| `swisstip-download`, `swisstip-gaps` | Bounded source acquisition (robots.txt, rate limits, request budget) and the gap report |
|
|
51
|
+
| `swisstip-extract`, `swisstip-extract-validate` | Saved pages and PDFs to labelled text blocks with offsets and hashes |
|
|
52
|
+
| `swisstip-build-release` | Curation file plus text dataset to `release.json` |
|
|
53
|
+
| `swisstip-concepts`, `swisstip-concepts-package` | Model-proposed concept candidates with a separate review |
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
Python 3.14 or newer. Install it as an isolated tool; the extraction
|
|
58
|
+
libraries are pinned exactly, because the text hashes of a release depend on
|
|
59
|
+
them:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uv tool install swisstip-builder # or: pipx install swisstip-builder
|
|
63
|
+
uv tool install "swisstip-builder[office]" # adds legacy Office and RTF extraction
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Use
|
|
67
|
+
|
|
68
|
+
The tools work on a directory that holds `releases/<pack>/` (a source
|
|
69
|
+
catalogue, a curation file, saved pages and a text dataset), for example a
|
|
70
|
+
clone of the repository or an unpacked pack workspace. Pass it as `--root`:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
swisstip-admin --root . # console on http://127.0.0.1:8765
|
|
74
|
+
swisstip-build mvp-zurich --root . --from build --until accept
|
|
75
|
+
swisstip-build mvp-zurich --root . --from accept --until ready --attested-by "A. Person"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The resulting `releases/<pack>/release.json` and `readiness.json` are what
|
|
79
|
+
`swisstip-mcp --release` serves.
|
|
80
|
+
|
|
81
|
+
Licence: Apache-2.0.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# swisstip-builder
|
|
2
|
+
|
|
3
|
+
**Last update:** 15 September 2026
|
|
4
|
+
|
|
5
|
+
The workstation tools of Swiss TIP, the grounding MCP server for Swiss public
|
|
6
|
+
information. They turn a source catalogue into a validated, reviewed knowledge
|
|
7
|
+
release that `swisstip-mcp` serves.
|
|
8
|
+
|
|
9
|
+
| Command | Does |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `swisstip-admin` | Local web console: sources, saved documents, reading view, review queue, tool sandbox, release |
|
|
12
|
+
| `swisstip-build` | The whole pipeline of a pack: acquire, gaps, extract, validate, build, accept, ready |
|
|
13
|
+
| `swisstip-download`, `swisstip-gaps` | Bounded source acquisition (robots.txt, rate limits, request budget) and the gap report |
|
|
14
|
+
| `swisstip-extract`, `swisstip-extract-validate` | Saved pages and PDFs to labelled text blocks with offsets and hashes |
|
|
15
|
+
| `swisstip-build-release` | Curation file plus text dataset to `release.json` |
|
|
16
|
+
| `swisstip-concepts`, `swisstip-concepts-package` | Model-proposed concept candidates with a separate review |
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
Python 3.14 or newer. Install it as an isolated tool; the extraction
|
|
21
|
+
libraries are pinned exactly, because the text hashes of a release depend on
|
|
22
|
+
them:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
uv tool install swisstip-builder # or: pipx install swisstip-builder
|
|
26
|
+
uv tool install "swisstip-builder[office]" # adds legacy Office and RTF extraction
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Use
|
|
30
|
+
|
|
31
|
+
The tools work on a directory that holds `releases/<pack>/` (a source
|
|
32
|
+
catalogue, a curation file, saved pages and a text dataset), for example a
|
|
33
|
+
clone of the repository or an unpacked pack workspace. Pass it as `--root`:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
swisstip-admin --root . # console on http://127.0.0.1:8765
|
|
37
|
+
swisstip-build mvp-zurich --root . --from build --until accept
|
|
38
|
+
swisstip-build mvp-zurich --root . --from accept --until ready --attested-by "A. Person"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The resulting `releases/<pack>/release.json` and `readiness.json` are what
|
|
42
|
+
`swisstip-mcp --release` serves.
|
|
43
|
+
|
|
44
|
+
Licence: Apache-2.0.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Generated by scripts/pypi/build_distributions.py; do not edit.
|
|
2
|
+
[build-system]
|
|
3
|
+
requires = [
|
|
4
|
+
"setuptools>=77",
|
|
5
|
+
]
|
|
6
|
+
build-backend = "setuptools.build_meta"
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "swisstip-builder"
|
|
10
|
+
version = "0.1.0"
|
|
11
|
+
description = "Swiss TIP workstation tools: source acquisition, text extraction, release build and the admin console"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.14"
|
|
14
|
+
license = "Apache-2.0"
|
|
15
|
+
license-files = [
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"NOTICE",
|
|
18
|
+
]
|
|
19
|
+
authors = [
|
|
20
|
+
{ name = "Alexander Bobrovsky" },
|
|
21
|
+
]
|
|
22
|
+
keywords = [
|
|
23
|
+
"mcp",
|
|
24
|
+
"grounding",
|
|
25
|
+
"switzerland",
|
|
26
|
+
"crawler",
|
|
27
|
+
"curation",
|
|
28
|
+
]
|
|
29
|
+
classifiers = [
|
|
30
|
+
"Development Status :: 3 - Alpha",
|
|
31
|
+
"Environment :: Web Environment",
|
|
32
|
+
"Framework :: FastAPI",
|
|
33
|
+
"Intended Audience :: Developers",
|
|
34
|
+
"Operating System :: OS Independent",
|
|
35
|
+
"Programming Language :: Python :: 3",
|
|
36
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
37
|
+
"Programming Language :: Python :: 3.14",
|
|
38
|
+
]
|
|
39
|
+
dependencies = [
|
|
40
|
+
"fastapi<1,>=0.115",
|
|
41
|
+
"jinja2<4,>=3.1",
|
|
42
|
+
"lxml==6.1.3",
|
|
43
|
+
"pydantic<3,>=2.11",
|
|
44
|
+
"pypdf==6.18.0",
|
|
45
|
+
"pypdfium2==5.13.0",
|
|
46
|
+
"python-multipart<1,>=0.0.20",
|
|
47
|
+
"pyyaml==6.0.3",
|
|
48
|
+
"swisstip-core==0.1.0",
|
|
49
|
+
"uvicorn<1,>=0.30",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.urls]
|
|
53
|
+
Homepage = "https://github.com/bobrovsky420/hackathon2026"
|
|
54
|
+
Source = "https://github.com/bobrovsky420/hackathon2026"
|
|
55
|
+
Issues = "https://github.com/bobrovsky420/hackathon2026/issues"
|
|
56
|
+
|
|
57
|
+
[project.optional-dependencies]
|
|
58
|
+
office = [
|
|
59
|
+
"olefile==0.47",
|
|
60
|
+
"striprtf==0.0.33",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[project.scripts]
|
|
64
|
+
swisstip-admin = "swisstip.admin_console.app:main"
|
|
65
|
+
swisstip-build = "swisstip.builder.cli:main"
|
|
66
|
+
swisstip-build-release = "swisstip.build.build_cli:main"
|
|
67
|
+
swisstip-concepts = "swisstip.concepts.concepts_cli:main"
|
|
68
|
+
swisstip-concepts-package = "swisstip.concepts.package_cli:main"
|
|
69
|
+
swisstip-download = "swisstip.ingestion.download_cli:main"
|
|
70
|
+
swisstip-extract = "swisstip.extraction.extract_cli:main"
|
|
71
|
+
swisstip-extract-validate = "swisstip.extraction.validate:main"
|
|
72
|
+
swisstip-gaps = "swisstip.ingestion.gap_report:main"
|
|
73
|
+
|
|
74
|
+
[tool.setuptools.packages.find]
|
|
75
|
+
where = [
|
|
76
|
+
"src",
|
|
77
|
+
]
|
|
78
|
+
namespaces = true
|
|
79
|
+
|
|
80
|
+
[tool.setuptools.package-data]
|
|
81
|
+
"swisstip.concepts" = [
|
|
82
|
+
"prompts/*.md",
|
|
83
|
+
]
|
|
84
|
+
"swisstip.admin_console" = [
|
|
85
|
+
"views/*.html",
|
|
86
|
+
"views/**/*.html",
|
|
87
|
+
"static/*",
|
|
88
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Swiss TIP admin console: a local web interface over the files of a pack.
|
|
2
|
+
|
|
3
|
+
Build-side only; the MCP server never imports this package. Every screen
|
|
4
|
+
reads a file the pipeline already writes, and the console writes only the
|
|
5
|
+
curation file, the source catalogue and its own checks file. See
|
|
6
|
+
docs/architecture/admin-console.md.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
CONSOLE_NAME = "swisstip-admin"
|
|
10
|
+
CONSOLE_VERSION = "0.1.0"
|
|
11
|
+
CHECKS_SCHEMA_VERSION = "swiss-tip-checks/v1"
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"""The console application: one FastAPI app over the files of the packs.
|
|
2
|
+
|
|
3
|
+
swisstip-admin edit mode on 127.0.0.1:8765
|
|
4
|
+
swisstip-admin --actor "Anna Meier" name the person who writes
|
|
5
|
+
swisstip-admin --read-only evaluator view: no write and no job route
|
|
6
|
+
swisstip-admin --host 0.0.0.0 --auth-file .local/console-users.txt
|
|
7
|
+
|
|
8
|
+
Routes are grouped by screen under `screens/`, one module and one template
|
|
9
|
+
folder per screen of section 4 of docs/architecture/admin-console.md. In
|
|
10
|
+
read-only mode the write and job routers are not registered at all, so a
|
|
11
|
+
missing button is not the only thing that stops a write.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import base64
|
|
16
|
+
import hashlib
|
|
17
|
+
import json
|
|
18
|
+
import secrets
|
|
19
|
+
import sys
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import Iterable
|
|
22
|
+
|
|
23
|
+
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
|
24
|
+
from fastapi.responses import HTMLResponse, JSONResponse
|
|
25
|
+
from fastapi.staticfiles import StaticFiles
|
|
26
|
+
from fastapi.templating import Jinja2Templates
|
|
27
|
+
|
|
28
|
+
from . import CONSOLE_NAME, CONSOLE_VERSION
|
|
29
|
+
from .data import Console, PackData
|
|
30
|
+
from .jobs import JobRunner
|
|
31
|
+
from .writes import WriteConflict, WriteRefused
|
|
32
|
+
|
|
33
|
+
ROOT = Path(__file__).resolve().parents[5]
|
|
34
|
+
PACKAGE = Path(__file__).resolve().parent
|
|
35
|
+
DEFAULT_HOST = "127.0.0.1"
|
|
36
|
+
DEFAULT_PORT = 8765
|
|
37
|
+
|
|
38
|
+
templates = Jinja2Templates(directory=str(PACKAGE / "views"))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# --- shared template helpers ------------------------------------------------
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def shorten(value, length: int = 12) -> str:
|
|
45
|
+
text = "" if value is None else str(value)
|
|
46
|
+
return text if len(text) <= length else text[:length] + "..."
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def as_json(value) -> str:
|
|
50
|
+
return json.dumps(value, indent=2, ensure_ascii=False, default=str)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def block_number(block_id: str) -> int:
|
|
54
|
+
return int(str(block_id).rsplit(":b", 1)[-1])
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
templates.env.filters["shorten"] = shorten
|
|
58
|
+
templates.env.filters["as_json"] = as_json
|
|
59
|
+
templates.env.filters["block_number"] = block_number
|
|
60
|
+
templates.env.globals["console_version"] = CONSOLE_VERSION
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def render(request: Request, name: str, *, status_code: int = 200, **context) -> HTMLResponse:
|
|
64
|
+
"""Every screen renders through here, so the header is the same everywhere."""
|
|
65
|
+
app = request.app
|
|
66
|
+
pack = context.get("pack")
|
|
67
|
+
values = dict(
|
|
68
|
+
console=app.state.console, read_only=app.state.console.read_only, actor=actor_of(request),
|
|
69
|
+
layout="fragment.html" if request.headers.get("hx-request") else "base.html",
|
|
70
|
+
packs=app.state.console.pack_names(), pack_name=pack.pack if isinstance(pack, PackData) else pack,
|
|
71
|
+
notice=request.query_params.get("notice"), error=request.query_params.get("error"), active=None)
|
|
72
|
+
values.update(context) # a screen may name its own `error` or `notice`
|
|
73
|
+
return templates.TemplateResponse(request, name, values, status_code=status_code)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def actor_of(request: Request) -> str:
|
|
77
|
+
return getattr(request.state, "actor", None) or request.app.state.console.actor
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# --- authentication (hosted mode, section 9) --------------------------------
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def read_users(path: Path) -> dict[str, tuple[str, str]]:
|
|
84
|
+
"""`user:<sha256 of password>:<editor|reader>` per line; the file lives outside Git."""
|
|
85
|
+
users: dict[str, tuple[str, str]] = {}
|
|
86
|
+
for line in Path(path).read_text(encoding="utf-8").splitlines():
|
|
87
|
+
line = line.strip()
|
|
88
|
+
if not line or line.startswith("#"):
|
|
89
|
+
continue
|
|
90
|
+
parts = line.split(":")
|
|
91
|
+
if len(parts) != 3:
|
|
92
|
+
raise ValueError(f"Bad line in {path}: expected user:sha256:role")
|
|
93
|
+
users[parts[0]] = (parts[1].lower(), parts[2].strip().lower())
|
|
94
|
+
return users
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def authenticate(request: Request) -> str:
|
|
98
|
+
"""HTTP basic; returns the user name. No secret is ever rendered."""
|
|
99
|
+
users = request.app.state.users
|
|
100
|
+
if not users:
|
|
101
|
+
return request.app.state.console.actor
|
|
102
|
+
header = request.headers.get("authorization", "")
|
|
103
|
+
unauthorized = HTTPException(status.HTTP_401_UNAUTHORIZED, "Authentication required",
|
|
104
|
+
headers={"WWW-Authenticate": "Basic realm=\"Swiss TIP admin console\""})
|
|
105
|
+
if not header.lower().startswith("basic "):
|
|
106
|
+
raise unauthorized
|
|
107
|
+
try:
|
|
108
|
+
name, _, password = base64.b64decode(header[6:]).decode("utf-8").partition(":")
|
|
109
|
+
except Exception as exc:
|
|
110
|
+
raise unauthorized from exc
|
|
111
|
+
expected = users.get(name)
|
|
112
|
+
if expected is None or not secrets.compare_digest(expected[0], hashlib.sha256(password.encode("utf-8")).hexdigest()):
|
|
113
|
+
raise unauthorized
|
|
114
|
+
request.state.actor = name
|
|
115
|
+
request.state.role = expected[1]
|
|
116
|
+
return name
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def require_editor(request: Request, user: str = Depends(authenticate)) -> str:
|
|
120
|
+
"""Write endpoints are for users listed as editors; in local mode there is one actor."""
|
|
121
|
+
if request.app.state.users and getattr(request.state, "role", "reader") != "editor":
|
|
122
|
+
raise HTTPException(status.HTTP_403_FORBIDDEN, "This user may read but not write")
|
|
123
|
+
return user
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def get_pack(request: Request, pack: str) -> PackData:
|
|
127
|
+
try:
|
|
128
|
+
return request.app.state.console.pack(pack)
|
|
129
|
+
except KeyError as exc:
|
|
130
|
+
raise HTTPException(status.HTTP_404_NOT_FOUND, f"Unknown pack {pack!r}") from exc
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
# --- application ------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def create_app(root: Path = ROOT, *, read_only: bool = False, actor: str = "operator",
|
|
137
|
+
run_dirs: dict[str, Path] | None = None, server_log: Path | None = None,
|
|
138
|
+
auth_file: Path | None = None) -> FastAPI:
|
|
139
|
+
from .screens import documents, operations, packs, release, review, runs, sandbox, sources, workbench
|
|
140
|
+
|
|
141
|
+
console = Console(root, read_only=read_only, actor=actor, run_dirs=run_dirs, server_log=server_log)
|
|
142
|
+
users = read_users(auth_file) if auth_file else {}
|
|
143
|
+
# Hosted: every page needs a user, so the actor on a write is the authenticated one.
|
|
144
|
+
app = FastAPI(title="Swiss TIP admin console", version=CONSOLE_VERSION, docs_url=None, redoc_url=None,
|
|
145
|
+
dependencies=[Depends(authenticate)] if users else [])
|
|
146
|
+
app.state.console = console
|
|
147
|
+
app.state.jobs = JobRunner()
|
|
148
|
+
app.state.users = users
|
|
149
|
+
app.mount("/static", StaticFiles(directory=str(PACKAGE / "static")), name="static")
|
|
150
|
+
for name in console.pack_names():
|
|
151
|
+
app.state.jobs.mark_interrupted(console.pack(name))
|
|
152
|
+
|
|
153
|
+
@app.exception_handler(WriteRefused)
|
|
154
|
+
async def refused(request: Request, exc: WriteRefused):
|
|
155
|
+
if wants_json(request):
|
|
156
|
+
return JSONResponse(status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
|
157
|
+
content=dict(refused=exc.message, issues=exc.issues, fields=exc.fields))
|
|
158
|
+
return render(request, "refused.html", status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
|
159
|
+
message=exc.message, issues=exc.issues, fields=exc.fields,
|
|
160
|
+
back=request.headers.get("referer", "/"))
|
|
161
|
+
|
|
162
|
+
@app.exception_handler(WriteConflict)
|
|
163
|
+
async def conflict(request: Request, exc: WriteConflict):
|
|
164
|
+
return render(request, "conflict.html", status_code=status.HTTP_409_CONFLICT, message=exc.message,
|
|
165
|
+
last_actor=exc.last_actor, current_sha256=exc.current_sha256,
|
|
166
|
+
back=request.headers.get("referer", "/"))
|
|
167
|
+
|
|
168
|
+
@app.get("/healthz")
|
|
169
|
+
def healthz():
|
|
170
|
+
return dict(status="ok", name=CONSOLE_NAME, version=CONSOLE_VERSION, root=str(console.root),
|
|
171
|
+
mode="read-only" if read_only else "edit", packs=console.pack_names())
|
|
172
|
+
|
|
173
|
+
for module in (packs, sources, runs, documents, workbench, review, release, sandbox, operations):
|
|
174
|
+
app.include_router(module.read_router)
|
|
175
|
+
if not read_only and hasattr(module, "write_router"):
|
|
176
|
+
app.include_router(module.write_router)
|
|
177
|
+
return app
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def wants_json(request: Request) -> bool:
|
|
181
|
+
return "application/json" in request.headers.get("accept", "")
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def main(argv: Iterable[str] | None = None) -> int:
|
|
185
|
+
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
186
|
+
parser.add_argument("--root", type=Path, default=ROOT, help="repository root; default: this checkout")
|
|
187
|
+
parser.add_argument("--host", default=DEFAULT_HOST, help=f"bind address; default {DEFAULT_HOST}")
|
|
188
|
+
parser.add_argument("--port", type=int, default=DEFAULT_PORT)
|
|
189
|
+
parser.add_argument("--actor", default="operator", help="name recorded on every write")
|
|
190
|
+
parser.add_argument("--read-only", action="store_true", help="register no write and no job route")
|
|
191
|
+
parser.add_argument("--run-dir", action="append", default=[], metavar="PACK=DIR",
|
|
192
|
+
help="run directory of a pack; default releases/<pack> when it holds a run, else .local/<pack>")
|
|
193
|
+
parser.add_argument("--server-log", type=Path, help="log file of a served release, for the operations screen")
|
|
194
|
+
parser.add_argument("--auth-file", type=Path, help="HTTP basic users: user:sha256:editor|reader per line")
|
|
195
|
+
parser.add_argument("--hash-password", metavar="PASSWORD", help="print the SHA-256 for an --auth-file line and exit")
|
|
196
|
+
args = parser.parse_args(argv)
|
|
197
|
+
if args.hash_password:
|
|
198
|
+
print(hashlib.sha256(args.hash_password.encode("utf-8")).hexdigest())
|
|
199
|
+
return 0
|
|
200
|
+
run_dirs = {}
|
|
201
|
+
for item in args.run_dir:
|
|
202
|
+
name, _, path = item.partition("=")
|
|
203
|
+
if not path:
|
|
204
|
+
parser.error("--run-dir takes PACK=DIR")
|
|
205
|
+
run_dirs[name] = Path(path)
|
|
206
|
+
if args.host != DEFAULT_HOST and not args.auth_file:
|
|
207
|
+
print("warning: binding beyond 127.0.0.1 without --auth-file leaves the console open", file=sys.stderr)
|
|
208
|
+
app = create_app(args.root, read_only=args.read_only, actor=args.actor, run_dirs=run_dirs,
|
|
209
|
+
server_log=args.server_log, auth_file=args.auth_file)
|
|
210
|
+
import uvicorn
|
|
211
|
+
print(f"{CONSOLE_NAME} {CONSOLE_VERSION} on http://{args.host}:{args.port} "
|
|
212
|
+
f"({'read-only' if args.read_only else 'edit'} mode, actor {args.actor!r}, root {args.root})")
|
|
213
|
+
uvicorn.run(app, host=args.host, port=args.port, log_level="info")
|
|
214
|
+
return 0
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
if __name__ == "__main__":
|
|
218
|
+
raise SystemExit(main())
|