Skip to content

Commit 55bb64e

Browse files
authored
feat(release)!: dependency upgrades and new colormap (#461)
### Changed - Python 3.9 to 3.11 upgrade - Pydantic>2 and associated package upgrades ### Breaking - Pydantic upgrades require migrating pgstac version to 0.8.5 ### Added - New custom surface temperature colormap (`st_cmap`) added to raster api
2 parents b95f3fd + 4480b3a commit 55bb64e

File tree

40 files changed

+225
-166
lines changed

40 files changed

+225
-166
lines changed

.github/actions/cdk-deploy/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ runs:
2121
- name: Set up Python
2222
uses: actions/setup-python@v5
2323
with:
24-
python-version: '3.9'
24+
python-version: '3.11'
2525
cache: 'pip'
2626
cache-dependency-path: |
2727
${{ inputs.dir }}/setup.py

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- name: Set up Python
1111
uses: actions/setup-python@v5
1212
with:
13-
python-version: '3.9'
13+
python-version: '3.11'
1414

1515
- uses: actions/cache@v4
1616
with:
@@ -48,7 +48,7 @@ jobs:
4848
- name: Set up Python
4949
uses: actions/setup-python@v5
5050
with:
51-
python-version: '3.9'
51+
python-version: '3.11'
5252

5353
- uses: actions/cache@v4
5454
with:
@@ -102,7 +102,7 @@ jobs:
102102
- name: Set up Python
103103
uses: actions/setup-python@v5
104104
with:
105-
python-version: '3.9'
105+
python-version: '3.11'
106106

107107
- name: Setup Node
108108
uses: actions/setup-node@v4

common/auth/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from setuptools import find_packages, setup
55

6-
inst_reqs = ["cryptography>=42.0.5", "pyjwt>=2.8.0", "fastapi", "pydantic<2"]
6+
inst_reqs = ["cryptography>=42.0.5", "pyjwt>=2.8.0", "fastapi", "pydantic"]
77

88
setup(
99
name="veda_auth",

config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
from getpass import getuser
33
from typing import List, Optional
44

5-
from pydantic import BaseSettings, Field, constr
5+
from pydantic import Field, constr
6+
from pydantic_settings import BaseSettings
67

7-
AwsSubnetId = constr(regex=r"^subnet-[a-z0-9]{17}$")
8+
AwsSubnetId = constr(pattern=r"^subnet-[a-z0-9]{17}$")
89

910

1011
class vedaAppSettings(BaseSettings):
@@ -146,6 +147,7 @@ class Config:
146147
"""model config."""
147148

148149
env_file = ".env"
150+
extra = "ignore"
149151

150152

151153
veda_app_settings = vedaAppSettings()

database/infrastructure/config.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
from typing import Optional
33

44
from aws_cdk import aws_ec2, aws_rds
5-
from pydantic import BaseSettings, Field, validator
5+
from pydantic import Field, field_validator
6+
from pydantic_settings import BaseSettings
67

78

89
class vedaDBSettings(BaseSettings):
@@ -42,17 +43,17 @@ class vedaDBSettings(BaseSettings):
4243
max_locks_per_transaction: Optional[str] = Field(
4344
"1024",
4445
description="Number of database objects that can be locked simultaneously",
45-
regex=r"^[1-9]\d*$",
46+
pattern=r"^[1-9]\d*$",
4647
)
4748
work_mem: Optional[str] = Field(
4849
"64000",
4950
description="Maximum amount of memory to be used by a query operation before writing to temporary disk files",
50-
regex=r"^[1-9]\d*$",
51+
pattern=r"^[1-9]\d*$",
5152
)
5253
temp_buffers: Optional[str] = Field(
5354
"32000",
5455
description="maximum number of temporary buffers used by each session",
55-
regex=r"^[1-9]\d*$",
56+
pattern=r"^[1-9]\d*$",
5657
)
5758
use_rds_proxy: Optional[bool] = Field(
5859
False,
@@ -64,13 +65,15 @@ class vedaDBSettings(BaseSettings):
6465
"The instance class of the RDS instance "
6566
"https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/InstanceClass.html"
6667
),
68+
validate_default=True,
6769
)
6870
rds_instance_size: Optional[str] = Field(
6971
aws_ec2.InstanceSize.SMALL.value,
7072
description=(
7173
"The size of the RDS instance "
7274
"https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/InstanceSize.html"
7375
),
76+
validate_default=True,
7477
)
7578
rds_engine_full_version: Optional[str] = Field(
7679
aws_rds.PostgresEngineVersion.VER_14.postgres_full_version,
@@ -91,14 +94,14 @@ class vedaDBSettings(BaseSettings):
9194
description="Boolean if the RDS should be encrypted",
9295
)
9396

94-
@validator("rds_instance_class", pre=True, always=True)
97+
@field_validator("rds_instance_class", mode="before")
9598
def convert_rds_class_to_uppercase(cls, value):
9699
"""Convert to uppercase."""
97100
if isinstance(value, str):
98101
return value.upper()
99102
return value
100103

101-
@validator("rds_instance_size", pre=True, always=True)
104+
@field_validator("rds_instance_size", mode="before")
102105
def convert_rds_size_to_uppercase(cls, value):
103106
"""Convert to uppercase."""
104107
if isinstance(value, str):
@@ -110,6 +113,7 @@ class Config:
110113

111114
env_file = ".env"
112115
env_prefix = "VEDA_DB_"
116+
extra = "ignore"
113117

114118

115119
veda_db_settings = vedaDBSettings()

database/infrastructure/construct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def __init__(
4848
self,
4949
"lambda",
5050
handler="handler.handler",
51-
runtime=aws_lambda.Runtime.PYTHON_3_9,
51+
runtime=aws_lambda.Runtime.PYTHON_3_11,
5252
code=aws_lambda.Code.from_docker_build(
5353
path=os.path.abspath("./"),
5454
file="database/runtime/Dockerfile",
5555
build_args={"PGSTAC_VERSION": pgstac_version},
5656
),
57-
timeout=Duration.minutes(2),
57+
timeout=Duration.minutes(5),
5858
vpc=database.vpc,
5959
log_retention=aws_logs.RetentionDays.ONE_WEEK,
6060
)

database/runtime/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=linux/amd64 public.ecr.aws/sam/build-python3.9:latest
1+
FROM --platform=linux/amd64 public.ecr.aws/sam/build-python3.11:latest
22

33
ARG PGSTAC_VERSION
44
RUN echo "Using PGSTAC Version ${PGSTAC_VERSION}"

docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ services:
129129
- PGDATABASE=postgis
130130
- DYNAMODB_ENDPOINT=http://localhost:8085
131131
- VEDA_DB_PGSTAC_VERSION=0.7.10
132+
- AWS_REGION=us-west-2
133+
- AWS_DEFAULT_REGION=us-west-2
134+
- DYNAMODB_TABLE=veda
135+
- STAC_URL=http://0.0.0.0:8081
136+
- USERPOOL_ID=us-west-2_123456789
137+
- CLIENT_ID=123456789
132138
ports:
133139
- "8083:8083"
134140
command: bash -c "bash /tmp/scripts/wait-for-it.sh -t 120 -h database -p 5432 && python /asset/local.py"

ingest_api/infrastructure/config.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from typing import List, Optional
33

44
import aws_cdk
5-
from pydantic import AnyHttpUrl, BaseSettings, Field, constr
5+
from pydantic import AnyHttpUrl, Field, StringConstraints
6+
from pydantic_settings import BaseSettings, SettingsConfigDict
7+
from typing_extensions import Annotated
68

7-
AwsArn = constr(regex=r"^arn:aws:iam::\d{12}:role/.+")
9+
AwsArn = Annotated[str, StringConstraints(pattern=r"^arn:aws:iam::\d{12}:role/.+")]
810

911

1012
class IngestorConfig(BaseSettings):
@@ -92,11 +94,9 @@ class IngestorConfig(BaseSettings):
9294
False,
9395
description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false.",
9496
)
95-
96-
class Config:
97-
case_sensitive = False
98-
env_file = ".env"
99-
env_prefix = "VEDA_"
97+
model_config = SettingsConfigDict(
98+
case_sensitive=False, env_file=".env", env_prefix="VEDA_", extra="ignore"
99+
)
100100

