bluecore-graph-toolbox 2.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.
- bluecore_graph_toolbox-2.0.0/.gitignore +3 -0
- bluecore_graph_toolbox-2.0.0/LICENSE-2.0.txt +202 -0
- bluecore_graph_toolbox-2.0.0/PKG-INFO +103 -0
- bluecore_graph_toolbox-2.0.0/README.md +83 -0
- bluecore_graph_toolbox-2.0.0/pyproject.toml +53 -0
- bluecore_graph_toolbox-2.0.0/src/bluecore_graph_toolbox/__init__.py +8 -0
- bluecore_graph_toolbox-2.0.0/src/bluecore_graph_toolbox/plugin.py +100 -0
- bluecore_graph_toolbox-2.0.0/src/bluecore_graph_toolbox/static/blue-core-v1.svg +45 -0
- bluecore_graph_toolbox-2.0.0/src/bluecore_graph_toolbox/static/toolbox-dark.svg +5 -0
- bluecore_graph_toolbox-2.0.0/src/bluecore_graph_toolbox/static/toolbox.css +15 -0
- bluecore_graph_toolbox-2.0.0/src/bluecore_graph_toolbox/static/toolbox.svg +5 -0
- bluecore_graph_toolbox-2.0.0/src/bluecore_graph_toolbox/templates/index.html +18 -0
- bluecore_graph_toolbox-2.0.0/tests/conftest.py +70 -0
- bluecore_graph_toolbox-2.0.0/tests/test_entry_point.py +26 -0
- bluecore_graph_toolbox-2.0.0/tests/test_plugin.py +93 -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,103 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bluecore-graph-toolbox
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Airflow Plugin for Blue Core Toolbox
|
|
5
|
+
Project-URL: Homepage, https://github.com/blue-core-lod/graph-toolbox
|
|
6
|
+
Project-URL: Issues, https://github.com/blue-core-lod/graph-toolbox/issues
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE-2.0.txt
|
|
9
|
+
Keywords: airflow,airflow-plugin,bibframe,blue-core,rdf
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Framework :: Apache Airflow
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: ==3.12.*
|
|
16
|
+
Requires-Dist: apache-airflow<4,>=3.2.0
|
|
17
|
+
Requires-Dist: bluecore-airflow-common>=0.1.0
|
|
18
|
+
Requires-Dist: jinja2>=3.1.6
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# Blue Core Graph Toolbox
|
|
22
|
+
Web Application for loading and manipulating [Blue Core](https://bcld.info) RDF.
|
|
23
|
+
|
|
24
|
+
The Toolbox is being rebuilt as an [Airflow 3 plugin](#running-as-an-airflow-plugin)
|
|
25
|
+
that runs inside Blue Core Workflows. Until its screens are moved over, the
|
|
26
|
+
original PyScript site lives alongside it in this repo.
|
|
27
|
+
|
|
28
|
+
Through [Pyscript](https://pyscript.net/), the [rdflib](https://rdflib.readthedocs.io/en/stable/) Python package is used
|
|
29
|
+
for loading RDF through Blue Core.
|
|
30
|
+
|
|
31
|
+
## Existing and Planned Functionality
|
|
32
|
+
- Run SPARQL queries on one or more Blue Core Resources
|
|
33
|
+
- Download RDF in various serializations like Turtle, XML/RDF, and json-ld
|
|
34
|
+
- Chat with Blue Core AI Agents
|
|
35
|
+
- Import and convert MARC to Blue Core BIBFRAME Resources
|
|
36
|
+
- Export Blue Core Constrained Bound Descriptions (CBD) to
|
|
37
|
+
MARC21 records
|
|
38
|
+
|
|
39
|
+
## Running as an Airflow plugin
|
|
40
|
+
|
|
41
|
+
The `bluecore_graph_toolbox` package registers itself with Airflow through the
|
|
42
|
+
`airflow.plugins` entry point, so installing it into the Airflow environment is
|
|
43
|
+
all that's needed; nothing goes in the plugins folder. Shared helpers, the base
|
|
44
|
+
template and styles come from
|
|
45
|
+
[bluecore-airflow-common](https://github.com/blue-core-lod/bluecore-airflow-common).
|
|
46
|
+
|
|
47
|
+
Requires Python 3.12 and Airflow 3.2 or later (tested against 3.3.2).
|
|
48
|
+
|
|
49
|
+
Releases are published to PyPI as
|
|
50
|
+
[bluecore-graph-toolbox](https://pypi.org/p/bluecore-graph-toolbox)
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
uv build
|
|
54
|
+
uv add bluecore-graph-toolbox
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
In [bluecore-workflows](https://github.com/blue-core-lod/bluecore-workflows),
|
|
58
|
+
add the pin to `dependencies` in its `pyproject.toml` and run `uv lock`; the
|
|
59
|
+
Docker image installs it from the lockfile, so no wheel is copied in. When a
|
|
60
|
+
new Toolbox release adds screens or API routes, bump that pin and `uv lock`
|
|
61
|
+
again in a Workflows pull request.
|
|
62
|
+
|
|
63
|
+
Once installed, a Toolbox item appears in the Airflow navigation. The UI
|
|
64
|
+
shows it in an iframe at `/plugin/graph-toolbox`; the app itself is mounted at
|
|
65
|
+
`/graph-toolbox`:
|
|
66
|
+
|
|
67
|
+
| Route | Sign-in | Purpose |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| `GET /graph-toolbox/` | required | Landing page |
|
|
70
|
+
| `GET /graph-toolbox/health` | none | `{"status", "version"}` |
|
|
71
|
+
| `/graph-toolbox/static/…` | none | Toolbox and shared Blue Core assets |
|
|
72
|
+
|
|
73
|
+
Sign-in is Airflow's own: the page uses Airflow's JWT cookie (Keycloak in a
|
|
74
|
+
Blue Core stack), and the Toolbox has no login of its own.
|
|
75
|
+
|
|
76
|
+
All URLs follow [api] base_url, so the same build works with Airflow at the
|
|
77
|
+
root or proxied under a path such as /workflows
|
|
78
|
+
(AIRFLOW__API__BASE_URL=`http://localhost/workflows`), where the routes above
|
|
79
|
+
become `/workflows/graph-toolbox/…`.
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
uv sync
|
|
85
|
+
uv run ruff check src/bluecore_graph_toolbox tests
|
|
86
|
+
uv run pytest
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Releasing
|
|
90
|
+
|
|
91
|
+
Releases go to PyPI from
|
|
92
|
+
[`.github/workflows/python-publish.yml`](.github/workflows/python-publish.yml)
|
|
93
|
+
using [trusted publishing](https://docs.pypi.org/trusted-publishers/), so no
|
|
94
|
+
API token is stored in the repo.
|
|
95
|
+
|
|
96
|
+
1. Bump `version` in `pyproject.toml` (`uv version --bump minor`, say) and
|
|
97
|
+
merge it to `main`.
|
|
98
|
+
2. Create a GitHub release whose tag is `v` plus that version, e.g. `v2.1.0`.
|
|
99
|
+
3. Publishing the release runs the workflow: it checks the tag against
|
|
100
|
+
`pyproject.toml`, runs the tests, builds the wheel and sdist, checks that the
|
|
101
|
+
wheel installs as an Airflow plugin, and uploads both to PyPI. Approve the
|
|
102
|
+
`pypi` environment deployment if it asks.
|
|
103
|
+
4. Bump the pin in bluecore-workflows as described above.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Blue Core Graph Toolbox
|
|
2
|
+
Web Application for loading and manipulating [Blue Core](https://bcld.info) RDF.
|
|
3
|
+
|
|
4
|
+
The Toolbox is being rebuilt as an [Airflow 3 plugin](#running-as-an-airflow-plugin)
|
|
5
|
+
that runs inside Blue Core Workflows. Until its screens are moved over, the
|
|
6
|
+
original PyScript site lives alongside it in this repo.
|
|
7
|
+
|
|
8
|
+
Through [Pyscript](https://pyscript.net/), the [rdflib](https://rdflib.readthedocs.io/en/stable/) Python package is used
|
|
9
|
+
for loading RDF through Blue Core.
|
|
10
|
+
|
|
11
|
+
## Existing and Planned Functionality
|
|
12
|
+
- Run SPARQL queries on one or more Blue Core Resources
|
|
13
|
+
- Download RDF in various serializations like Turtle, XML/RDF, and json-ld
|
|
14
|
+
- Chat with Blue Core AI Agents
|
|
15
|
+
- Import and convert MARC to Blue Core BIBFRAME Resources
|
|
16
|
+
- Export Blue Core Constrained Bound Descriptions (CBD) to
|
|
17
|
+
MARC21 records
|
|
18
|
+
|
|
19
|
+
## Running as an Airflow plugin
|
|
20
|
+
|
|
21
|
+
The `bluecore_graph_toolbox` package registers itself with Airflow through the
|
|
22
|
+
`airflow.plugins` entry point, so installing it into the Airflow environment is
|
|
23
|
+
all that's needed; nothing goes in the plugins folder. Shared helpers, the base
|
|
24
|
+
template and styles come from
|
|
25
|
+
[bluecore-airflow-common](https://github.com/blue-core-lod/bluecore-airflow-common).
|
|
26
|
+
|
|
27
|
+
Requires Python 3.12 and Airflow 3.2 or later (tested against 3.3.2).
|
|
28
|
+
|
|
29
|
+
Releases are published to PyPI as
|
|
30
|
+
[bluecore-graph-toolbox](https://pypi.org/p/bluecore-graph-toolbox)
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
uv build
|
|
34
|
+
uv add bluecore-graph-toolbox
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
In [bluecore-workflows](https://github.com/blue-core-lod/bluecore-workflows),
|
|
38
|
+
add the pin to `dependencies` in its `pyproject.toml` and run `uv lock`; the
|
|
39
|
+
Docker image installs it from the lockfile, so no wheel is copied in. When a
|
|
40
|
+
new Toolbox release adds screens or API routes, bump that pin and `uv lock`
|
|
41
|
+
again in a Workflows pull request.
|
|
42
|
+
|
|
43
|
+
Once installed, a Toolbox item appears in the Airflow navigation. The UI
|
|
44
|
+
shows it in an iframe at `/plugin/graph-toolbox`; the app itself is mounted at
|
|
45
|
+
`/graph-toolbox`:
|
|
46
|
+
|
|
47
|
+
| Route | Sign-in | Purpose |
|
|
48
|
+
|---|---|---|
|
|
49
|
+
| `GET /graph-toolbox/` | required | Landing page |
|
|
50
|
+
| `GET /graph-toolbox/health` | none | `{"status", "version"}` |
|
|
51
|
+
| `/graph-toolbox/static/…` | none | Toolbox and shared Blue Core assets |
|
|
52
|
+
|
|
53
|
+
Sign-in is Airflow's own: the page uses Airflow's JWT cookie (Keycloak in a
|
|
54
|
+
Blue Core stack), and the Toolbox has no login of its own.
|
|
55
|
+
|
|
56
|
+
All URLs follow [api] base_url, so the same build works with Airflow at the
|
|
57
|
+
root or proxied under a path such as /workflows
|
|
58
|
+
(AIRFLOW__API__BASE_URL=`http://localhost/workflows`), where the routes above
|
|
59
|
+
become `/workflows/graph-toolbox/…`.
|
|
60
|
+
|
|
61
|
+
## Development
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
uv sync
|
|
65
|
+
uv run ruff check src/bluecore_graph_toolbox tests
|
|
66
|
+
uv run pytest
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Releasing
|
|
70
|
+
|
|
71
|
+
Releases go to PyPI from
|
|
72
|
+
[`.github/workflows/python-publish.yml`](.github/workflows/python-publish.yml)
|
|
73
|
+
using [trusted publishing](https://docs.pypi.org/trusted-publishers/), so no
|
|
74
|
+
API token is stored in the repo.
|
|
75
|
+
|
|
76
|
+
1. Bump `version` in `pyproject.toml` (`uv version --bump minor`, say) and
|
|
77
|
+
merge it to `main`.
|
|
78
|
+
2. Create a GitHub release whose tag is `v` plus that version, e.g. `v2.1.0`.
|
|
79
|
+
3. Publishing the release runs the workflow: it checks the tag against
|
|
80
|
+
`pyproject.toml`, runs the tests, builds the wheel and sdist, checks that the
|
|
81
|
+
wheel installs as an Airflow plugin, and uploads both to PyPI. Approve the
|
|
82
|
+
`pypi` environment deployment if it asks.
|
|
83
|
+
4. Bump the pin in bluecore-workflows as described above.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "bluecore-graph-toolbox"
|
|
3
|
+
version = "2.0.0"
|
|
4
|
+
description = "Airflow Plugin for Blue Core Toolbox"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = "==3.12.*"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
license-files = ["LICENSE-2.0.txt"]
|
|
9
|
+
keywords = ["airflow", "airflow-plugin", "bibframe", "blue-core", "rdf"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Framework :: Apache Airflow",
|
|
13
|
+
"Operating System :: OS Independent",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
]
|
|
17
|
+
dependencies = [
|
|
18
|
+
"apache-airflow>=3.2.0,<4",
|
|
19
|
+
"bluecore-airflow-common>=0.1.0",
|
|
20
|
+
"jinja2>=3.1.6",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/blue-core-lod/graph-toolbox"
|
|
25
|
+
Issues = "https://github.com/blue-core-lod/graph-toolbox/issues"
|
|
26
|
+
|
|
27
|
+
[project.entry-points."airflow.plugins"]
|
|
28
|
+
bluecore_graph_toolbox = "bluecore_graph_toolbox.plugin:GraphToolboxPlugin"
|
|
29
|
+
|
|
30
|
+
[dependency-groups]
|
|
31
|
+
dev = [
|
|
32
|
+
"apache-airflow==3.3.2",
|
|
33
|
+
"httpx",
|
|
34
|
+
"pytest",
|
|
35
|
+
"ruff",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["hatchling>=1.27"]
|
|
40
|
+
build-backend = "hatchling.build"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.build.targets.wheel]
|
|
43
|
+
packages = ["src/bluecore_graph_toolbox"]
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.sdist]
|
|
46
|
+
include = [
|
|
47
|
+
"src/bluecore_graph_toolbox",
|
|
48
|
+
"tests",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE-2.0.txt",
|
|
51
|
+
]
|
|
52
|
+
[tool.pytest.ini_options]
|
|
53
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""Blue Core Graph Toolbox, served as an Airflow 3 plugin.
|
|
2
|
+
|
|
3
|
+
The plugin registers two things with Airflow:
|
|
4
|
+
|
|
5
|
+
1. A FastAPI application mounted into the Airflow API server at
|
|
6
|
+
``/graph-toolbox``, so its routes share Airflow's authentication.
|
|
7
|
+
2. An external view that adds a "Toolbox" item to the Airflow navigation.
|
|
8
|
+
Because it supplies a ``url_route``, the Airflow UI renders the page in an
|
|
9
|
+
iframe at ``/plugin/graph-toolbox``.
|
|
10
|
+
|
|
11
|
+
Routes, relative to the prefix:
|
|
12
|
+
|
|
13
|
+
- ``GET /``: landing page (signed in)
|
|
14
|
+
- ``GET /health``: ``{"status", "version"}`` (public)
|
|
15
|
+
- ``/static/*`` and ``/static/bluecore/*``: assets (public)
|
|
16
|
+
|
|
17
|
+
Toolbox screens are built out in graph-toolbox #43 and #45-47.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import pathlib
|
|
23
|
+
|
|
24
|
+
import bluecore_airflow_common as common
|
|
25
|
+
from airflow.api_fastapi.core_api.security import GetUserDep
|
|
26
|
+
from airflow.plugins_manager import AirflowPlugin
|
|
27
|
+
from fastapi import APIRouter, Depends, FastAPI, Request
|
|
28
|
+
from fastapi.responses import HTMLResponse
|
|
29
|
+
|
|
30
|
+
from bluecore_graph_toolbox import __version__
|
|
31
|
+
|
|
32
|
+
PLUGIN_NAME = "bluecore_graph_toolbox"
|
|
33
|
+
TITLE = "Blue Core Graph Toolbox"
|
|
34
|
+
|
|
35
|
+
# The Airflow nav truncates long labels, so the nav item has its own short name.
|
|
36
|
+
NAV_LABEL = "Toolbox"
|
|
37
|
+
|
|
38
|
+
# Where the FastAPI app is mounted on the Airflow API server, and the path the
|
|
39
|
+
# Airflow UI uses for the iframe that wraps it. The route must be unique across
|
|
40
|
+
# plugins, or Airflow drops the view.
|
|
41
|
+
URL_PREFIX = "/graph-toolbox"
|
|
42
|
+
URL_ROUTE = "graph-toolbox"
|
|
43
|
+
|
|
44
|
+
PACKAGE_DIR = pathlib.Path(__file__).parent
|
|
45
|
+
STATIC_DIR = PACKAGE_DIR / "static"
|
|
46
|
+
TEMPLATES_DIR = PACKAGE_DIR / "templates"
|
|
47
|
+
|
|
48
|
+
app = FastAPI(title=TITLE, docs_url=None, redoc_url=None, openapi_url=None)
|
|
49
|
+
common.mount_static(app, STATIC_DIR)
|
|
50
|
+
templates = common.templates(TEMPLATES_DIR)
|
|
51
|
+
|
|
52
|
+
# Everything on this router needs a signed-in user, so screens added later are
|
|
53
|
+
# protected without each route having to remember to ask.
|
|
54
|
+
pages = APIRouter(dependencies=[Depends(common.requires_login)])
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@pages.get("/", response_class=HTMLResponse)
|
|
58
|
+
def index(request: Request, user: GetUserDep) -> HTMLResponse:
|
|
59
|
+
"""Render the landing page."""
|
|
60
|
+
return templates.TemplateResponse(
|
|
61
|
+
request=request,
|
|
62
|
+
name="index.html",
|
|
63
|
+
context=common.context(
|
|
64
|
+
URL_PREFIX, title=TITLE, username=user.get_name(), version=__version__
|
|
65
|
+
),
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@app.get("/health")
|
|
70
|
+
def health() -> dict[str, str]:
|
|
71
|
+
"""Report that the plugin is loaded. Public, so it carries nothing sensitive."""
|
|
72
|
+
return {"status": "ok", "version": __version__}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
app.include_router(pages)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class GraphToolboxPlugin(AirflowPlugin):
|
|
79
|
+
name = PLUGIN_NAME
|
|
80
|
+
|
|
81
|
+
fastapi_apps = [ # noqa: RUF012
|
|
82
|
+
{
|
|
83
|
+
"app": app,
|
|
84
|
+
"url_prefix": URL_PREFIX,
|
|
85
|
+
"name": TITLE,
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
external_views = [ # noqa: RUF012
|
|
90
|
+
{
|
|
91
|
+
"name": NAV_LABEL,
|
|
92
|
+
"href": f"{common.airflow_root_path()}{URL_PREFIX}/",
|
|
93
|
+
"url_route": URL_ROUTE,
|
|
94
|
+
"destination": "nav",
|
|
95
|
+
# Rendered by the Airflow UI in an <img>, so the icon cannot pick up
|
|
96
|
+
# the nav's text color and each color mode needs its own file.
|
|
97
|
+
"icon": common.static_url(URL_PREFIX, "toolbox.svg"),
|
|
98
|
+
"icon_dark_mode": common.static_url(URL_PREFIX, "toolbox-dark.svg"),
|
|
99
|
+
}
|
|
100
|
+
]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 589.5 162">
|
|
3
|
+
<defs>
|
|
4
|
+
<style>
|
|
5
|
+
.cls-1, .cls-2 {
|
|
6
|
+
fill: #003caf;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.cls-3, .cls-4 {
|
|
10
|
+
font-family: Roboto-Medium, Roboto;
|
|
11
|
+
font-weight: 500;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.cls-5, .cls-6 {
|
|
15
|
+
font-family: Roboto-Light, Roboto;
|
|
16
|
+
font-weight: 300;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.cls-2 {
|
|
20
|
+
font-size: 100px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.cls-7 {
|
|
24
|
+
fill: #fff;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.cls-6 {
|
|
28
|
+
letter-spacing: -.06em;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cls-4 {
|
|
32
|
+
letter-spacing: 0em;
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
35
|
+
</defs>
|
|
36
|
+
<text class="cls-2" transform="translate(151 115.5)"><tspan class="cls-5" x="0" y="0">Blue</tspan><tspan class="cls-6" x="190.28" y="0"> </tspan><tspan class="cls-3" x="208.6" y="0">Co</tspan><tspan class="cls-4" x="330.82" y="0">r</tspan><tspan class="cls-3" x="365.04" y="0">e</tspan></text>
|
|
37
|
+
<g>
|
|
38
|
+
<circle class="cls-1" cx="51.75" cy="110.25" r="29.25"/>
|
|
39
|
+
<circle class="cls-1" cx="102.94" cy="81" r="29.25"/>
|
|
40
|
+
<circle class="cls-1" cx="51.75" cy="51.75" r="29.25"/>
|
|
41
|
+
<path class="cls-7" d="M51.03,81c-2.39,0-4.57-.32-6.59-.89v29.24c0,4.54,3.27,8.21,7.31,8.21s7.31-3.68,7.31-8.21v-29.25c-2.41.57-5.06.9-8.03.9Z"/>
|
|
42
|
+
<path class="cls-7" d="M77.61,96.27c1.19,2.07,2.01,4.12,2.53,6.15l25.32-14.62c3.93-2.27,5.48-6.94,3.46-10.44-2.02-3.5-6.84-4.49-10.77-2.23l-25.33,14.63c1.7,1.8,3.31,3.93,4.8,6.51Z"/>
|
|
43
|
+
<path class="cls-7" d="M56.33,46.05c-3.93-2.27-8.75-1.27-10.77,2.23s-.47,8.17,3.46,10.44l25.33,14.63c.71-2.37,1.75-4.84,3.23-7.41,1.19-2.07,2.57-3.8,4.06-5.27l-25.32-14.62Z"/>
|
|
44
|
+
</g>
|
|
45
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"
|
|
2
|
+
fill="none" stroke="#e2e8f0" stroke-width="2" stroke-linecap="round"
|
|
3
|
+
stroke-linejoin="round" role="img" aria-label="Wrench">
|
|
4
|
+
<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" />
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Graph Toolbox styles, loaded after the shared bluecore.css. Only rules
|
|
3
|
+
* specific to the Toolbox belong here; anything every plugin page needs goes
|
|
4
|
+
* in bluecore-airflow-common instead.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.toolbox-logo {
|
|
8
|
+
width: 12rem;
|
|
9
|
+
height: auto;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.toolbox-version {
|
|
13
|
+
font-size: 1rem;
|
|
14
|
+
color: var(--bluecore-fg-muted);
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"
|
|
2
|
+
fill="none" stroke="#2d3748" stroke-width="2" stroke-linecap="round"
|
|
3
|
+
stroke-linejoin="round" role="img" aria-label="Wrench">
|
|
4
|
+
<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" />
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{% extends "bluecore/base.html" %}
|
|
2
|
+
|
|
3
|
+
{% block head %}
|
|
4
|
+
<link rel="stylesheet" href="{{ static_url('toolbox.css') }}" />
|
|
5
|
+
{% endblock %}
|
|
6
|
+
|
|
7
|
+
{% block body_class %}centered{% endblock %}
|
|
8
|
+
|
|
9
|
+
{% block content %}
|
|
10
|
+
<img
|
|
11
|
+
class="toolbox-logo"
|
|
12
|
+
src="{{ static_url('blue-core-v1.svg') }}"
|
|
13
|
+
alt="Blue Core"
|
|
14
|
+
/>
|
|
15
|
+
<h1>{{ title }}</h1>
|
|
16
|
+
<p>Signed in as {{ username }}</p>
|
|
17
|
+
<p class="toolbox-version">Version {{ version }}</p>
|
|
18
|
+
{% endblock %}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Shared fixtures for the Graph Toolbox plugin tests."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import importlib
|
|
6
|
+
from collections.abc import Iterator
|
|
7
|
+
from types import ModuleType
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
from airflow.api_fastapi.core_api.security import get_user
|
|
11
|
+
from fastapi.testclient import TestClient
|
|
12
|
+
|
|
13
|
+
from bluecore_graph_toolbox import plugin as plugin_module
|
|
14
|
+
|
|
15
|
+
# [api] base_url values, with the path each one should put in front of every
|
|
16
|
+
# URL: Airflow at the root, proxied under /workflows, and not set at all.
|
|
17
|
+
BASE_URLS = {
|
|
18
|
+
"root": ("http://localhost:8080/", ""),
|
|
19
|
+
"workflows": ("http://localhost/workflows", "/workflows"),
|
|
20
|
+
"unset": ("", ""),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class StubUser:
|
|
25
|
+
"""Stands in for the user Airflow resolves from its JWT cookie."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, name: str) -> None:
|
|
28
|
+
self.name = name
|
|
29
|
+
self.id = name
|
|
30
|
+
|
|
31
|
+
def get_name(self) -> str:
|
|
32
|
+
return self.name
|
|
33
|
+
|
|
34
|
+
def get_id(self) -> str:
|
|
35
|
+
return self.id
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.fixture(params=sorted(BASE_URLS))
|
|
39
|
+
def root_path(request: pytest.FixtureRequest, monkeypatch: pytest.MonkeyPatch) -> str:
|
|
40
|
+
"""Set [api] base_url and return the root path URLs should start with."""
|
|
41
|
+
base_url, path = BASE_URLS[request.param]
|
|
42
|
+
monkeypatch.setenv("AIRFLOW__API__BASE_URL", base_url)
|
|
43
|
+
return path
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.fixture
|
|
47
|
+
def plugin(root_path: str) -> ModuleType:
|
|
48
|
+
"""The plugin module, imported again under the current base_url.
|
|
49
|
+
|
|
50
|
+
The nav link and icon URLs are built when the module is imported, so it
|
|
51
|
+
has to be reloaded for each base path to see the change.
|
|
52
|
+
"""
|
|
53
|
+
return importlib.reload(plugin_module)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@pytest.fixture
|
|
57
|
+
def client(plugin: ModuleType) -> TestClient:
|
|
58
|
+
"""A browser with no Airflow cookie."""
|
|
59
|
+
return TestClient(plugin.app)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@pytest.fixture
|
|
63
|
+
def signed_in_client(plugin: ModuleType) -> Iterator[TestClient]:
|
|
64
|
+
"""A browser whose Airflow cookie resolved to a user.
|
|
65
|
+
|
|
66
|
+
The name contains markup so tests can check the page escapes it.
|
|
67
|
+
"""
|
|
68
|
+
plugin.app.dependency_overrides[get_user] = lambda: StubUser("<b>cataloger</b>")
|
|
69
|
+
yield TestClient(plugin.app)
|
|
70
|
+
plugin.app.dependency_overrides.clear()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Tests that installing the package is enough for Airflow to find the plugin."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import entry_points, version
|
|
6
|
+
|
|
7
|
+
from airflow.plugins_manager import AirflowPlugin
|
|
8
|
+
|
|
9
|
+
from bluecore_graph_toolbox import __version__
|
|
10
|
+
from bluecore_graph_toolbox.plugin import GraphToolboxPlugin
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_plugin_is_registered_as_an_airflow_entry_point() -> None:
|
|
14
|
+
[entry_point] = entry_points(group="airflow.plugins", name="bluecore_graph_toolbox")
|
|
15
|
+
|
|
16
|
+
assert entry_point.value == "bluecore_graph_toolbox.plugin:GraphToolboxPlugin"
|
|
17
|
+
loaded = entry_point.load()
|
|
18
|
+
assert loaded is GraphToolboxPlugin
|
|
19
|
+
assert issubclass(loaded, AirflowPlugin)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_version_comes_from_the_installed_distribution() -> None:
|
|
23
|
+
# __version__ looks itself up by distribution name, so renaming the
|
|
24
|
+
# distribution without updating __init__.py falls back to 0.0.0+unknown.
|
|
25
|
+
assert __version__ != "0.0.0+unknown"
|
|
26
|
+
assert __version__ == version("bluecore-graph-toolbox")
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Tests for the Graph Toolbox Airflow plugin: registration, URLs and access."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from types import ModuleType
|
|
7
|
+
|
|
8
|
+
from airflow.plugins_manager import AirflowPlugin
|
|
9
|
+
from fastapi.testclient import TestClient
|
|
10
|
+
|
|
11
|
+
from bluecore_graph_toolbox import __version__
|
|
12
|
+
|
|
13
|
+
STATIC_FILES = [
|
|
14
|
+
"toolbox.css",
|
|
15
|
+
"toolbox.svg",
|
|
16
|
+
"toolbox-dark.svg",
|
|
17
|
+
"blue-core-v1.svg",
|
|
18
|
+
"bluecore/bluecore.css",
|
|
19
|
+
"bluecore/bluecore.js",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_plugin_registers_app_and_nav_view(plugin: ModuleType) -> None:
|
|
24
|
+
toolbox = plugin.GraphToolboxPlugin
|
|
25
|
+
|
|
26
|
+
assert issubclass(toolbox, AirflowPlugin)
|
|
27
|
+
assert toolbox.name == "bluecore_graph_toolbox"
|
|
28
|
+
assert toolbox.fastapi_apps == [
|
|
29
|
+
{"app": plugin.app, "url_prefix": "/graph-toolbox", "name": plugin.TITLE}
|
|
30
|
+
]
|
|
31
|
+
[view] = toolbox.external_views
|
|
32
|
+
assert view["name"] == "Toolbox"
|
|
33
|
+
assert view["url_route"] == "graph-toolbox"
|
|
34
|
+
assert view["destination"] == "nav"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_nav_urls_follow_base_url(plugin: ModuleType, root_path: str) -> None:
|
|
38
|
+
[view] = plugin.GraphToolboxPlugin.external_views
|
|
39
|
+
|
|
40
|
+
assert view["href"] == f"{root_path}/graph-toolbox/"
|
|
41
|
+
assert view["icon"] == f"{root_path}/graph-toolbox/static/toolbox.svg"
|
|
42
|
+
assert (
|
|
43
|
+
view["icon_dark_mode"] == f"{root_path}/graph-toolbox/static/toolbox-dark.svg"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_landing_page_requires_sign_in(client: TestClient) -> None:
|
|
48
|
+
response = client.get("/")
|
|
49
|
+
|
|
50
|
+
assert response.status_code == 401
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_landing_page_shows_signed_in_user(signed_in_client: TestClient) -> None:
|
|
54
|
+
response = signed_in_client.get("/")
|
|
55
|
+
|
|
56
|
+
assert response.status_code == 200
|
|
57
|
+
assert "Signed in as <b>cataloger</b>" in response.text
|
|
58
|
+
assert "<b>cataloger</b>" not in response.text
|
|
59
|
+
assert f"Version {__version__}" in response.text
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_landing_page_links_are_absolute(
|
|
63
|
+
signed_in_client: TestClient, root_path: str
|
|
64
|
+
) -> None:
|
|
65
|
+
html = signed_in_client.get("/").text
|
|
66
|
+
static = f"{root_path}/graph-toolbox/static"
|
|
67
|
+
|
|
68
|
+
local = [
|
|
69
|
+
url
|
|
70
|
+
for url in re.findall(r'(?:href|src)="([^"]+)"', html)
|
|
71
|
+
if not url.startswith("https://")
|
|
72
|
+
]
|
|
73
|
+
assert sorted(local) == sorted(
|
|
74
|
+
[
|
|
75
|
+
f"{static}/bluecore/bluecore.css",
|
|
76
|
+
f"{static}/bluecore/bluecore.js",
|
|
77
|
+
f"{static}/toolbox.css",
|
|
78
|
+
f"{static}/blue-core-v1.svg",
|
|
79
|
+
]
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_health_is_public_and_minimal(client: TestClient) -> None:
|
|
84
|
+
response = client.get("/health")
|
|
85
|
+
|
|
86
|
+
assert response.status_code == 200
|
|
87
|
+
assert response.json() == {"status": "ok", "version": __version__}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_static_files_are_served_without_sign_in(client: TestClient) -> None:
|
|
91
|
+
for name in STATIC_FILES:
|
|
92
|
+
response = client.get(f"/static/{name}")
|
|
93
|
+
assert response.status_code == 200, name
|