Skip to content

Commit ac45fe7

Browse files
committed
Organize divisions pkg, add missing relationships, tidy and add docs
This commit organizes the divisions Pydantic package to align with the other packages that have been done so far: addresses, base, buildings, and places. After this commit there remains only: transportation and core (the latter will soon be renamed common). Organization work done: 1. Common code into `_common.py`. 2. Each feature type gets its own main module, e.g., `division.py`. 3. Types used exclusively by a feature type into that feature type's main module, regardless of whether the type is an enum, model, NewType, etc. 4. Eliminate sub-directories. 5. Curate `__all__` in `__init__.py`. Missing relationships added: 1. `CapitalOfItem` 2. `HierarchyItem` 3. `parent_division_id` in `Division` 4. `capital_division_ids` in `Division` Getting this to work required extending the list of relationships in the system package's `ref.py`. (On this, note, that Tristan will likely shrink it back to managable size when he rationalizes the relationships.) It also required solving an issue with Python forward references being in the Pydantic field annotations for `CapitalOfItem` and `HierarchyItem`, which was breaking codegen. I fixed this issue by using `.model_rebuild()` on both models, see `divisions.py`. Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to divisions. 2. Converted several enums to `DocumentedEnum` so they can have a richer presence in the schema reference. 3. Added missing docstrings and `Field(description="...")` annotations. 4. Edited and refined some of the documentation wording where it wasn't fully up to standard. 5. Wrapped long doc/desc lines using `textwrap.dedent("...").strip()` so the docs are easier to read and edit in a code editor. Signed-off-by: schapper <schapper@amazon.com>
1 parent b8664f2 commit ac45fe7

34 files changed

Lines changed: 1074 additions & 776 deletions

File tree

packages/overture-schema-base-theme/src/overture/schema/base/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"LandSubtype",
3737
"LandUse",
3838
"LandUseClass",
39-
"LandUseSubtype"
39+
"LandUseSubtype",
4040
"SourceTags",
4141
"SurfaceMaterial",
4242
"Water",

packages/overture-schema-base-theme/tests/bathymetry_baseline_schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@
214214
"properties": {
215215
"cartography": {
216216
"$ref": "#/$defs/CartographicHints",
217-
"title": "cartography"
217+
"description": "Cartographic hints useful when including the feature in maps"
218218
},
219219
"depth": {
220220
"description": "Depth below surface level of the feature in meters.",

packages/overture-schema-base-theme/tests/infrastructure_baseline_schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,8 @@
630630
"type": "integer"
631631
},
632632
"names": {
633-
"$ref": "#/$defs/Names"
633+
"$ref": "#/$defs/Names",
634+
"description": "All known names by which the feature is called"
634635
},
635636
"source_tags": {
636637
"additionalProperties": true,

packages/overture-schema-base-theme/tests/land_baseline_schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@
505505
"type": "integer"
506506
},
507507
"names": {
508-
"$ref": "#/$defs/Names"
508+
"$ref": "#/$defs/Names",
509+
"description": "All known names by which the feature is called"
509510
},
510511
"source_tags": {
511512
"additionalProperties": true,

packages/overture-schema-base-theme/tests/land_cover_baseline_schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
"properties": {
232232
"cartography": {
233233
"$ref": "#/$defs/CartographicHints",
234-
"title": "cartography"
234+
"description": "Cartographic hints useful when including the feature in maps"
235235
},
236236
"sources": {
237237
"description": "Information about the source data used to assemble the feature.",

packages/overture-schema-base-theme/tests/land_use_baseline_schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,8 @@
582582
"type": "integer"
583583
},
584584
"names": {
585-
"$ref": "#/$defs/Names"
585+
"$ref": "#/$defs/Names",
586+
"description": "All known names by which the feature is called"
586587
},
587588
"source_tags": {
588589
"additionalProperties": true,

packages/overture-schema-base-theme/tests/water_baseline_schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,8 @@
469469
"type": "integer"
470470
},
471471
"names": {
472-
"$ref": "#/$defs/Names"
472+
"$ref": "#/$defs/Names",
473+
"description": "All known names by which the feature is called"
473474
},
474475
"source_tags": {
475476
"additionalProperties": true,

packages/overture-schema-buildings-theme/tests/building_baseline_schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@
560560
"type": "number"
561561
},
562562
"names": {
563-
"$ref": "#/$defs/Names"
563+
"$ref": "#/$defs/Names",
564+
"description": "All known names by which the feature is called"
564565
},
565566
"num_floors": {
566567
"description": "Number of above-ground floors of the building or part.",

packages/overture-schema-buildings-theme/tests/building_part_baseline_schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@
444444
"type": "number"
445445
},
446446
"names": {
447-
"$ref": "#/$defs/Names"
447+
"$ref": "#/$defs/Names",
448+
"description": "All known names by which the feature is called"
448449
},
449450
"num_floors": {
450451
"description": "Number of above-ground floors of the building or part.",

packages/overture-schema-codegen/tests/test_type_placement.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,6 @@ def test_supplementary_types_nested_under_types(self) -> None:
132132
"buildings/types/building_class.md"
133133
)
134134

135-
def test_submodule_supplementary_types_nested_under_types(self) -> None:
136-
"""Supplementary types in a feature subdirectory go under types/."""
137-
specs = flat_specs_from_discovery("divisions")
138-
registry, _ = _build_registry(specs)
139-
140-
# AreaClass is from overture.schema.divisions.division_area.enums,
141-
# a subdirectory of the divisions feature directory.
142-
assert lookup_by_name(registry, "AreaClass") == PurePosixPath(
143-
"divisions/types/division_area/area_class.md"
144-
)
145-
146135
def test_shared_types_not_nested(self) -> None:
147136
"""Core/system supplementary types stay at their module-mirrored path."""
148137
specs = flat_specs_from_discovery("buildings")

0 commit comments

Comments
 (0)