From aa57acb1a00d8943726df9e1d6ee8bcc03a5b645 Mon Sep 17 00:00:00 2001 From: Logan Byers <5625411+loganbyers@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:28:30 -0500 Subject: [PATCH 1/3] Replace sqlalchemy with vanilla enum module. modified: app/models/enum/versions.py Not known why this relied on sqlalchemy instead of the vanilla enum module. This bring this file into conformance with the rest of the enums. --- app/models/enum/versions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/enum/versions.py b/app/models/enum/versions.py index 817824c14..2520e1548 100644 --- a/app/models/enum/versions.py +++ b/app/models/enum/versions.py @@ -1,4 +1,4 @@ -from sqlalchemy import Enum +from enum import Enum class VersionStatus(str, Enum): From c15e784c9acb18584d33d5be081cd93dac784215 Mon Sep 17 00:00:00 2001 From: Logan Byers <5625411+loganbyers@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:38:01 -0500 Subject: [PATCH 2/3] Use relative imports everywhere. Imports from within the project have been non-standard. This standardizes them to always use relative imports. modified: app/models/enum/assets.py modified: app/models/orm/api_keys.py modified: app/models/pydantic/authentication.py modified: app/models/pydantic/downloads.py modified: app/models/pydantic/extent.py modified: app/models/pydantic/political.py modified: app/models/pydantic/query.py modified: app/models/pydantic/sources.py modified: app/models/pydantic/statistics.py modified: app/models/pydantic/symbology.py --- app/models/enum/assets.py | 2 +- app/models/orm/api_keys.py | 4 ++-- app/models/pydantic/authentication.py | 4 ++-- app/models/pydantic/downloads.py | 6 +++--- app/models/pydantic/extent.py | 2 +- app/models/pydantic/political.py | 6 +++--- app/models/pydantic/query.py | 7 ++++--- app/models/pydantic/sources.py | 2 +- app/models/pydantic/statistics.py | 4 ++-- app/models/pydantic/symbology.py | 4 ++-- 10 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/models/enum/assets.py b/app/models/enum/assets.py index d6435dcac..4f4c7c4e7 100644 --- a/app/models/enum/assets.py +++ b/app/models/enum/assets.py @@ -1,7 +1,7 @@ from enum import Enum from typing import Any, Dict -from app.models.enum.sources import SourceType +from .sources import SourceType class AssetStatus(str, Enum): diff --git a/app/models/orm/api_keys.py b/app/models/orm/api_keys.py index 6993cb533..0a360e56a 100644 --- a/app/models/orm/api_keys.py +++ b/app/models/orm/api_keys.py @@ -1,5 +1,5 @@ -from app.application import db -from app.models.orm.base import Base +from ...application import db +from .base import Base class ApiKey(Base): diff --git a/app/models/pydantic/authentication.py b/app/models/pydantic/authentication.py index bd5cdb713..9ec8ef6cd 100644 --- a/app/models/pydantic/authentication.py +++ b/app/models/pydantic/authentication.py @@ -5,8 +5,8 @@ from fastapi import Query from pydantic import BaseModel, EmailStr -from app.models.pydantic.base import BaseRecord, StrictBaseModel -from app.models.pydantic.responses import Response +from .base import BaseRecord, StrictBaseModel +from .responses import Response class SignUpRequestIn(StrictBaseModel): diff --git a/app/models/pydantic/downloads.py b/app/models/pydantic/downloads.py index aeb654286..dfe403844 100644 --- a/app/models/pydantic/downloads.py +++ b/app/models/pydantic/downloads.py @@ -2,9 +2,9 @@ from pydantic import Field -from app.models.enum.creation_options import Delimiters -from app.models.pydantic.base import StrictBaseModel -from app.models.pydantic.geostore import Geometry +from ..enum.creation_options import Delimiters +from .base import StrictBaseModel +from .geostore import Geometry class DownloadJSONIn(StrictBaseModel): diff --git a/app/models/pydantic/extent.py b/app/models/pydantic/extent.py index fa6ccab13..0cc2d0b6a 100644 --- a/app/models/pydantic/extent.py +++ b/app/models/pydantic/extent.py @@ -1,6 +1,6 @@ from typing import Optional -from ..pydantic.responses import Response +from .responses import Response from .geostore import FeatureCollection diff --git a/app/models/pydantic/political.py b/app/models/pydantic/political.py index aa8682046..2d67627ca 100644 --- a/app/models/pydantic/political.py +++ b/app/models/pydantic/political.py @@ -3,9 +3,9 @@ from fastapi.params import Query from pydantic import Field, root_validator -from app.models.pydantic.base import StrictBaseModel -from app.models.pydantic.responses import Response -from app.settings.globals import ENV, per_env_admin_boundary_versions +from .base import StrictBaseModel +from .responses import Response +from ...settings.globals import ENV, per_env_admin_boundary_versions class AdminIDLookupQueryParams(StrictBaseModel): diff --git a/app/models/pydantic/query.py b/app/models/pydantic/query.py index bfc3e4911..cd9d23865 100644 --- a/app/models/pydantic/query.py +++ b/app/models/pydantic/query.py @@ -1,10 +1,11 @@ from typing import Optional, List -from app.models.enum.creation_options import Delimiters -from app.models.pydantic.base import StrictBaseModel -from app.models.pydantic.geostore import FeatureCollection, Geometry from pydantic import Field +from ..enum.creation_options import Delimiters +from .base import StrictBaseModel +from .geostore import FeatureCollection, Geometry + class QueryRequestIn(StrictBaseModel): geometry: Optional[Geometry] diff --git a/app/models/pydantic/sources.py b/app/models/pydantic/sources.py index 09b190893..02e88ffed 100644 --- a/app/models/pydantic/sources.py +++ b/app/models/pydantic/sources.py @@ -1,6 +1,6 @@ from typing import List, Optional -from app.models.pydantic.base import StrictBaseModel +from .base import StrictBaseModel class Source(StrictBaseModel): diff --git a/app/models/pydantic/statistics.py b/app/models/pydantic/statistics.py index 3d6218c68..b9aaf5686 100644 --- a/app/models/pydantic/statistics.py +++ b/app/models/pydantic/statistics.py @@ -11,8 +11,8 @@ PGTextType, PGType, ) -from ..pydantic.geostore import FeatureCollection -from ..pydantic.responses import Response +from .geostore import FeatureCollection +from .responses import Response from .base import StrictBaseModel diff --git a/app/models/pydantic/symbology.py b/app/models/pydantic/symbology.py index f4a3d9bde..9535ea3b7 100644 --- a/app/models/pydantic/symbology.py +++ b/app/models/pydantic/symbology.py @@ -2,8 +2,8 @@ from pydantic import Field, StrictInt, validator -from app.models.enum.creation_options import ColorMapType -from app.models.pydantic.base import StrictBaseModel +from ..enum.creation_options import ColorMapType +from .base import StrictBaseModel class RGB(StrictBaseModel): From f86d2eae98b1471e78bb6fab6bd246f0677268b9 Mon Sep 17 00:00:00 2001 From: Logan Byers <5625411+loganbyers@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:44:31 -0500 Subject: [PATCH 3/3] Remove PGType from creation_options.py enum file. There have been two PGType classes in `app/models` directory. One came from the `app/models/enum/creation_options.py` file. The other came from the `app/models/enum/pg_types.py` file. The "creation option" PGType does not appear to be used anywhere within the code and is probably some dead code from a refactor... This enum has two fewer Postgres types than the other -- missing the "timestamp_wtz" and "ARRAY" types... This commit removes the "creation option" PGType while keeping the "pg_types" PGType enum in place. modified: app/models/enum/creation_options.py --- app/models/enum/creation_options.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app/models/enum/creation_options.py b/app/models/enum/creation_options.py index 693645fff..da32ebe0f 100644 --- a/app/models/enum/creation_options.py +++ b/app/models/enum/creation_options.py @@ -61,24 +61,6 @@ class PartitionType(str, Enum): range = "range" -class PGType(str, Enum): - bigint = "bigint" - boolean = "boolean" - character_varying = "character varying" - date = "date" - double_precision = "double precision" - geometry = "geometry" - integer = "integer" - jsonb = "jsonb" - numeric = "numeric" - smallint = "smallint" - text = "text" - time = "time" - timestamp = "timestamp" - uuid = "uuid" - xml = "xml" - - class ColorMapType(str, Enum): discrete = "discrete" discrete_intensity = "discrete_intensity"