Repository navigation
[REFACTOR] Organize common package for consistency #603
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
Merged
Merged
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
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
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
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
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
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
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
45 changes: 40 additions & 5 deletions
45
packages/overture-schema-common/src/overture/schema/common/__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 |
|---|---|---|
| @@ -1,15 +1,50 @@ | ||
| from . import cartography, names, scoping, sources | ||
| from .models import OvertureFeature, ThemeT, TypeT | ||
| from .scoping import Scope, scoped | ||
| """ | ||
| Shared building blocks common to all Overture theme packages. | ||
|
|
||
| The `OvertureFeature` base class and the reusable feature components — naming, sources, | ||
| cartographic hints, scoping, and more — that theme packages compose to define their | ||
| feature types. | ||
|
|
||
| Subpackages | ||
| ----------- | ||
| - :mod:`cartography <overture.schema.common.cartography>` Cartographic display hints. | ||
| - :mod:`confidence <overture.schema.common.confidence>` The `ConfidenceScore` type. | ||
| - :mod:`feature <overture.schema.common.feature>` The `OvertureFeature` base class and its | ||
| supporting types (`FeatureVersion`, `ThemeT`, `TypeT`). | ||
| - :mod:`level <overture.schema.common.level>` Feature Z-order / stacking (`Level`, `Stacked`). | ||
| - :mod:`names <overture.schema.common.names>` Multilingual naming with variants and rules. | ||
| - :mod:`perspectives <overture.schema.common.perspectives>` Political perspectives on disputed | ||
| data. | ||
| - :mod:`scoping <overture.schema.common.scoping>` Scoped, conditionally-applicable field values. | ||
| - :mod:`sources <overture.schema.common.sources>` Data provenance and source attribution. | ||
| - :mod:`unit <overture.schema.common.unit>` Units of measure. | ||
| """ | ||
|
|
||
| from . import ( | ||
| cartography, | ||
| confidence, | ||
| feature, | ||
| level, | ||
| names, | ||
| perspectives, | ||
| scoping, | ||
| sources, | ||
| unit, | ||
| ) | ||
| from .feature import FeatureVersion, OvertureFeature, ThemeT, TypeT | ||
|
|
||
| __all__ = [ | ||
| "cartography", | ||
| "confidence", | ||
| "feature", | ||
| "FeatureVersion", | ||
| "level", | ||
| "names", | ||
| "OvertureFeature", | ||
| "Scope", | ||
| "scoped", | ||
| "perspectives", | ||
| "scoping", | ||
| "sources", | ||
| "ThemeT", | ||
| "TypeT", | ||
| "unit", | ||
| ] | ||
17 changes: 17 additions & 0 deletions
17
packages/overture-schema-common/src/overture/schema/common/confidence.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,17 @@ | ||
| """ | ||
| Confidence scores for machine-generated or machine-augmented data. | ||
| """ | ||
|
vcschapp marked this conversation as resolved.
|
||
|
|
||
| from typing import Annotated, NewType | ||
|
|
||
| from pydantic import Field | ||
|
|
||
| from overture.schema.system.numeric import float64 | ||
|
|
||
| ConfidenceScore = NewType( | ||
| "ConfidenceScore", | ||
| Annotated[ | ||
| float64, | ||
| Field(description="Confidence score between 0.0 and 1.0", ge=0.0, le=1.0), | ||
| ], | ||
| ) | ||
8 changes: 0 additions & 8 deletions
8
packages/overture-schema-common/src/overture/schema/common/enums.py
This file was deleted.
Oops, something went wrong.
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
23 changes: 23 additions & 0 deletions
23
packages/overture-schema-common/src/overture/schema/common/level.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,23 @@ | ||
| """ | ||
| Z-order stacking. | ||
| """ | ||
|
|
||
| from typing import Annotated, NewType | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
| from overture.schema.system.numeric import int32 | ||
|
|
||
| Level = NewType( | ||
| "Level", | ||
| Annotated[ | ||
| int32, | ||
| Field(description="Z-order of the feature where 0 is visual level"), | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| class Stacked(BaseModel): | ||
| """Properties defining feature Z-order, i.e., stacking order.""" | ||
|
|
||
| level: Level | None = 0 # type: ignore[assignment] |
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
40 changes: 40 additions & 0 deletions
40
packages/overture-schema-common/src/overture/schema/common/perspectives.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,40 @@ | ||
| """ | ||
| Political perspectives. | ||
| """ | ||
|
vcschapp marked this conversation as resolved.
|
||
|
|
||
| from enum import Enum | ||
| from typing import Annotated | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
| from overture.schema.system.field_constraint import UniqueItemsConstraint | ||
| from overture.schema.system.model_constraint import no_extra_fields | ||
| from overture.schema.system.string import CountryCodeAlpha2 | ||
|
|
||
|
|
||
| class PerspectiveMode(str, Enum): | ||
| """Perspective mode for disputed names.""" | ||
|
|
||
| ACCEPTED_BY = "accepted_by" | ||
| DISPUTED_BY = "disputed_by" | ||
|
|
||
|
|
||
| @no_extra_fields | ||
| class Perspectives(BaseModel): | ||
| """Political perspectives container.""" | ||
|
|
||
| # Required | ||
|
|
||
| mode: Annotated[ | ||
| PerspectiveMode, | ||
| Field( | ||
| description="Whether the perspective holder accepts or disputes this name." | ||
| ), | ||
| ] | ||
| countries: Annotated[ | ||
| list[CountryCodeAlpha2], | ||
| Field( | ||
| min_length=1, description="Countries holding the given mode of perspective." | ||
| ), | ||
| UniqueItemsConstraint(), | ||
| ] | ||
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
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
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.