pangloss-models 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.
- pangloss_models-0.1.0/.gitignore +42 -0
- pangloss_models-0.1.0/LICENCE.txt +21 -0
- pangloss_models-0.1.0/PKG-INFO +21 -0
- pangloss_models-0.1.0/README.md +7 -0
- pangloss_models-0.1.0/pyproject.toml +40 -0
- pangloss_models-0.1.0/setup.cfg +15 -0
- pangloss_models-0.1.0/src/pangloss_models/__init__.py +294 -0
- pangloss_models-0.1.0/src/pangloss_models/autocomplete.py +128 -0
- pangloss_models-0.1.0/src/pangloss_models/bulk_upload.py +147 -0
- pangloss_models-0.1.0/src/pangloss_models/citations.py +393 -0
- pangloss_models-0.1.0/src/pangloss_models/companions.py +236 -0
- pangloss_models-0.1.0/src/pangloss_models/computed.py +117 -0
- pangloss_models-0.1.0/src/pangloss_models/context.py +99 -0
- pangloss_models-0.1.0/src/pangloss_models/creators.py +136 -0
- pangloss_models-0.1.0/src/pangloss_models/diagnostics.py +830 -0
- pangloss_models-0.1.0/src/pangloss_models/editor_schema.py +292 -0
- pangloss_models-0.1.0/src/pangloss_models/exceptions.py +280 -0
- pangloss_models-0.1.0/src/pangloss_models/export.py +586 -0
- pangloss_models-0.1.0/src/pangloss_models/field_definitions.py +362 -0
- pangloss_models-0.1.0/src/pangloss_models/hooks.py +863 -0
- pangloss_models-0.1.0/src/pangloss_models/indexes.py +161 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/__init__.py +0 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/builder.py +645 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_attributions.py +122 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_bindings.py +71 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_companions.py +316 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_degree_fields.py +168 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_grounds.py +102 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_label_templates.py +245 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_relation_targets.py +74 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_reverse_names.py +43 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/check_semantic_spaces.py +215 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/common.py +338 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_create_db_model.py +22 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_create_model.py +20 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_edit_view_model.py +44 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_field_definitions.py +1721 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_head_view_model.py +166 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_incoming_relation_definitions.py +125 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_reference_models.py +151 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_update_db_model.py +22 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_update_model.py +20 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/initialise_view_model.py +32 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/kinds.py +377 -0
- pangloss_models-0.1.0/src/pangloss_models/initialise_models/tagged_union.py +174 -0
- pangloss_models-0.1.0/src/pangloss_models/label_templates.py +770 -0
- pangloss_models-0.1.0/src/pangloss_models/literals.py +533 -0
- pangloss_models-0.1.0/src/pangloss_models/markers.py +126 -0
- pangloss_models-0.1.0/src/pangloss_models/merging.py +490 -0
- pangloss_models-0.1.0/src/pangloss_models/meta_kit/__init__.py +10 -0
- pangloss_models-0.1.0/src/pangloss_models/meta_kit/exceptions.py +2 -0
- pangloss_models-0.1.0/src/pangloss_models/meta_kit/meta.py +350 -0
- pangloss_models-0.1.0/src/pangloss_models/meta_slots.py +110 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/__init__.py +131 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/affected.py +225 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/changes.py +1021 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/check.py +154 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/conversion.py +96 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/diff.py +948 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/files.py +596 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/fulfils.py +74 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/history.py +134 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/patterns.py +657 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/planner.py +434 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/questions.py +274 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/reports.py +52 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/reverse.py +469 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/snapshot.py +187 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/startup.py +55 -0
- pangloss_models-0.1.0/src/pangloss_models/migrations/state.py +364 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/__init__.py +0 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/annotated_value.py +34 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/base_models.py +502 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/base_types.py +6 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/binding.py +129 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/configs.py +21 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/conjunction.py +69 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/document.py +261 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/edge_model.py +40 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/embedded.py +75 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/entity.py +221 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/from_database.py +25 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/fulfilment.py +118 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/ground.py +61 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/helpers.py +38 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/instance_context.py +65 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/labels.py +96 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/model_tools.py +89 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/reified_relation.py +159 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/relation.py +7 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/semantic_space.py +127 -0
- pangloss_models-0.1.0/src/pangloss_models/model_bases/trait.py +64 -0
- pangloss_models-0.1.0/src/pangloss_models/model_registry.py +704 -0
- pangloss_models-0.1.0/src/pangloss_models/protection.py +67 -0
- pangloss_models-0.1.0/src/pangloss_models/py.typed +0 -0
- pangloss_models-0.1.0/src/pangloss_models/rewriting.py +130 -0
- pangloss_models-0.1.0/src/pangloss_models/search.py +1956 -0
- pangloss_models-0.1.0/src/pangloss_models/search_where.py +776 -0
- pangloss_models-0.1.0/src/pangloss_models/server_only.py +26 -0
- pangloss_models-0.1.0/src/pangloss_models/spaces.py +422 -0
- pangloss_models-0.1.0/src/pangloss_models/text.py +19 -0
- pangloss_models-0.1.0/src/pangloss_models/together.py +29 -0
- pangloss_models-0.1.0/src/pangloss_models/typestubs.py +855 -0
- pangloss_models-0.1.0/src/pangloss_models/usage.py +55 -0
- pangloss_models-0.1.0/src/pangloss_models/utils.py +582 -0
- pangloss_models-0.1.0/src/pangloss_models/validators.py +17 -0
- pangloss_models-0.1.0/src/pangloss_models/write_checks.py +210 -0
- pangloss_models-0.1.0/tests/conftest.py +41 -0
- pangloss_models-0.1.0/tests/export/test_export_models.py +352 -0
- pangloss_models-0.1.0/tests/generated_models/snapshots/generated_models.json +29611 -0
- pangloss_models-0.1.0/tests/generated_models/test_binding_rules.py +394 -0
- pangloss_models-0.1.0/tests/generated_models/test_create_db_model.py +1805 -0
- pangloss_models-0.1.0/tests/generated_models/test_create_model.py +1392 -0
- pangloss_models-0.1.0/tests/generated_models/test_cross_kind_properties.py +190 -0
- pangloss_models-0.1.0/tests/generated_models/test_descriptions.py +40 -0
- pangloss_models-0.1.0/tests/generated_models/test_edit_view_model.py +106 -0
- pangloss_models-0.1.0/tests/generated_models/test_embedded_reached_through_a_binding.py +98 -0
- pangloss_models-0.1.0/tests/generated_models/test_generated_models_snapshot.py +108 -0
- pangloss_models-0.1.0/tests/generated_models/test_head_view_model.py +408 -0
- pangloss_models-0.1.0/tests/generated_models/test_nesting.py +118 -0
- pangloss_models-0.1.0/tests/generated_models/test_pydantic_conformance.py +390 -0
- pangloss_models-0.1.0/tests/generated_models/test_reference_model.py +240 -0
- pangloss_models-0.1.0/tests/generated_models/test_tagged_union.py +314 -0
- pangloss_models-0.1.0/tests/generated_models/test_union_order.py +119 -0
- pangloss_models-0.1.0/tests/generated_models/test_update_db_model.py +1273 -0
- pangloss_models-0.1.0/tests/generated_models/test_update_model.py +1622 -0
- pangloss_models-0.1.0/tests/generated_models/test_view_model.py +994 -0
- pangloss_models-0.1.0/tests/initialisation/test_binding_names.py +136 -0
- pangloss_models-0.1.0/tests/initialisation/test_companion_declarations.py +308 -0
- pangloss_models-0.1.0/tests/initialisation/test_field_types.py +357 -0
- pangloss_models-0.1.0/tests/initialisation/test_initialisation_gaps.py +1211 -0
- pangloss_models-0.1.0/tests/initialisation/test_initialisation_mechanism.py +3548 -0
- pangloss_models-0.1.0/tests/initialisation/test_initialise_field_definitions.py +2479 -0
- pangloss_models-0.1.0/tests/initialisation/test_literals.py +206 -0
- pangloss_models-0.1.0/tests/initialisation/test_meta.py +229 -0
- pangloss_models-0.1.0/tests/initialisation/test_model_manager.py +13 -0
- pangloss_models-0.1.0/tests/initialisation/test_relation_targets.py +96 -0
- pangloss_models-0.1.0/tests/initialisation/test_reverse_names.py +78 -0
- pangloss_models-0.1.0/tests/initialisation/test_semantic_traits.py +228 -0
- pangloss_models-0.1.0/tests/initialisation/test_utils.py +342 -0
- pangloss_models-0.1.0/tests/initialisation/test_wrapper_and_edge_shapes.py +402 -0
- pangloss_models-0.1.0/tests/label_cases.json +910 -0
- pangloss_models-0.1.0/tests/meta_kit/test_meta_kit.py +538 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_affected.py +395 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_by_hand.py +154 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_diff.py +1781 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_files.py +202 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_fulfils.py +127 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_literal_types.py +106 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_patterns.py +701 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_planner.py +911 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_reverse.py +258 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_squash.py +404 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_state.py +140 -0
- pangloss_models-0.1.0/tests/migrations/test_migration_structure.py +323 -0
- pangloss_models-0.1.0/tests/space_cases.json +3004 -0
- pangloss_models-0.1.0/tests/support/kitchen_sink.py +265 -0
- pangloss_models-0.1.0/tests/support/migration_support.py +58 -0
- pangloss_models-0.1.0/tests/support/sample_data.py +242 -0
- pangloss_models-0.1.0/tests/support/snapshot_support.py +391 -0
- pangloss_models-0.1.0/tests/test_attribution.py +364 -0
- pangloss_models-0.1.0/tests/test_autocomplete_types.py +119 -0
- pangloss_models-0.1.0/tests/test_bulk_upload.py +209 -0
- pangloss_models-0.1.0/tests/test_check_semantic_spaces.py +440 -0
- pangloss_models-0.1.0/tests/test_citations.py +229 -0
- pangloss_models-0.1.0/tests/test_citations_no_basis.py +38 -0
- pangloss_models-0.1.0/tests/test_companion_payloads.py +212 -0
- pangloss_models-0.1.0/tests/test_computed_fields.py +542 -0
- pangloss_models-0.1.0/tests/test_confirmed_hook.py +76 -0
- pangloss_models-0.1.0/tests/test_context_path.py +444 -0
- pangloss_models-0.1.0/tests/test_declared_validators.py +67 -0
- pangloss_models-0.1.0/tests/test_degree_marker.py +372 -0
- pangloss_models-0.1.0/tests/test_editor_schema.py +106 -0
- pangloss_models-0.1.0/tests/test_from_database_hook.py +61 -0
- pangloss_models-0.1.0/tests/test_generic_optional_relation.py +78 -0
- pangloss_models-0.1.0/tests/test_ground.py +373 -0
- pangloss_models-0.1.0/tests/test_incoming_through_wrapper.py +79 -0
- pangloss_models-0.1.0/tests/test_label_templates.py +833 -0
- pangloss_models-0.1.0/tests/test_merging.py +637 -0
- pangloss_models-0.1.0/tests/test_meta_slots.py +232 -0
- pangloss_models-0.1.0/tests/test_model_indexes.py +176 -0
- pangloss_models-0.1.0/tests/test_read_validator.py +204 -0
- pangloss_models-0.1.0/tests/test_resolved_hook.py +77 -0
- pangloss_models-0.1.0/tests/test_rewriting_tree.py +43 -0
- pangloss_models-0.1.0/tests/test_search_incoming.py +152 -0
- pangloss_models-0.1.0/tests/test_search_match.py +1142 -0
- pangloss_models-0.1.0/tests/test_search_through.py +567 -0
- pangloss_models-0.1.0/tests/test_search_via_check.py +775 -0
- pangloss_models-0.1.0/tests/test_search_where.py +190 -0
- pangloss_models-0.1.0/tests/test_search_where_models.py +499 -0
- pangloss_models-0.1.0/tests/test_search_wrapper_relations.py +458 -0
- pangloss_models-0.1.0/tests/test_semantic_space_fields.py +114 -0
- pangloss_models-0.1.0/tests/test_shares.py +177 -0
- pangloss_models-0.1.0/tests/test_space_contents_length.py +477 -0
- pangloss_models-0.1.0/tests/test_space_export.py +166 -0
- pangloss_models-0.1.0/tests/test_spaces_walk.py +922 -0
- pangloss_models-0.1.0/tests/test_stand_ins.py +617 -0
- pangloss_models-0.1.0/tests/test_usage_meta.py +64 -0
- pangloss_models-0.1.0/tests/test_wrapper_classes_below.py +188 -0
- pangloss_models-0.1.0/tests/test_wrapper_field_validators.py +41 -0
- pangloss_models-0.1.0/tests/test_write_checks.py +463 -0
- pangloss_models-0.1.0/tests/test_write_instructions.py +117 -0
- pangloss_models-0.1.0/tests/typestubs/test_attribution_stubs.py +107 -0
- pangloss_models-0.1.0/tests/typestubs/test_space_meta_stubs.py +104 -0
- pangloss_models-0.1.0/tests/typestubs/test_stub_source.py +363 -0
- pangloss_models-0.1.0/todo.md +216 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.pytest_cache
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
.venv
|
|
15
|
+
|
|
16
|
+
# Editor variables
|
|
17
|
+
.zed
|
|
18
|
+
.ropeproject
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# a separate repository, cloned here
|
|
22
|
+
packages/pydantic-meta-kit/
|
|
23
|
+
|
|
24
|
+
# coverage data
|
|
25
|
+
.coverage
|
|
26
|
+
.coverage.*
|
|
27
|
+
|
|
28
|
+
# Playwright traces and screenshots of failed e2e tests
|
|
29
|
+
test-results/
|
|
30
|
+
|
|
31
|
+
.ruff_cache/
|
|
32
|
+
|
|
33
|
+
# Secrets of a project (AUTHJWT_SECRET_KEY, API keys): never for version control
|
|
34
|
+
.env
|
|
35
|
+
.env.*
|
|
36
|
+
!.env.example
|
|
37
|
+
|
|
38
|
+
# what npm installs, and the caches vitest keeps there
|
|
39
|
+
node_modules/
|
|
40
|
+
|
|
41
|
+
# the scratch folder of the mutation tests (implementation_docs/mutation-testing.md)
|
|
42
|
+
packages/pangloss-models/mm_live/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Richard Hadden, Department of Digital Humanities, University of Graz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pangloss-models
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pangloss models: declare research data as Python classes, and generate their create, update and view models
|
|
5
|
+
Project-URL: Repository, https://github.com/richardhadden/pangloss-monorepo
|
|
6
|
+
Author-email: Richard Hadden <richard.hadden@oeaw.ac.at>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENCE.txt
|
|
9
|
+
Requires-Python: >=3.15
|
|
10
|
+
Requires-Dist: frozendict>=2.4.7
|
|
11
|
+
Requires-Dist: pangloss-core==0.1.0
|
|
12
|
+
Requires-Dist: pydantic>=2.13.3
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# pangloss-models
|
|
16
|
+
|
|
17
|
+
Declaring and initialising models: `Document`, `Entity`, `Embedded`, `Trait`, `EdgeModel`, `ReifiedRelation`, `SemanticSpace`,
|
|
18
|
+
`Conjunction`; the generated `Create`, `Update` and view models; `initialise()`; the export of the models, type stubs, the
|
|
19
|
+
migration planner, structured search and the meta slots. `pangloss_models.meta_kit` is the vendored `pydantic-meta-kit`.
|
|
20
|
+
|
|
21
|
+
Guide: [guide/getting-started](../../guide/getting-started/README.md). Reference: [implementation_docs/models.md](../../implementation_docs/models.md).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# pangloss-models
|
|
2
|
+
|
|
3
|
+
Declaring and initialising models: `Document`, `Entity`, `Embedded`, `Trait`, `EdgeModel`, `ReifiedRelation`, `SemanticSpace`,
|
|
4
|
+
`Conjunction`; the generated `Create`, `Update` and view models; `initialise()`; the export of the models, type stubs, the
|
|
5
|
+
migration planner, structured search and the meta slots. `pangloss_models.meta_kit` is the vendored `pydantic-meta-kit`.
|
|
6
|
+
|
|
7
|
+
Guide: [guide/getting-started](../../guide/getting-started/README.md). Reference: [implementation_docs/models.md](../../implementation_docs/models.md).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pangloss-models"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Pangloss models: declare research data as Python classes, and generate their create, update and view models"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENCE.txt"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Richard Hadden", email = "richard.hadden@oeaw.ac.at" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.15"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"frozendict>=2.4.7",
|
|
14
|
+
"pangloss-core==0.1.0",
|
|
15
|
+
"pydantic>=2.13.3",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Repository = "https://github.com/richardhadden/pangloss-monorepo"
|
|
20
|
+
|
|
21
|
+
[build-system]
|
|
22
|
+
requires = ["hatchling>=1.27"]
|
|
23
|
+
build-backend = "hatchling.build"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.build.targets.sdist]
|
|
26
|
+
# (a scratch folder of the mutation tests)
|
|
27
|
+
exclude = ["/mm_live"]
|
|
28
|
+
|
|
29
|
+
[tool.uv.sources]
|
|
30
|
+
pangloss-core = { workspace = true }
|
|
31
|
+
pangloss-sdk = { workspace = true }
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = [
|
|
35
|
+
"dirty-equals>=0.11",
|
|
36
|
+
"pangloss-sdk",
|
|
37
|
+
"pytest>=9.0.3",
|
|
38
|
+
"pytest-xdist>=3.8.0",
|
|
39
|
+
"python-lsp-server>=1.14.0",
|
|
40
|
+
]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[mutmut]
|
|
2
|
+
paths_to_mutate=
|
|
3
|
+
src/pangloss_models/search.py
|
|
4
|
+
src/pangloss_models/search_where.py
|
|
5
|
+
src/pangloss_models/label_templates.py
|
|
6
|
+
tests_dir=
|
|
7
|
+
tests/test_search_match.py
|
|
8
|
+
tests/test_search_through.py
|
|
9
|
+
tests/test_search_where.py
|
|
10
|
+
tests/test_search_where_models.py
|
|
11
|
+
tests/test_label_templates.py
|
|
12
|
+
tests/test_search_incoming.py
|
|
13
|
+
pytest_add_cli_args=-p no:cacheprovider -q
|
|
14
|
+
also_copy=
|
|
15
|
+
src
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"""Pangloss models: declare research data as Python classes, and generate their create, update and view models.
|
|
2
|
+
|
|
3
|
+
What a project or an add-on uses is imported from here (`from pangloss_models import Document, initialise`), not from
|
|
4
|
+
the module it is kept in; the imports are lazy, so nothing is loaded until it is used. See implementation_docs/imports.md.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
lazy from pangloss_models.creators import Creator, ToolchainRun
|
|
8
|
+
lazy from pangloss_models.context import PathEntry
|
|
9
|
+
lazy from pangloss_models.model_bases.annotated_value import AnnotatedValue
|
|
10
|
+
lazy from pangloss_models.model_bases.configs import RelationConfig
|
|
11
|
+
lazy from pangloss_models.model_bases.conjunction import Conjunction
|
|
12
|
+
lazy from pangloss_models.model_bases.document import Document
|
|
13
|
+
lazy from pangloss_models.model_bases.edge_model import EdgeModel
|
|
14
|
+
lazy from pangloss_models.model_bases.embedded import Embedded
|
|
15
|
+
lazy from pangloss_models.model_bases.entity import Entity
|
|
16
|
+
lazy from pangloss_models.model_bases.helpers import (
|
|
17
|
+
DBField,
|
|
18
|
+
Description,
|
|
19
|
+
Fulfils,
|
|
20
|
+
ViaEdge,
|
|
21
|
+
)
|
|
22
|
+
lazy from pangloss_models.model_bases.ground import Ground
|
|
23
|
+
lazy from pangloss_models.model_bases.reified_relation import (
|
|
24
|
+
ReifiedRelation,
|
|
25
|
+
ReifiedRelationDocument,
|
|
26
|
+
)
|
|
27
|
+
lazy from pangloss_models.model_bases.semantic_space import (
|
|
28
|
+
DEGREE_STEPS,
|
|
29
|
+
DegreeStep,
|
|
30
|
+
Modal,
|
|
31
|
+
SemanticSpace,
|
|
32
|
+
)
|
|
33
|
+
lazy from pangloss_models.model_bases.trait import (
|
|
34
|
+
NonHeritableTrait,
|
|
35
|
+
SemanticNonHeritableTrait,
|
|
36
|
+
SemanticTrait,
|
|
37
|
+
Trait,
|
|
38
|
+
)
|
|
39
|
+
lazy from pangloss_models.field_definitions import (
|
|
40
|
+
FieldBinding,
|
|
41
|
+
FieldSubclassing,
|
|
42
|
+
)
|
|
43
|
+
lazy from pangloss_models.validators import SumsTo
|
|
44
|
+
lazy from pangloss_models.together import create_heads
|
|
45
|
+
lazy from pangloss_models.rewriting import prepare_rewrite, rewrite
|
|
46
|
+
lazy from pangloss_models.companions import (
|
|
47
|
+
Companion,
|
|
48
|
+
CompanionPart,
|
|
49
|
+
CopyFromOuter,
|
|
50
|
+
Standalone,
|
|
51
|
+
Within,
|
|
52
|
+
)
|
|
53
|
+
lazy from pangloss_models.citations import Cites
|
|
54
|
+
lazy from pangloss_models.markers import (
|
|
55
|
+
Attribution,
|
|
56
|
+
Computed,
|
|
57
|
+
Degree,
|
|
58
|
+
FieldMarker,
|
|
59
|
+
KeepOnMerge,
|
|
60
|
+
)
|
|
61
|
+
lazy from pangloss_models.computed import ComputedTarget, ComputedWrite
|
|
62
|
+
lazy from pangloss_models.literals import (
|
|
63
|
+
LiteralCodec,
|
|
64
|
+
ValueNotMigrated,
|
|
65
|
+
register_codec,
|
|
66
|
+
)
|
|
67
|
+
lazy from pangloss_models.search import (
|
|
68
|
+
AnyOf,
|
|
69
|
+
Match,
|
|
70
|
+
Not,
|
|
71
|
+
OrderBy,
|
|
72
|
+
Var,
|
|
73
|
+
ViaItem,
|
|
74
|
+
)
|
|
75
|
+
lazy from pangloss_models.search_where import (
|
|
76
|
+
AnyRel,
|
|
77
|
+
Choice,
|
|
78
|
+
Compare,
|
|
79
|
+
IncomingFrom,
|
|
80
|
+
Items,
|
|
81
|
+
Rel,
|
|
82
|
+
Text,
|
|
83
|
+
Through,
|
|
84
|
+
Where,
|
|
85
|
+
)
|
|
86
|
+
lazy from pangloss_models.hooks import WriteEvent
|
|
87
|
+
lazy from pangloss_models.merging import MergeRules
|
|
88
|
+
lazy from pangloss_models.meta_slots import register_meta_slot
|
|
89
|
+
lazy from pangloss_models.protection import (
|
|
90
|
+
Protection,
|
|
91
|
+
protection_of,
|
|
92
|
+
)
|
|
93
|
+
lazy from pangloss_models.usage import (
|
|
94
|
+
Usage,
|
|
95
|
+
included_only_when_referenced,
|
|
96
|
+
)
|
|
97
|
+
lazy from pangloss_models.export import export_models
|
|
98
|
+
lazy from pangloss_models.label_templates import (
|
|
99
|
+
Formatter,
|
|
100
|
+
LabelTemplate,
|
|
101
|
+
register_label_formatter,
|
|
102
|
+
)
|
|
103
|
+
lazy from pangloss_models.text import fold
|
|
104
|
+
lazy from pangloss_models.exceptions import (
|
|
105
|
+
PanglossAwaitingInitialisation,
|
|
106
|
+
PanglossBulkLoadError,
|
|
107
|
+
PanglossBulkRecordError,
|
|
108
|
+
PanglossClassChangeError,
|
|
109
|
+
PanglossConflictError,
|
|
110
|
+
PanglossEntityInUseError,
|
|
111
|
+
PanglossImportError,
|
|
112
|
+
PanglossInitialisationError,
|
|
113
|
+
PanglossInstructionError,
|
|
114
|
+
PanglossInternalError,
|
|
115
|
+
PanglossMergeBusyError,
|
|
116
|
+
PanglossCitedError,
|
|
117
|
+
PanglossMergedError,
|
|
118
|
+
PanglossMergeError,
|
|
119
|
+
PanglossMergeNotAllowedError,
|
|
120
|
+
PanglossMergeTooLargeError,
|
|
121
|
+
PanglossMetaError,
|
|
122
|
+
PanglossMigrationAnswerNeeded,
|
|
123
|
+
PanglossMigrationError,
|
|
124
|
+
PanglossMigrationIrreversible,
|
|
125
|
+
PanglossMigrationNotSupported,
|
|
126
|
+
PanglossModelError,
|
|
127
|
+
PanglossModelWarning,
|
|
128
|
+
PanglossNotCreatableError,
|
|
129
|
+
PanglossNotDeletableError,
|
|
130
|
+
PanglossNotDeletedError,
|
|
131
|
+
PanglossNotFoundError,
|
|
132
|
+
PanglossReadOnlyError,
|
|
133
|
+
PanglossReferenceError,
|
|
134
|
+
PanglossRuntimeError,
|
|
135
|
+
PanglossSearchError,
|
|
136
|
+
PanglossSearchTimeoutError,
|
|
137
|
+
PanglossServerOnly,
|
|
138
|
+
PanglossUnknownTypeError,
|
|
139
|
+
PanglossUserDisabledError,
|
|
140
|
+
PanglossUserNotFoundError,
|
|
141
|
+
PanglossVersionConflictError,
|
|
142
|
+
PanglossWriteError,
|
|
143
|
+
PanglossWriteRefused,
|
|
144
|
+
)
|
|
145
|
+
lazy from pangloss_models.initialise_models.builder import classes_stood_for
|
|
146
|
+
lazy from pangloss_models.write_checks import (
|
|
147
|
+
before_create,
|
|
148
|
+
before_update,
|
|
149
|
+
create_validator,
|
|
150
|
+
nodes_of,
|
|
151
|
+
read_validator,
|
|
152
|
+
update_validator,
|
|
153
|
+
whole_write,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
from pangloss_models import hooks
|
|
157
|
+
lazy from pangloss_models import spaces
|
|
158
|
+
from pangloss_models import protection # (registers the `_protect_meta` slot)
|
|
159
|
+
from pangloss_models import usage # (registers the `_usage_meta` slot)
|
|
160
|
+
from pangloss_models.model_registry import ModelRegistry
|
|
161
|
+
from pangloss_models.server_only import server_only
|
|
162
|
+
|
|
163
|
+
initialise = ModelRegistry.finalise
|
|
164
|
+
|
|
165
|
+
__all__ = [
|
|
166
|
+
"Companion",
|
|
167
|
+
"CompanionPart",
|
|
168
|
+
"CopyFromOuter",
|
|
169
|
+
"Standalone",
|
|
170
|
+
"Within",
|
|
171
|
+
"create_heads",
|
|
172
|
+
"prepare_rewrite",
|
|
173
|
+
"rewrite",
|
|
174
|
+
"Creator",
|
|
175
|
+
"Modal",
|
|
176
|
+
"Ground",
|
|
177
|
+
"DegreeStep",
|
|
178
|
+
"DEGREE_STEPS",
|
|
179
|
+
"PathEntry",
|
|
180
|
+
"ToolchainRun",
|
|
181
|
+
"AnnotatedValue",
|
|
182
|
+
"AnyOf",
|
|
183
|
+
"AnyRel",
|
|
184
|
+
"Choice",
|
|
185
|
+
"Compare",
|
|
186
|
+
"Conjunction",
|
|
187
|
+
"DBField",
|
|
188
|
+
"Description",
|
|
189
|
+
"Document",
|
|
190
|
+
"EdgeModel",
|
|
191
|
+
"Embedded",
|
|
192
|
+
"Entity",
|
|
193
|
+
"export_models",
|
|
194
|
+
"FieldBinding",
|
|
195
|
+
"Attribution",
|
|
196
|
+
"Degree",
|
|
197
|
+
"Computed",
|
|
198
|
+
"ComputedTarget",
|
|
199
|
+
"ComputedWrite",
|
|
200
|
+
"FieldMarker",
|
|
201
|
+
"FieldSubclassing",
|
|
202
|
+
"fold",
|
|
203
|
+
"Formatter",
|
|
204
|
+
"Fulfils",
|
|
205
|
+
"hooks",
|
|
206
|
+
"IncomingFrom",
|
|
207
|
+
"initialise",
|
|
208
|
+
"Cites",
|
|
209
|
+
"KeepOnMerge",
|
|
210
|
+
"MergeRules",
|
|
211
|
+
"Items",
|
|
212
|
+
"LabelTemplate",
|
|
213
|
+
"LiteralCodec",
|
|
214
|
+
"ValueNotMigrated",
|
|
215
|
+
"Match",
|
|
216
|
+
"ModelRegistry",
|
|
217
|
+
"NonHeritableTrait",
|
|
218
|
+
"Not",
|
|
219
|
+
"OrderBy",
|
|
220
|
+
"PanglossAwaitingInitialisation",
|
|
221
|
+
"PanglossBulkLoadError",
|
|
222
|
+
"PanglossBulkRecordError",
|
|
223
|
+
"PanglossClassChangeError",
|
|
224
|
+
"PanglossConflictError",
|
|
225
|
+
"PanglossEntityInUseError",
|
|
226
|
+
"PanglossImportError",
|
|
227
|
+
"PanglossInitialisationError",
|
|
228
|
+
"PanglossInstructionError",
|
|
229
|
+
"PanglossInternalError",
|
|
230
|
+
"PanglossMergeBusyError",
|
|
231
|
+
"PanglossCitedError",
|
|
232
|
+
"PanglossMergedError",
|
|
233
|
+
"PanglossMergeError",
|
|
234
|
+
"PanglossMergeNotAllowedError",
|
|
235
|
+
"PanglossMergeTooLargeError",
|
|
236
|
+
"PanglossMetaError",
|
|
237
|
+
"PanglossMigrationAnswerNeeded",
|
|
238
|
+
"PanglossMigrationError",
|
|
239
|
+
"PanglossMigrationIrreversible",
|
|
240
|
+
"PanglossMigrationNotSupported",
|
|
241
|
+
"PanglossModelError",
|
|
242
|
+
"PanglossModelWarning",
|
|
243
|
+
"PanglossNotCreatableError",
|
|
244
|
+
"PanglossNotDeletableError",
|
|
245
|
+
"PanglossNotDeletedError",
|
|
246
|
+
"PanglossNotFoundError",
|
|
247
|
+
"PanglossReadOnlyError",
|
|
248
|
+
"PanglossReferenceError",
|
|
249
|
+
"PanglossRuntimeError",
|
|
250
|
+
"PanglossSearchError",
|
|
251
|
+
"PanglossSearchTimeoutError",
|
|
252
|
+
"PanglossServerOnly",
|
|
253
|
+
"PanglossUnknownTypeError",
|
|
254
|
+
"PanglossUserDisabledError",
|
|
255
|
+
"PanglossUserNotFoundError",
|
|
256
|
+
"PanglossVersionConflictError",
|
|
257
|
+
"PanglossWriteError",
|
|
258
|
+
"PanglossWriteRefused",
|
|
259
|
+
"before_create",
|
|
260
|
+
"before_update",
|
|
261
|
+
"nodes_of",
|
|
262
|
+
"whole_write",
|
|
263
|
+
"classes_stood_for",
|
|
264
|
+
"create_validator",
|
|
265
|
+
"read_validator",
|
|
266
|
+
"update_validator",
|
|
267
|
+
"Protection",
|
|
268
|
+
"Usage",
|
|
269
|
+
"included_only_when_referenced",
|
|
270
|
+
"protection",
|
|
271
|
+
"usage",
|
|
272
|
+
"protection_of",
|
|
273
|
+
"register_meta_slot",
|
|
274
|
+
"ReifiedRelation",
|
|
275
|
+
"register_codec",
|
|
276
|
+
"register_label_formatter",
|
|
277
|
+
"ReifiedRelationDocument",
|
|
278
|
+
"Rel",
|
|
279
|
+
"RelationConfig",
|
|
280
|
+
"SemanticNonHeritableTrait",
|
|
281
|
+
"SemanticSpace",
|
|
282
|
+
"spaces",
|
|
283
|
+
"SemanticTrait",
|
|
284
|
+
"server_only",
|
|
285
|
+
"SumsTo",
|
|
286
|
+
"Text",
|
|
287
|
+
"Through",
|
|
288
|
+
"Trait",
|
|
289
|
+
"Var",
|
|
290
|
+
"ViaEdge",
|
|
291
|
+
"ViaItem",
|
|
292
|
+
"Where",
|
|
293
|
+
"WriteEvent",
|
|
294
|
+
]
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""Finding existing entities by their label, over any set of entity types (see implementation_docs/autocomplete.md).
|
|
2
|
+
|
|
3
|
+
The types asked for are named (`resolve_entity_types`), and reduced to as few as will find the same
|
|
4
|
+
entities (`smallest_types`): a node has the name of each of its parents and traits as a label, so a
|
|
5
|
+
class that is a subclass of another one asked for finds nothing more.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import re
|
|
9
|
+
from collections.abc import Sequence
|
|
10
|
+
from typing import Any
|
|
11
|
+
from uuid import UUID
|
|
12
|
+
|
|
13
|
+
from pydantic import AnyHttpUrl
|
|
14
|
+
|
|
15
|
+
from pangloss_models.exceptions import PanglossUnknownTypeError
|
|
16
|
+
from pangloss_models.model_bases.base_models import _BaseObject
|
|
17
|
+
from pangloss_models.model_bases.document import Document
|
|
18
|
+
from pangloss_models.model_bases.entity import Entity
|
|
19
|
+
from pangloss_models.model_bases.labels import labels_for_model
|
|
20
|
+
from pangloss_models.text import fold
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AutocompleteItem(_BaseObject):
|
|
24
|
+
id: UUID | AnyHttpUrl
|
|
25
|
+
type: str
|
|
26
|
+
label: str
|
|
27
|
+
# If it was found by the label of an entity that was merged into it (`Entity.merge`), and not by its own: that label
|
|
28
|
+
merged_label: str | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AutocompleteResults(_BaseObject):
|
|
32
|
+
"""One page of what was found, with the paging fields of a list"""
|
|
33
|
+
|
|
34
|
+
results: list[AutocompleteItem]
|
|
35
|
+
count: int
|
|
36
|
+
page: int
|
|
37
|
+
page_size: int
|
|
38
|
+
next_page: int | None
|
|
39
|
+
previous_page: int | None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def resolve_entity_types(names: list[str]) -> list[type]:
|
|
43
|
+
"""The classes named, each once, in the order given. A name that is not an entity (or a trait
|
|
44
|
+
that only entities have) raises `PanglossUnknownTypeError`."""
|
|
45
|
+
from pangloss_models.model_registry import ModelRegistry
|
|
46
|
+
from pangloss_models.utils import get_concrete_types, model_is_trait
|
|
47
|
+
|
|
48
|
+
models = ModelRegistry.all_models()
|
|
49
|
+
found: list[type] = []
|
|
50
|
+
for name in names:
|
|
51
|
+
if name == "Entity": # (any entity)
|
|
52
|
+
found.append(Entity)
|
|
53
|
+
continue
|
|
54
|
+
model = models.get(name)
|
|
55
|
+
if model is None:
|
|
56
|
+
raise PanglossUnknownTypeError(f"There is no model called '{name}'")
|
|
57
|
+
if model_is_trait(model): # type: ignore[arg-type]
|
|
58
|
+
implementing = get_concrete_types(model, include_abstract=True) # type: ignore[type-var]
|
|
59
|
+
ok = bool(implementing) and all(issubclass(t, Entity) for t in implementing)
|
|
60
|
+
else:
|
|
61
|
+
ok = isinstance(model, type) and issubclass(model, Entity)
|
|
62
|
+
if not ok:
|
|
63
|
+
raise PanglossUnknownTypeError(
|
|
64
|
+
f"'{name}' is not an entity type: only entities can be found by their label"
|
|
65
|
+
)
|
|
66
|
+
if model not in found:
|
|
67
|
+
found.append(model)
|
|
68
|
+
return found
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def smallest_types(types: Sequence[type]) -> list[type]:
|
|
72
|
+
"""The types that find everything the given ones do: those that are not a subclass (or an
|
|
73
|
+
application of the trait) of another one in the list"""
|
|
74
|
+
result = []
|
|
75
|
+
for model in types:
|
|
76
|
+
# (a trait has no kind, and its labels are its own and those of the traits it extends)
|
|
77
|
+
labels = labels_for_model(model, getattr(model, "__metatype__", "")) # type: ignore
|
|
78
|
+
if any(other is not model and other.__name__ in labels for other in types):
|
|
79
|
+
continue
|
|
80
|
+
result.append(model)
|
|
81
|
+
return result
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def search_words(text: str) -> list[str]:
|
|
85
|
+
"""What was typed as the words of the text index: lower case, accents folded (`pangloss_models.text.fold`), cut at
|
|
86
|
+
anything that is not a letter or digit. (That is how the index cuts a label, so no punctuation, and no
|
|
87
|
+
regular-expression character, is left to be matched.)"""
|
|
88
|
+
return re.findall(r"\w+", fold(text))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def labels_to_match(types: Sequence[type]) -> list[str]:
|
|
92
|
+
"""The node labels, any of which finds the entities of these types"""
|
|
93
|
+
return [model.__name__ for model in smallest_types(types)]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def excluded_from_global_search() -> list[str]:
|
|
97
|
+
"""The names of the classes that "search everything" does not find (`global_search=False`)"""
|
|
98
|
+
from pangloss_models.model_registry import ModelRegistry
|
|
99
|
+
|
|
100
|
+
return sorted(
|
|
101
|
+
name
|
|
102
|
+
for name, model in ModelRegistry.all_models().items()
|
|
103
|
+
if isinstance(model, type)
|
|
104
|
+
and issubclass(model, (Document, Entity))
|
|
105
|
+
and not model._meta.global_search # type: ignore[attr-defined]
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def search_everything(
|
|
110
|
+
search_terms: str,
|
|
111
|
+
types: Sequence[type] | None = None,
|
|
112
|
+
page_number: int | None = None,
|
|
113
|
+
page_size: int | None = None,
|
|
114
|
+
documents_only: bool = False,
|
|
115
|
+
) -> Any:
|
|
116
|
+
"""The head documents and entities whose label has every word (of `types` and their subclasses, if given), the most
|
|
117
|
+
connected first (with no words, all of `types`; without those too, nothing); what is awaited on a backend that is async. See implementation_docs/homepage-and-pages.md.
|
|
118
|
+
`documents_only`: no entities (what a citation is chosen from)"""
|
|
119
|
+
from pangloss_core import storage_of
|
|
120
|
+
|
|
121
|
+
return storage_of().operations.search_everything(
|
|
122
|
+
search_terms,
|
|
123
|
+
labels_to_match(types) if types else None,
|
|
124
|
+
excluded_from_global_search(),
|
|
125
|
+
page_number,
|
|
126
|
+
page_size,
|
|
127
|
+
documents_only=documents_only,
|
|
128
|
+
)
|