-
Notifications
You must be signed in to change notification settings - Fork 11
[WIP] Opening Hours Extension Proof-of-Concept DO NOT MERGE #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jenningsanderson
wants to merge
1
commit into
dev
Choose a base branch
from
opening-hours-extension
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # overture-schema-extensions | ||
|
|
||
| Overture Maps schema extensions with additional feature properties like operating hours. | ||
|
|
||
| ## Overview | ||
|
|
||
| This package provides a simple extension model that contains just an ID and operating hours information. Unlike full Overture features, this model doesn't require geometry, version, theme, or other standard feature fields, making it perfect for datasets that only need to associate operating hours with IDs. | ||
|
|
||
| ## Features | ||
|
|
||
| ### ExtendedFeature | ||
|
|
||
| A simple model with just two fields: | ||
|
|
||
| **Fields:** | ||
|
|
||
| - `id`: Unique identifier (required, inherited from the `Identified` mixin) | ||
| - `operating_hours`: Operating hours specification (optional) | ||
|
|
||
| ### OperatingHours | ||
|
|
||
| A structured model for operating hours information: | ||
|
|
||
| - `primary`: Primary operating hours (required string, e.g., `"Mo-Fr 09:00-17:00; Sa 10:00-14:00"`) | ||
|
|
||
| ## Installation | ||
|
|
||
| This package is part of the Overture Maps schema workspace. Install it using: | ||
|
|
||
| ```bash | ||
| uv pip install overture-schema-extensions | ||
| ``` | ||
|
|
||
| Or include it in your project dependencies: | ||
|
|
||
| ```toml | ||
| [project] | ||
| dependencies = [ | ||
| "overture-schema-extensions", | ||
| ] | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Basic Example | ||
|
|
||
| ```python | ||
| from overture.schema.extensions import ExtendedFeature, OperatingHours | ||
|
|
||
| # Create a simple feature with just ID and operating hours | ||
| feature = ExtendedFeature( | ||
| id="example-123", | ||
| operating_hours=OperatingHours( | ||
| primary="Mo-Fr 09:00-17:00; Sa 10:00-14:00" | ||
| ) | ||
| ) | ||
|
|
||
| # You can also create a feature with just an ID | ||
| minimal_feature = ExtendedFeature(id="example-456") | ||
| ``` | ||
|
|
||
| ### JSON Schema Generation | ||
|
|
||
| Generate JSON Schema for validation: | ||
|
|
||
| ```python | ||
| import json | ||
| from overture.schema.extensions import ExtendedFeature | ||
|
|
||
| schema = ExtendedFeature.model_json_schema() | ||
| print(json.dumps(schema, indent=2)) | ||
| ``` | ||
|
|
||
| ### Validation | ||
|
|
||
| The models use Pydantic for automatic validation: | ||
|
|
||
| ```python | ||
| from overture.schema.extensions import ExtendedFeature | ||
|
|
||
| # This will raise validation errors if required fields are missing | ||
| # or if field values don't match constraints | ||
| try: | ||
| feature = ExtendedFeature( | ||
| id="test", | ||
| operating_hours=OperatingHours(primary="Mo-Fr 09:00-17:00") | ||
| ) | ||
| print("Valid feature!") | ||
| except ValueError as e: | ||
| print(f"Validation error: {e}") | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ### Running Tests | ||
|
|
||
| ```bash | ||
| uv run pytest packages/overture-schema-extensions/ | ||
| ``` | ||
|
|
||
| ### Type Checking | ||
|
|
||
| The package includes a `py.typed` marker for full type hint support: | ||
|
|
||
| ```bash | ||
| mypy src/overture/schema/extensions/ | ||
| ``` | ||
|
|
||
| ## Use Cases | ||
|
|
||
| This package is ideal for: | ||
|
|
||
| - **Lightweight datasets**: When you only need to track operating hours by ID, without full geospatial features | ||
| - **Operating hours updates**: Maintaining a separate dataset of operating hours that can be joined with full feature data | ||
| - **Simple extensions**: Demonstrating how to create minimal Pydantic models that reuse Overture's ID system | ||
|
|
||
| ## Schema Patterns | ||
|
|
||
| This package follows the Overture Maps Pydantic schema conventions: | ||
|
|
||
| - Uses `@no_extra_fields` decorator for strict validation | ||
| - Follows the `OvertureFeature[ThemeT, TypeT]` generic pattern | ||
| - Uses `Annotated` types with `Field()` for descriptions and constraints | ||
| - All optional fields default to `None` (never non-None defaults) | ||
| - Numeric types use specific primitives (`int32`, `float64`, etc.) | ||
|
|
||
| For more information on schema patterns, see the [Pydantic Guide](../../PYDANTIC_GUIDE.md). | ||
|
|
||
| ## License | ||
|
|
||
| MIT License - See LICENSE file for details. | ||
|
|
||
| ## Related Packages | ||
|
|
||
| - `overture-schema-core`: Base classes and common structures | ||
| - `overture-schema-system`: Primitives, constraints, and validation | ||
| - `overture-schema-places-theme`: Places features (inspiration for operating hours) | ||
| - `overture-schema-buildings-theme`: Buildings features | ||
|
|
||
| ## Contributing | ||
|
|
||
| This package demonstrates how to create simple extensions to the Overture Maps schema: | ||
|
|
||
| 1. Inherit from `Identified` to get the `id` field (instead of full `OvertureFeature`) | ||
| 2. Add custom fields with proper annotations and descriptions | ||
| 3. Create supporting models with `@no_extra_fields` decorator | ||
| 4. Register your feature in `pyproject.toml` entry points | ||
|
|
||
| This approach lets you create lightweight models that don't require all the standard Overture feature fields like geometry, version, theme, and type. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| [project] | ||
| dependencies = [ | ||
| "overture-schema-core", | ||
| "overture-schema-places-theme", | ||
| "pydantic>=2.0", | ||
| ] | ||
| description = "Overture Maps places extended with operating hours support" | ||
| dynamic = ["version"] | ||
| license = "MIT" | ||
| name = "overture-schema-extensions" | ||
| readme = "README.md" | ||
| requires-python = ">=3.10" | ||
|
|
||
| [tool.uv.sources] | ||
| overture-schema-core = { workspace = true } | ||
| overture-schema-places-theme = { workspace = true } | ||
|
|
||
| [build-system] | ||
| build-backend = "hatchling.build" | ||
| requires = ["hatchling"] | ||
|
|
||
| [tool.hatch.version] | ||
| path = "src/overture/schema/extensions/__about__.py" | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["src/overture"] | ||
|
|
||
| [project.entry-points."overture.models"] | ||
| "extensions.entity_with_operating_hours" = "overture.schema.extensions:EntityWithOperatingHours" | ||
| "extensions.place_with_operating_hours" = "overture.schema.extensions:PlaceWithOperatingHours" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Overture namespace package.""" |
1 change: 1 addition & 0 deletions
1
packages/overture-schema-extensions/src/overture/schema/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Overture schema namespace package.""" |
3 changes: 3 additions & 0 deletions
3
packages/overture-schema-extensions/src/overture/schema/extensions/__about__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| """Version information for overture-schema-extensions.""" | ||
|
|
||
| __version__ = "0.1.0" |
21 changes: 21 additions & 0 deletions
21
packages/overture-schema-extensions/src/overture/schema/extensions/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """Overture schema extensions package.""" | ||
|
|
||
| from .models import ( | ||
| DayOfWeek, | ||
| EntityWithOperatingHours, | ||
| HourSet, | ||
| HourSetStatus, | ||
| OperatingHours, | ||
| PlaceWithOperatingHours, | ||
| Rule, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "DayOfWeek", | ||
| "EntityWithOperatingHours", | ||
| "HourSet", | ||
| "HourSetStatus", | ||
| "OperatingHours", | ||
| "PlaceWithOperatingHours", | ||
| "Rule", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name for this decorator --
@no_extra_fields-- could be confusing for builders. Are we asking them to make clear which properties are core? I can address this in the main Pydantic packages for schema