[REFACTOR] Organize transportation theme Pydantic package, add relationships, sync JSON Schema, and tidy docs - #598
Conversation
🗺️ Schema reference docs preview is live!
Note ♻️ This preview updates automatically with each push to this PR. |
527465a to
2358544
Compare
|
While reading through this I noticed Lines 852 to 857 in 2358544 Feel free to change, however the guide has broader staleness that predates this PR such as the |
Seth Fitzsimmons (sethfitz)
left a comment
There was a problem hiding this comment.
Looks good other than the silly backticks (for a follow-up?).
|
Thanks — filed as #604 so it doesn't ride along here. I confirmed both halves: the entry point keys are unqualified ( |
8601994
2358544 to
8601994
Compare
This is a good find - thanks. I think the right call is just to update it now, so I did that. |
8601994 to
12fbc5d
Compare
5d9aab7
12fbc5d to
5d9aab7
Compare
5d9aab7 to
2360c75
Compare
This commit organizes the transportation Pydantic package to align with the other theme packages already done: addresses, base, buildings, divisions, and places. Transportation was the last theme still using the old layout, so with this commit the whole theme set is organized consistently. Organization work done: 1. Each feature type gets its own main module. `connector` becomes a flat `connector.py`, but because `segment` is a discriminated union over road, rail, and water subtypes, `segment` becomes a *package* with one module per subtype (`road.py`, `rail.py`, `water.py`) plus a private `_common.py` for the shared base. This is the one place we do NOT eliminate a sub-directory (unlike divisions): the subtype union makes a package the natural fit. 2. Types used exclusively by one subtype move into that subtype's module and are renamed to be subtype-scoped: `Subtype` -> `SegmentSubtype`, `Subclass` -> `RoadSubclass`, `SubclassRule` -> `RoadSubclassRule`, `SurfaceRule` -> `RoadSurfaceRule`, `AccessRestrictionRule` -> `AccessRule`, `SequenceEntry` -> `ProhibitedTransitionSequenceEntry`. Exception (deliberate): the mode-independent rule types currently used only by road but conceivably reusable by other subtypes (the prohibited-transition, speed, and width types) are kept in `_common.py`. 3. Eliminated the old flat `enums.py`, `models.py`, and `types.py`, and the `connector/` and `segment/` (models.py) sub-packages. 4. Curated `__all__` in both the theme `__init__.py` and the segment package's `__init__.py`. Relationships added: 1. `from_connector_id` and `to_connector_id` in `DestinationRule` (to `Connector`). 2. `to_segment_id` in `DestinationRule` (to `TransportationSegment`). 3. `connector_id` in `ProhibitedTransitionSequenceEntry` (to `Connector`). 4. `segment_id` in `ProhibitedTransitionSequenceEntry` (to `TransportationSegment`). Docs tidied and updated: 1. Eliminated all `make docformat` errors pertaining to transportation. 2. Converted `SegmentSubtype` and `AccessType` to `DocumentedEnum` so they have a richer presence in the schema reference. (`RoadSurface` and `DestinationLabelType` are intentionally left as plain enums for now, as I don't have cycles to generate docs for them.) Schema reconciliation (a dimension the divisions refactor did not have): 1. Made `routes` and `subclass_rules` road-only (moved from the shared base to `RoadSegment`) and back-ported the change to the JSON Schema so both representations agree. While technically backwardly- incompatible, this fixes a error that dates back to the JSON Schema and that was never intended. 2. Removed the scalar `level` from segment in both the Pydantic model and the JSON Schema, finishing the model/schema sync begun in "Remove levels from types without data for them" (commit dd5d3f2, PR #390), which updated the model but left `level` on the legacy JSON Schema, leading to a discrepancy between schemas. Signed-off-by: schapper <schapper@amazon.com>
2360c75 to
81c1f74
Compare
Description
This brings us closer to the end of the Pydantic package organization journey: transportation was the last theme package still on the old layout. With this PR every theme package—addresses, base, buildings, divisions, places, and now transportation —is organized consistently.
Transportation differs from the earlier themes in three ways. First,
segmentis a discriminated union over road/rail/water subtypes, so it becomes a small package rather than a single module. Second, this PR makes a couple of technically backwardly-incompatible, but in practice not really, changes to the transportation segment feature to push down a few fields that have been wrongly defined at the segment level down to the level of the road segment:routesandsubclass_rules. Third, this change back ports a few changes on to the old legacy JSON Schema to keep it in sync-ish until we delete it. The back-ported changes are the two already mentioned plus removinglevelfromsegmentto close the loop on a change Seth Fitzsimmons (@sethfitz) made in PR #390.tl;dr
segmentbecomes a package (road.py,rail.py,water.py+ a private_common.pyfor the shared base);connectorbecomes a flat module.DestinationRuleandProhibitedTransitionSequenceEntry.routesandsubclass_rulesroad-only (back-ported to the JSON Schema), and removed the scalarlevelfrom JSON Schema since [Pydantic] housekeeping #390 removed it from the Pydantic schema.make docformatclean, convertedSegmentSubtype/AccessTypetoDocumentedEnum, and documented the previously-undefineddesignatedaccess type.Merge guidance: Squash
The work is captured as a single squashed commit, so this PR should be squash-merged.
Journey
-coreto-common— PR [REFACTOR] Rename-corepackage to-commonto remove a source of confusion #520Testing
make checkpasses (lint, mypy, doctest, and the full test suite). JSON Schema baselines were regenerated to reflect the reconciled model.Documentation website
Docs preview for this PR.
Related Issues
Closes #599.