101101
@property
102102
def stack_name(self) -> str:

ingest_api/infrastructure/construct.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def __init__(
5252
"RASTER_URL": config.veda_raster_api_cf_url,
5353
"ROOT_PATH": config.ingest_root_path,
5454
"STAGE": config.stage,
55-
"COGNITO_DOMAIN": config.cognito_domain,
55+
"COGNITO_DOMAIN": str(config.cognito_domain),
5656
}
5757

5858
build_api_lambda_params = {
@@ -149,7 +149,7 @@ def build_api_lambda(
149149
platform="linux/amd64",
150150
build_args={"PGSTAC_VERSION": pgstac_version},
151151
),
152-
runtime=aws_lambda.Runtime.PYTHON_3_9,
152+
runtime=aws_lambda.Runtime.PYTHON_3_11,
153153
timeout=Duration.seconds(30),
154154
handler="handler.handler",
155155
role=handler_role,
@@ -307,7 +307,7 @@ def build_ingestor(
307307
build_args={"PGSTAC_VERSION": pgstac_version},
308308
),
309309
handler="ingestor.handler",
310-
runtime=aws_lambda.Runtime.PYTHON_3_9,
310+
runtime=aws_lambda.Runtime.PYTHON_3_11,
311311
timeout=Duration.seconds(180),
312312
environment={"DB_SECRET_ARN": db_secret.secret_arn, **env},
313313
vpc=db_vpc,

0 commit comments

Comments
 (0)