diff --git a/cdr_schemas/area_extraction.py b/cdr_schemas/area_extraction.py index 0365c86..3426b4e 100644 --- a/cdr_schemas/area_extraction.py +++ b/cdr_schemas/area_extraction.py @@ -41,19 +41,17 @@ class Area_Extraction(BaseModel): The type of area extraction. """, ) - text: Optional[str] = Field( - default=None, + text: str = Field( + default="", description=""" The text within the extraction area. """, ) # Model Provenance - model: Optional[str] = Field( - default=None, description="Name of the model used to generate this data" - ) - model_version: Optional[str] = Field( - default=None, description="Version of the model used to generate this data" + model: str = Field(description="Name of the model used to generate this data") + model_version: str = Field( + description="Version of the model used to generate this data" ) model_config = ConfigDict(protected_namespaces=()) confidence: Optional[Union[float | int]] = Field( diff --git a/cdr_schemas/common.py b/cdr_schemas/common.py index 784e4ee..a19bee1 100644 --- a/cdr_schemas/common.py +++ b/cdr_schemas/common.py @@ -19,11 +19,9 @@ class GeoJsonType(str, Enum): class ModelProvenance(BaseModel): - model: Optional[str] = Field( - default=None, description="Name of the model used to generate this data" - ) - model_version: Optional[str] = Field( - default=None, description="Version of the model used to generate this data" + model: str = Field(description="Name of the model used to generate this data") + model_version: str = Field( + description="Version of the model used to generate this data" ) model_config = ConfigDict(protected_namespaces=()) confidence: Optional[Union[float | int]] = Field( diff --git a/cdr_schemas/document.py b/cdr_schemas/document.py index 5646bde..9f494ae 100644 --- a/cdr_schemas/document.py +++ b/cdr_schemas/document.py @@ -20,12 +20,8 @@ class DocumentProvenance(BaseModel): external_system_name: str = Field( ..., description="Name of system storing document" ) - external_system_id: Optional[str] = Field( - "", description="The system ID of the document" - ) - external_system_url: Optional[str] = Field( - "", description="Name of system storing document" - ) + external_system_id: str = Field("", description="The system ID of the document") + external_system_url: str = Field("", description="Name of system storing document") class UploadDocument(BaseModel): diff --git a/cdr_schemas/features/line_features.py b/cdr_schemas/features/line_features.py index e885204..2052a35 100644 --- a/cdr_schemas/features/line_features.py +++ b/cdr_schemas/features/line_features.py @@ -36,11 +36,9 @@ class LineProperty(BaseModel): """ # Model Provenance - model: Optional[str] = Field( - default=None, description="Name of the model used to generate this data" - ) - model_version: Optional[str] = Field( - default=None, description="Version of the model used to generate this data" + model: str = Field(description="Name of the model used to generate this data") + model_version: str = Field( + description="Version of the model used to generate this data" ) model_config = ConfigDict(protected_namespaces=()) confidence: Optional[Union[float | int]] = Field( @@ -51,9 +49,7 @@ class LineProperty(BaseModel): dash_pattern: Optional[DashType] = Field( default=None, description="values = {solid, dash, dotted}" ) - symbol: Optional[str] = Field( # TODO add description - default=None, description="TODO : Add description" - ) + symbol: str = Field(default="", description="TODO : Add description") class LineFeature(BaseModel): @@ -96,14 +92,12 @@ class LineLegendAndFeaturesResult(BaseModel): legend_provenance: Optional[ModelProvenance] = Field( default=None, description="Where the data originated from." ) - name: Optional[str] = Field( - default=None, description="Label of the map unit in the legend" - ) - abbreviation: Optional[str] = Field( - default=None, description="Abbreviation of the map unit label." + name: str = Field(default="", description="Label of the map unit in the legend") + abbreviation: str = Field( + default="", description="Abbreviation of the map unit label." ) - description: Optional[str] = Field( - default=None, description="Description of the map unit in the legend" + description: str = Field( + default="", description="Description of the map unit in the legend" ) legend_bbox: List[Union[float, int]] = Field( default_factory=list, @@ -119,14 +113,14 @@ class LineLegendAndFeaturesResult(BaseModel): ) # Segmentation Fields - crs: Optional[str] = Field( + crs: str = Field( default=CRITICALMAAS_PIXEL, description="""What projection the geometry of the segmentation are in, Default is CRITICALMAAS_PIXEL which specifies pixel coordinates. Possible values are {CRITICALMAAS_PIXEL, EPSG:*}""", ) - cdr_projection_id: Optional[str] = Field( - default=None, + cdr_projection_id: str = Field( + default="", description="""If non-pixel coordinates are used the cdr projection id of the georeference that was used to create them is required.""", ) diff --git a/cdr_schemas/features/point_features.py b/cdr_schemas/features/point_features.py index 44f3d15..bbcd856 100644 --- a/cdr_schemas/features/point_features.py +++ b/cdr_schemas/features/point_features.py @@ -28,11 +28,9 @@ class PointProperties(BaseModel): """ # Model Provenance - model: Optional[str] = Field( - default=None, description="Name of the model used to generate this data" - ) - model_version: Optional[str] = Field( - default=None, description="Version of the model used to generate this data" + model: str = Field(description="Name of the model used to generate this data") + model_version: str = Field( + description="Version of the model used to generate this data" ) model_config = ConfigDict(protected_namespaces=()) confidence: Optional[Union[float | int]] = Field( @@ -94,14 +92,12 @@ class PointLegendAndFeaturesResult(BaseModel): legend_provenance: Optional[ModelProvenance] = Field( default=None, description="Where the data originated from." ) - name: Optional[str] = Field( - default=None, description="Label of the map unit in the legend" - ) - abbreviation: Optional[str] = Field( - default=None, description="Abbreviation of the map unit label." + name: str = Field(description="Label of the map unit in the legend") + abbreviation: str = Field( + default="", description="Abbreviation of the map unit label." ) - description: Optional[str] = Field( - default=None, description="Description of the map unit in the legend" + description: str = Field( + default="", description="Description of the map unit in the legend" ) legend_bbox: List[Union[float, int]] = Field( default_factory=list, @@ -117,14 +113,14 @@ class PointLegendAndFeaturesResult(BaseModel): ) # Segmentation Fields - crs: Optional[str] = Field( + crs: str = Field( default=CRITICALMAAS_PIXEL, description="""What projection the geometry of the segmentation are in, Default is CRITICALMAAS_PIXEL which specifies pixel coordinates. Possible values are {CRITICALMAAS_PIXEL, EPSG:*}""", ) - cdr_projection_id: Optional[str] = Field( - default=None, + cdr_projection_id: str = Field( + default="", description="""If non-pixel coordinates are used the cdr projection id of the georeference that was used to create them is required.""", ) diff --git a/cdr_schemas/features/polygon_features.py b/cdr_schemas/features/polygon_features.py index ff1e408..aadad7e 100644 --- a/cdr_schemas/features/polygon_features.py +++ b/cdr_schemas/features/polygon_features.py @@ -28,12 +28,8 @@ class PolygonProperty(BaseModel): Properties of the polygon. """ - model: Optional[str] = Field( - default=None, description="Name of the model used for extraction" - ) - model_version: Optional[str] = Field( - default=None, description="Version of the model used for extraction" - ) + model: str = Field(description="Name of the model used for extraction") + model_version: str = Field(description="Version of the model used for extraction") confidence: Optional[Union[float | int]] = Field( default=None, description="The prediction confidence of the model" ) @@ -75,14 +71,14 @@ class MapUnit(BaseModel): """ # TODO Someone needs to add full descriptions to these fields - age_text: Optional[str] = None + age_text: str = "" b_age: Optional[float] = None - b_interval: Optional[str] = None - lithology: Optional[str] = None - name: Optional[str] = None + b_interval: str = "" + lithology: str = "" + name: str = "" t_age: Optional[float] = None - t_interval: Optional[str] = None - comments: Optional[str] = None + t_interval: str = "" + comments: str = "" class PolygonLegendAndFeaturesResult(BaseModel): @@ -97,13 +93,11 @@ class PolygonLegendAndFeaturesResult(BaseModel): legend_provenance: Optional[ModelProvenance] = Field( default=None, description="Where the data originated from." ) - label: Optional[str] = Field(default=None, description="Label of the map unit") - abbreviation: Optional[str] = Field( - default=None, description="Abbreviation of the map unit label." - ) - description: Optional[str] = Field( - default=None, description="Description of the map unit" + label: str = Field(description="Label of the map unit") + abbreviation: str = Field( + default="", description="Abbreviation of the map unit label." ) + description: str = Field(default="", description="Description of the map unit") legend_bbox: List[Union[float, int]] = Field( default_factory=list, description="""The rough 2 point bounding box of the map units label. @@ -116,25 +110,23 @@ class PolygonLegendAndFeaturesResult(BaseModel): label. Format is expected to be [x,y] coordinate pairs where the top left is the origin (0,0).""", ) - color: Optional[str] = Field(default=None, description="The color of the map unit") - pattern: Optional[str] = Field( - default=None, description="The pattern of the map unit" - ) + color: str = Field(default="", description="The color of the map unit") + pattern: str = Field(default="", description="The pattern of the map unit") ### TODO Agreed on Apr 15th call that category can be removed - category: Optional[str] = Field(default=None, description="TODO - what is this?") + category: str = Field(default="", description="TODO - what is this?") map_unit: Optional[MapUnit] = Field( default=None, description="Human annotated information on the map unit" ) # Segmentation Fields - crs: Optional[str] = Field( + crs: str = Field( default=CRITICALMAAS_PIXEL, description="""What projection the geometry of the segmentation are in, Default is CRITICALMAAS_PIXEL which specifies pixel coordinates. Possible values are {CRITICALMAAS_PIXEL, EPSG:*}""", ) - cdr_projection_id: Optional[str] = Field( - default=None, + cdr_projection_id: str = Field( + default="", description="""If non-pixel coordinates are used the cdr projection id of the georeference that was used to create them is required.""", ) diff --git a/cdr_schemas/georeference.py b/cdr_schemas/georeference.py index 4b7b09a..7e70ead 100644 --- a/cdr_schemas/georeference.py +++ b/cdr_schemas/georeference.py @@ -88,7 +88,7 @@ class GroundControlPoint(BaseModel): The version of the model. """, ) - crs: Optional[str] = Field( + crs: str = Field( ..., description=""" Coordinate reference system. i.e. "EPSG:4267" diff --git a/cdr_schemas/metadata.py b/cdr_schemas/metadata.py index 9ce49d8..ae07260 100644 --- a/cdr_schemas/metadata.py +++ b/cdr_schemas/metadata.py @@ -20,8 +20,8 @@ class MapColorSchemeTypes(str, Enum): class MapMetaData(BaseModel): - title: Optional[str] = Field( - default=None, + title: str = Field( + default="", description=""" Title of the map/cog. """, @@ -32,8 +32,8 @@ class MapMetaData(BaseModel): Year the map was made. i.e. 2012 """, ) - crs: Optional[str] = Field( - default=None, + crs: str = Field( + default="", description=""" CRS of the map. i.e. "EPSG:4267" """, @@ -44,8 +44,8 @@ class MapMetaData(BaseModel): Authors of the map """, ) - organization: Optional[str] = Field( - default=None, + organization: str = Field( + default="", description=""" Organization that created the map """, @@ -56,8 +56,8 @@ class MapMetaData(BaseModel): Scale of the map. 24000 would be equivalent to 1:24000 """, ) - quadrangle_name: Optional[str] = Field( - default=None, + quadrangle_name: str = Field( + default="", description=""" If map is based on a quadrangle location we can save the name here. """, @@ -74,8 +74,8 @@ class MapMetaData(BaseModel): Color scheme of the map. """, ) - publisher: Optional[str] = None - state: Optional[str] = None + publisher: str = "" + state: str = "" model: str model_version: str diff --git a/cdr_schemas/mineral.py b/cdr_schemas/mineral.py index 3c34120..070cdf7 100644 --- a/cdr_schemas/mineral.py +++ b/cdr_schemas/mineral.py @@ -21,13 +21,13 @@ class ResourceReserveCategory(Enum): class GeologyInfo(BaseModel): - age: Optional[str] = Field(description="Age of the geologic unit or event") - unit_name: Optional[str] = Field(description="Name of the geologic unit") - description: Optional[str] + age: str = Field(default="", description="Age of the geologic unit or event") + unit_name: str = Field(default="", description="Name of the geologic unit") + description: str = "" lithology: List[str] = Field(default_factory=list, description="Lithology") process: List[str] = Field(default_factory=list, description="Process") environment: List[str] = Field(default_factory=list, description="environment") - comments: Optional[str] + comments: str = "" class Ore(BaseModel): @@ -87,7 +87,7 @@ class EvidenceLayer(BaseModel): class MappableCriteria(BaseModel): criteria: str - theoretical: Optional[str] + theoretical: str = "" potential_dataset: list[EvidenceLayer] = Field( default_factory=list, description="List of evidence layers" ) @@ -125,8 +125,9 @@ class Grade(BaseModel): class MineralInventory(BaseModel): commodity: Commodity = Field(description="The commodity of an inventory item") - observed_commodity: Optional[str] = Field( - description="The observed commodity in the source data (textual format)" + observed_commodity: str = Field( + default="", + description="The observed commodity in the source data (textual format)", ) category: Optional[ResourceReserveCategory] = Field( description="The category of an inventory item" @@ -143,8 +144,9 @@ class MineralInventory(BaseModel): date: Optional[datetime] = Field( description="When in the point of time mineral inventory valid" ) - zone: Optional[str] = Field( - description="zone of mineral site where inventory item was discovered" + zone: str = Field( + default="", + description="zone of mineral site where inventory item was discovered", ) @@ -155,7 +157,9 @@ class LocationInfo(BaseModel): crs: str = Field( description="The Coordinate Reference System (CRS) of the location" ) - country: Optional[str] = Field(description="Country that the mine site resides in") + country: str = Field( + default="", description="Country that the mine site resides in" + ) state_or_province: Optional[str] = Field( description="State or province that the mine site resides in" ) @@ -168,7 +172,7 @@ class MineralSite(BaseModel): record_id: str = Field( description="Unique ID of the record that the info is retrieved from e.g., 10022920" ) - name: Optional[str] = Field(description="Name of the mine, e.g., Tungsten Jim") + name: str = Field(default="", description="Name of the mine, e.g., Tungsten Jim") mineral_inventory: list[MineralInventory] location_info: LocationInfo geology_info: Optional[GeologyInfo] diff --git a/tests/test_area_extraction.py b/tests/test_area_extraction.py index 6b71e6c..93c2289 100644 --- a/tests/test_area_extraction.py +++ b/tests/test_area_extraction.py @@ -14,6 +14,8 @@ def test_area_extraction_1(): test_2 = { + "model_version": "0.0.1", + "model": "jataware_extraction", "coordinates": [[[2, 3, 5, 6]]], "category": "point_legend_area", "text": "hi", diff --git a/tests/test_georeference.py b/tests/test_georeference.py index 474d24d..d425a49 100644 --- a/tests/test_georeference.py +++ b/tests/test_georeference.py @@ -25,7 +25,7 @@ [[443, 852], [5648, 852], [5648, 7869], [443, 7869], [443, 852]] ], "model": "jataware_extraction", - "text": None, + "text": "", "type": "Polygon", "category": "map_area", }, @@ -144,7 +144,7 @@ def test_gcp_1(): test_4 = { "model_version": "0.0.1", - "crs": None, + "crs": "", "map_geom": {"latitude": 43.25, "longitude": None}, "px_geom": {"rows_from_top": 7210, "columns_from_left": 542}, "model": "jataware_extraction", diff --git a/tests/test_point_extraction.py b/tests/test_point_extraction.py index 4f5917c..0c93188 100644 --- a/tests/test_point_extraction.py +++ b/tests/test_point_extraction.py @@ -5,13 +5,14 @@ "id": "1", "legend_provenance": {"model": "test", "model_version": "1", "confidence": 0}, "label": "nickel_deposit", + "name": "nickel_deposit", "map_unit": None, "legend_bbox": [1, 2, 3, 4], "abbreviation": "ni_deposit", "description": "nickel deposit description", } -def test_poly_extraction_1(): +def test_point_extraction_1(): results = PointLegendAndFeaturesResult(**test_1).model_dump_json() PointLegendAndFeaturesResult.model_validate_json(results) @@ -20,6 +21,7 @@ def test_poly_extraction_1(): test_2 = { "id": "1", "cdr_projection_id": "1234alksdfjslakfjd", + "name": "", "point_features": { "features": [ { @@ -32,6 +34,6 @@ def test_poly_extraction_1(): } # extraction info only -def test_poly_extraction_2(): +def test_point_extraction_2(): results = PointLegendAndFeaturesResult(**test_2).model_dump_json() PointLegendAndFeaturesResult.model_validate_json(results) \ No newline at end of file diff --git a/tests/test_polygon_extraction.py b/tests/test_polygon_extraction.py index ac17006..75ca5ae 100644 --- a/tests/test_polygon_extraction.py +++ b/tests/test_polygon_extraction.py @@ -20,6 +20,7 @@ def test_poly_extraction_1(): test_2 = { "id": "1", "cdr_projection_id": "1234alksdfjslakfjd", + "label": "nickel", "polygon_features": { "features": [ {