schemapack 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- schemapack-1.0.0/LICENSE +202 -0
- schemapack-1.0.0/PKG-INFO +66 -0
- schemapack-1.0.0/README.md +42 -0
- schemapack-1.0.0/pyproject.toml +35 -0
- schemapack-1.0.0/setup.cfg +4 -0
- schemapack-1.0.0/src/schemapack/__init__.py +20 -0
- schemapack-1.0.0/src/schemapack/__main__.py +16 -0
- schemapack-1.0.0/src/schemapack/exceptions.py +202 -0
- schemapack-1.0.0/src/schemapack/integrate.py +131 -0
- schemapack-1.0.0/src/schemapack/isolate.py +185 -0
- schemapack-1.0.0/src/schemapack/load.py +49 -0
- schemapack-1.0.0/src/schemapack/main.py +45 -0
- schemapack-1.0.0/src/schemapack/spec/__init__.py +17 -0
- schemapack-1.0.0/src/schemapack/spec/datapack.py +135 -0
- schemapack-1.0.0/src/schemapack/spec/schemapack.py +400 -0
- schemapack-1.0.0/src/schemapack/utils.py +146 -0
- schemapack-1.0.0/src/schemapack/validation/__init__.py +20 -0
- schemapack-1.0.0/src/schemapack/validation/base.py +128 -0
- schemapack-1.0.0/src/schemapack/validation/default.py +54 -0
- schemapack-1.0.0/src/schemapack/validation/main.py +239 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/__init__.py +52 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/cardinality_plural.py +79 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/content_schema.py +78 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/duplicate_foreign_id.py +88 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/foreign_id.py +79 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/id_from_content.py +65 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/missing_class.py +60 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/missing_relations.py +70 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/one_to_many_overlap.py +101 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/one_to_one_overlap.py +101 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/unknown_class.py +63 -0
- schemapack-1.0.0/src/schemapack/validation/plugins/unknown_relations.py +70 -0
- schemapack-1.0.0/src/schemapack.egg-info/PKG-INFO +66 -0
- schemapack-1.0.0/src/schemapack.egg-info/SOURCES.txt +41 -0
- schemapack-1.0.0/src/schemapack.egg-info/dependency_links.txt +1 -0
- schemapack-1.0.0/src/schemapack.egg-info/requires.txt +5 -0
- schemapack-1.0.0/src/schemapack.egg-info/top_level.txt +1 -0
- schemapack-1.0.0/tests/test_integrate.py +65 -0
- schemapack-1.0.0/tests/test_isolate.py +95 -0
- schemapack-1.0.0/tests/test_load.py +75 -0
- schemapack-1.0.0/tests/test_main.py +61 -0
- schemapack-1.0.0/tests/test_spec.py +60 -0
- schemapack-1.0.0/tests/test_utils.py +94 -0
schemapack-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
|
|
190
|
+
for the German Human Genome-Phenome Archive (GHGA)
|
|
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,66 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: schemapack
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Make your JSON Schemas sociable and create linked data model.
|
|
5
|
+
Author-email: "German Human Genome Phenome Archive (GHGA)" <contact@ghga.de>
|
|
6
|
+
License: Apache 2.0
|
|
7
|
+
Classifier: Development Status :: 1 - Planning
|
|
8
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: pydantic<3,>=2
|
|
20
|
+
Requires-Dist: pydantic_settings<3,>=2
|
|
21
|
+
Requires-Dist: PyYAML<7,>=6.0.1
|
|
22
|
+
Requires-Dist: jsonschema<5,>=4.19.2
|
|
23
|
+
Requires-Dist: immutabledict<4,>=3.0.0
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
[](https://pypi.python.org/pypi/schemapack/)
|
|
27
|
+
[](https://pypi.python.org/pypi/schemapack/)
|
|
28
|
+
[](https://coveralls.io/github/ghga-de/schemapack?branch=main)
|
|
29
|
+
|
|
30
|
+
# schemapack
|
|
31
|
+
|
|
32
|
+
Make your JSON Schemas sociable and create linked data model.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
This package is available at PyPI:
|
|
36
|
+
https://pypi.org/project/schemapack
|
|
37
|
+
|
|
38
|
+
You can install it from there using:
|
|
39
|
+
```
|
|
40
|
+
pip install schemapack
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
For setting up the development environment, we rely on the
|
|
45
|
+
[devcontainer feature](https://code.visualstudio.com/docs/remote/containers) of vscode.
|
|
46
|
+
|
|
47
|
+
To use it, you have to have Docker as well as vscode with its "Remote - Containers"
|
|
48
|
+
extension (`ms-vscode-remote.remote-containers`) extension installed.
|
|
49
|
+
Then, you just have to open this repo in vscode and run the command
|
|
50
|
+
`Remote-Containers: Reopen in Container` from the vscode "Command Palette".
|
|
51
|
+
|
|
52
|
+
This will give you a full-fledged, pre-configured development environment including:
|
|
53
|
+
- infrastructural dependencies of the service (databases, etc.)
|
|
54
|
+
- all relevant vscode extensions pre-installed
|
|
55
|
+
- pre-configured linting and auto-formating
|
|
56
|
+
- a pre-configured debugger
|
|
57
|
+
- automatic license-header insertion
|
|
58
|
+
|
|
59
|
+
Moreover, inside the devcontainer, there is follwing convenience command available
|
|
60
|
+
(please type it in the integrated terminal of vscode):
|
|
61
|
+
- `dev_install` - install the lib with all development dependencies and pre-commit hooks
|
|
62
|
+
(please run that if you are starting the devcontainer for the first time
|
|
63
|
+
or if added any python dependencies to the [`./setup.cfg`](./setup.cfg))
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
This repository is free to use and modify according to the [Apache 2.0 License](./LICENSE).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+

|
|
2
|
+
[](https://pypi.python.org/pypi/schemapack/)
|
|
3
|
+
[](https://pypi.python.org/pypi/schemapack/)
|
|
4
|
+
[](https://coveralls.io/github/ghga-de/schemapack?branch=main)
|
|
5
|
+
|
|
6
|
+
# schemapack
|
|
7
|
+
|
|
8
|
+
Make your JSON Schemas sociable and create linked data model.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
This package is available at PyPI:
|
|
12
|
+
https://pypi.org/project/schemapack
|
|
13
|
+
|
|
14
|
+
You can install it from there using:
|
|
15
|
+
```
|
|
16
|
+
pip install schemapack
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
For setting up the development environment, we rely on the
|
|
21
|
+
[devcontainer feature](https://code.visualstudio.com/docs/remote/containers) of vscode.
|
|
22
|
+
|
|
23
|
+
To use it, you have to have Docker as well as vscode with its "Remote - Containers"
|
|
24
|
+
extension (`ms-vscode-remote.remote-containers`) extension installed.
|
|
25
|
+
Then, you just have to open this repo in vscode and run the command
|
|
26
|
+
`Remote-Containers: Reopen in Container` from the vscode "Command Palette".
|
|
27
|
+
|
|
28
|
+
This will give you a full-fledged, pre-configured development environment including:
|
|
29
|
+
- infrastructural dependencies of the service (databases, etc.)
|
|
30
|
+
- all relevant vscode extensions pre-installed
|
|
31
|
+
- pre-configured linting and auto-formating
|
|
32
|
+
- a pre-configured debugger
|
|
33
|
+
- automatic license-header insertion
|
|
34
|
+
|
|
35
|
+
Moreover, inside the devcontainer, there is follwing convenience command available
|
|
36
|
+
(please type it in the integrated terminal of vscode):
|
|
37
|
+
- `dev_install` - install the lib with all development dependencies and pre-commit hooks
|
|
38
|
+
(please run that if you are starting the devcontainer for the first time
|
|
39
|
+
or if added any python dependencies to the [`./setup.cfg`](./setup.cfg))
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
This repository is free to use and modify according to the [Apache 2.0 License](./LICENSE).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=67.7.2"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "schemapack"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Make your JSON Schemas sociable and create linked data model."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "German Human Genome Phenome Archive (GHGA)", email = "contact@ghga.de" },
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
license = { text = "Apache 2.0" }
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 1 - Planning",
|
|
17
|
+
"Operating System :: POSIX :: Linux",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"License :: OSI Approved :: Apache Software License",
|
|
22
|
+
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
|
23
|
+
"Topic :: Software Development :: Libraries",
|
|
24
|
+
"Intended Audience :: Developers",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pydantic >=2, <3",
|
|
28
|
+
"pydantic_settings >=2, <3",
|
|
29
|
+
"PyYAML >=6.0.1, <7",
|
|
30
|
+
"jsonschema >=4.19.2, <5",
|
|
31
|
+
"immutabledict >=3.0.0, <4",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[tool.setuptools.packages.find]
|
|
35
|
+
where = ["src"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
|
|
2
|
+
# for the German Human Genome-Phenome Archive (GHGA)
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
"""A specification (plus tooling) for describing linked data models based on JSON schema."""
|
|
17
|
+
|
|
18
|
+
from importlib.metadata import version
|
|
19
|
+
|
|
20
|
+
__version__ = version(__package__)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
|
|
2
|
+
# for the German Human Genome-Phenome Archive (GHGA)
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
"""Entrypoint of the package"""
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Copyright 2021 - 2023 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln
|
|
2
|
+
# for the German Human Genome-Phenome Archive (GHGA)
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
"""Collection of package-specific exceptions"""
|
|
18
|
+
|
|
19
|
+
from abc import ABC
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from typing import Optional
|
|
22
|
+
|
|
23
|
+
import pydantic_core
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class BaseError(ABC, Exception):
|
|
27
|
+
"""Base class for all schemapack errors."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class SpecError(BaseError, ValueError):
|
|
31
|
+
"""An error indicating that an instance was not valid against the specification."""
|
|
32
|
+
|
|
33
|
+
def __init__(self, message: str, *, details: list[pydantic_core.ErrorDetails]):
|
|
34
|
+
"""Initiate a SpecError.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
message: A human-readable message describing the error.
|
|
38
|
+
details: Details on which fields of the instance are invalid.
|
|
39
|
+
"""
|
|
40
|
+
super().__init__(message)
|
|
41
|
+
self.message = message
|
|
42
|
+
self.details = details
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class SchemaPackSpecError(SpecError):
|
|
46
|
+
"""An error indicating that the provided data is not valid against the schemapack
|
|
47
|
+
specification.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
def __init__(self, message: str, *, details: list[pydantic_core.ErrorDetails]):
|
|
51
|
+
"""Initiate a SchemaPackSpecError.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
message: A human-readable message describing the error.
|
|
55
|
+
details: Details on which fields of the instance are invalid.
|
|
56
|
+
"""
|
|
57
|
+
message = (
|
|
58
|
+
"The provided object was not compatible with the schemapack"
|
|
59
|
+
+ f" specification: {message}"
|
|
60
|
+
)
|
|
61
|
+
super().__init__(message, details=details)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class DataPackSpecError(SpecError):
|
|
65
|
+
"""An error indicating that the provided data is not valid against the datapack
|
|
66
|
+
specification (this is independent of validation done using a schemapack).
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def __init__(self, message: str, *, details: list[pydantic_core.ErrorDetails]):
|
|
70
|
+
"""Initiate a SchemaPackSpecError.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
message: A human-readable message describing the error.
|
|
74
|
+
details: Details on which fields of the instance are invalid.
|
|
75
|
+
"""
|
|
76
|
+
message = (
|
|
77
|
+
"The provided object was not compatible with the datapack"
|
|
78
|
+
+ f" specification: {message}"
|
|
79
|
+
)
|
|
80
|
+
super().__init__(message, details=details)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class ValidationPluginError(BaseError, ValueError):
|
|
84
|
+
"""Raised by a ValidationPlugin."""
|
|
85
|
+
|
|
86
|
+
def __init__(
|
|
87
|
+
self, *, type_: str, message: str, details: Optional[dict[str, object]] = None
|
|
88
|
+
):
|
|
89
|
+
"""Initiate a ValidationPluginError.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
type: A preferably short type label.
|
|
93
|
+
message: A human-readable message describing the error.
|
|
94
|
+
details: A dictionary for transporting additional machine-readable details.
|
|
95
|
+
"""
|
|
96
|
+
super().__init__(message)
|
|
97
|
+
self.type_ = type_
|
|
98
|
+
self.message = message
|
|
99
|
+
self.details = details if details else {}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@dataclass
|
|
103
|
+
class ValidationErrorRecord:
|
|
104
|
+
"""A record of an Error occuring during validation on a specific context
|
|
105
|
+
(e.g. a specific resource) regarding a specific validation aspect.
|
|
106
|
+
|
|
107
|
+
Attributes:
|
|
108
|
+
subject_class:
|
|
109
|
+
If relevant, the name of the subject class as per the schemapack.
|
|
110
|
+
subject_resource:
|
|
111
|
+
If relevant, the ID or the subject resource of the subject class.
|
|
112
|
+
type:
|
|
113
|
+
A preferably short type label.
|
|
114
|
+
message:
|
|
115
|
+
A human-readable message describing the error.
|
|
116
|
+
details:
|
|
117
|
+
A dictionary for transporting additional machine-readable details.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
subject_class: Optional[str]
|
|
121
|
+
subject_resource: Optional[str]
|
|
122
|
+
type: str
|
|
123
|
+
message: str
|
|
124
|
+
details: dict[str, object]
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _val_record_to_str(record: ValidationErrorRecord) -> str:
|
|
128
|
+
"""Translate a ValidationErrorRecords into a human-readable message
|
|
129
|
+
to be displayed to the user on the terminal.
|
|
130
|
+
"""
|
|
131
|
+
if record.subject_class:
|
|
132
|
+
if record.subject_resource:
|
|
133
|
+
context = f"resource '{record.subject_class}.{record.subject_resource}'"
|
|
134
|
+
else:
|
|
135
|
+
context = "class '{record.subject_class}'"
|
|
136
|
+
else:
|
|
137
|
+
context = "global datapack"
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
f"Error in {context}:"
|
|
141
|
+
+ f"\n\tType: {record.type}"
|
|
142
|
+
+ f"\n\tMessage: {record.message}"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _sorted_val_records(
|
|
147
|
+
records: list[ValidationErrorRecord],
|
|
148
|
+
) -> list[ValidationErrorRecord]:
|
|
149
|
+
"""Sort a set of ValidationErrorRecords."""
|
|
150
|
+
return sorted(records, key=lambda r: (r.subject_class, r.subject_resource, r.type))
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class ValidationError(BaseError, ValueError):
|
|
154
|
+
"""A collection of ValidationErrorRecords raised when a datapack fails validation
|
|
155
|
+
against a schemapack.
|
|
156
|
+
"""
|
|
157
|
+
|
|
158
|
+
def __init__(self, records: list[ValidationErrorRecord]):
|
|
159
|
+
"""Initiate a ValidationError.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
records: A list of ValidationErrorRecords.
|
|
163
|
+
"""
|
|
164
|
+
if not records:
|
|
165
|
+
raise ValueError("ValidationError must be raised with at least one record.")
|
|
166
|
+
|
|
167
|
+
self.records = _sorted_val_records(records)
|
|
168
|
+
n_records = len(self.records)
|
|
169
|
+
record_messages = "\n".join(_val_record_to_str(r) for r in self.records)
|
|
170
|
+
message = f"Validation failed with {n_records} issue(s):\n{record_messages}"
|
|
171
|
+
|
|
172
|
+
super().__init__(message)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class ValidationAssumptionError(BaseError, RuntimeError):
|
|
176
|
+
"""This is raised when a unit of code assumes to work with a datapack that has
|
|
177
|
+
already been validated against a specific schemapack, however, it became apparent
|
|
178
|
+
that this assumption was not correct. The error should not contain the details on
|
|
179
|
+
which aspect is invalid. These details can be retrieved by performing a validation
|
|
180
|
+
and receiving a ValidationError.
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
def __init__(self, *, context: str):
|
|
184
|
+
"""Initiate a ValidationAssumptionError.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
context: Some context to be included in the error message.
|
|
188
|
+
"""
|
|
189
|
+
message = (
|
|
190
|
+
"It was assumed that the provided datapack has already been validated"
|
|
191
|
+
+ " against the provided schemapack, however, this assumption failed in"
|
|
192
|
+
+ f" the context of {context}. Please validate the datapack against the"
|
|
193
|
+
+ " schemapack to get further details."
|
|
194
|
+
)
|
|
195
|
+
super().__init__(message)
|
|
196
|
+
self.message = message
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class CircularRelationError(BaseError, ValueError):
|
|
200
|
+
"""Raised when a circular relation between resources is detected, but the requested
|
|
201
|
+
operation cannot be performed on datapacks with circular relations.
|
|
202
|
+
"""
|