Skip to content
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

lambdas: bump pydantic to v2 #4355

Merged
merged 4 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lambdas/pkgpush/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ where verb is one of

## Changes

- [Changed] Bump pydantic to v2 ([#4355](https://github.com/quiltdata/quilt/pull/4355))
- [Added] Entrypoint for Quilt Packaging Engine ([#4304](https://github.com/quiltdata/quilt/pull/4304))
- [Fixed] Fix promotion with data copy to unversioned buckets ([#4300](https://github.com/quiltdata/quilt/pull/4300))
- [Changed] Upgrade to Python 3.11 ([#4241](https://github.com/quiltdata/quilt/pull/4241))
Expand Down
9 changes: 7 additions & 2 deletions lambdas/pkgpush/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# pip-compile
#
annotated-types==0.7.0
# via pydantic
attrs==24.2.0
# via
# jsonschema
Expand Down Expand Up @@ -47,15 +49,17 @@ mypy-boto3-sts==1.35.61
# via boto3-stubs
platformdirs==4.3.6
# via quilt3
pydantic==1.10.19
pydantic==2.10.6
# via
# quilt-shared
# t4_lambda_pkgpush (setup.py)
pydantic-core==2.27.2
# via pydantic
python-dateutil==2.9.0.post0
# via botocore
pyyaml==6.0.2
# via quilt3
quilt-shared[boto,pydantic,quilt] @ https://github.com/quiltdata/quilt/archive/438b031534d5c9f92734d8120e69088ae32d8fdb.zip#subdirectory=py-shared
quilt-shared[boto,pydantic,quilt] @ https://github.com/quiltdata/quilt/archive/2818a8f869a6596f7f0833d3259fcb35797afa30.zip#subdirectory=py-shared
# via t4_lambda_pkgpush (setup.py)
quilt3 @ https://github.com/quiltdata/quilt/archive/5c2b79128fe4d5d1e6093ff6a7d11d09d3315843.zip#subdirectory=api/python
# via
Expand Down Expand Up @@ -102,6 +106,7 @@ typing-extensions==4.12.2
# mypy-boto3-s3
# mypy-boto3-sts
# pydantic
# pydantic-core
# quilt-shared
# types-aiobotocore
# types-aiobotocore-s3
Expand Down
4 changes: 2 additions & 2 deletions lambdas/pkgpush/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package_dir={"": "src"},
install_requires=[
"boto3 ~= 1.28",
"pydantic ~= 1.10",
"pydantic ~= 2.10",
"rfc3986 ~= 2.0",
(
"quilt3 @ https://github.com/quiltdata/quilt/archive/"
Expand All @@ -16,7 +16,7 @@
),
(
"quilt_shared[pydantic,boto,quilt] @ https://github.com/quiltdata/quilt/archive/"
"438b031534d5c9f92734d8120e69088ae32d8fdb.zip"
"2818a8f869a6596f7f0833d3259fcb35797afa30.zip"
"#subdirectory=py-shared"
),
],
Expand Down
16 changes: 8 additions & 8 deletions lambdas/pkgpush/src/t4_lambda_pkgpush/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import botocore.client
import botocore.credentials
import botocore.exceptions
import pydantic
import pydantic.v1
import rfc3986

# Must be done before importing quilt3.
Expand Down Expand Up @@ -96,7 +96,7 @@ def from_quilt_exception(cls, qe: quilt3.util.QuiltException):
return cls(name, {"details": qe.message})


def invoke_lambda(*, function_name: str, params: pydantic.BaseModel, err_prefix: str):
def invoke_lambda(*, function_name: str, params: pydantic.v1.BaseModel, err_prefix: str):
resp = lambda_.invoke(
FunctionName=function_name,
Payload=params.json(exclude_defaults=True),
Expand Down Expand Up @@ -225,7 +225,7 @@ def copy_file_list(
get_user_boto_session = boto3.Session


class Event(pydantic.BaseModel):
class Event(pydantic.v1.BaseModel):
credentials: AWSCredentials
params: T.Any

Expand All @@ -242,7 +242,7 @@ def setup_user_boto_session(session):

def auth(f):
@functools.wraps(f)
@pydantic.validate_arguments
@pydantic.v1.validate_arguments
def wrapper(event: Event):
with setup_user_boto_session(get_user_boto_session(**event.credentials.boto_args)):
return f(event.params)
Expand Down Expand Up @@ -270,7 +270,7 @@ def wrapper(event, context):
except PkgpushException as e:
logger.exception("PkgpushException")
return {"error": e.dict()}
except pydantic.ValidationError as e:
except pydantic.v1.ValidationError as e:
# XXX: make it .info()?
logger.exception("ValidationError")
# XXX: expose advanced pydantic error reporting capabilities?
Expand Down Expand Up @@ -392,7 +392,7 @@ def _push_pkg_to_successor(
@exception_handler
@auth
@setup_telemetry
@pydantic.validate_arguments
@pydantic.v1.validate_arguments
def promote_package(params: PackagePromoteParams) -> PackagePushResult:
def get_pkg(src_registry: S3PackageRegistryV1):
quilt3.util.validate_package_name(params.src.name)
Expand Down Expand Up @@ -531,7 +531,7 @@ def create_package(req_file: T.IO[bytes]) -> PackagePushResult:
return PackagePushResult(top_hash=TopHash(top_hash))


class PackagerEvent(pydantic.BaseModel):
class PackagerEvent(pydantic.v1.BaseModel):
source_prefix: str
registry: str | None = None
package_name: str | None = None
Expand All @@ -540,7 +540,7 @@ class PackagerEvent(pydantic.BaseModel):
workflow: str | None = None
commit_message: str | None = None

@pydantic.root_validator
@pydantic.v1.root_validator
def validate_metadata(cls, values):
metadata, metadata_uri = values["metadata"], values["metadata_uri"]
if metadata is not None and metadata_uri is not None:
Expand Down
1 change: 1 addition & 0 deletions lambdas/s3hash/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ where verb is one of

## Changes

- [Changed] Bump pydantic to v2 ([#4355](https://github.com/quiltdata/quilt/pull/4355))
- [Fixed] Fix copy to unversioned buckets ([#4300](https://github.com/quiltdata/quilt/pull/4300))
- [Changed] Upgrade to Python 3.11 ([#4241](https://github.com/quiltdata/quilt/pull/4241))
- [Fixed] Fix invalid checksum for some non-canonical objects with existing checksum ([#4062](https://github.com/quiltdata/quilt/pull/4062))
Expand Down
9 changes: 7 additions & 2 deletions lambdas/s3hash/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ aioitertools==0.12.0
# via aiobotocore
aiosignal==1.3.1
# via aiohttp
annotated-types==0.7.0
# via pydantic
attrs==24.2.0
# via
# aiohttp
Expand Down Expand Up @@ -73,15 +75,17 @@ propcache==0.2.0
# via
# aiohttp
# yarl
pydantic==1.10.19
pydantic==2.10.6
# via
# quilt-shared
# t4_lambda_s3hash (setup.py)
pydantic-core==2.27.2
# via pydantic
python-dateutil==2.9.0.post0
# via botocore
pyyaml==6.0.2
# via quilt3
quilt-shared[boto,pydantic,quilt] @ https://github.com/quiltdata/quilt/archive/438b031534d5c9f92734d8120e69088ae32d8fdb.zip#subdirectory=py-shared
quilt-shared[boto,pydantic,quilt] @ https://github.com/quiltdata/quilt/archive/2818a8f869a6596f7f0833d3259fcb35797afa30.zip#subdirectory=py-shared
# via t4_lambda_s3hash (setup.py)
quilt3==5.4.0
# via quilt-shared
Expand Down Expand Up @@ -126,6 +130,7 @@ typing-extensions==4.12.2
# mypy-boto3-s3
# mypy-boto3-sts
# pydantic
# pydantic-core
# quilt-shared
# types-aiobotocore
# types-aiobotocore-s3
Expand Down
4 changes: 2 additions & 2 deletions lambdas/s3hash/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
install_requires=[
"aiobotocore ~= 2.11",
"botocore ~= 1.31",
"pydantic ~= 1.10",
"pydantic ~= 2.10",
"types-aiobotocore[s3] ~= 2.11",
(
"quilt_shared[pydantic,boto,quilt] @ https://github.com/quiltdata/quilt/archive/"
"438b031534d5c9f92734d8120e69088ae32d8fdb.zip"
"2818a8f869a6596f7f0833d3259fcb35797afa30.zip"
"#subdirectory=py-shared"
),
],
Expand Down
14 changes: 7 additions & 7 deletions lambdas/s3hash/src/t4_lambda_s3hash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import aiobotocore.response
import aiobotocore.session
import botocore.exceptions
import pydantic
import pydantic.v1

from quilt_shared.aws import AWSCredentials
from quilt_shared.lambdas_errors import LambdaError
Expand Down Expand Up @@ -188,7 +188,7 @@ def hash_parts(parts: T.Sequence[bytes]) -> bytes:
return hashlib.sha256(b"".join(parts)).digest()


class PartDef(pydantic.BaseModel):
class PartDef(pydantic.v1.BaseModel):
part_number: int
range: T.Optional[T.Tuple[int, int]]

Expand Down Expand Up @@ -287,7 +287,7 @@ async def compute_part_checksums(
return checksums


class PartUploadResult(pydantic.BaseModel):
class PartUploadResult(pydantic.v1.BaseModel):
etag: str
sha256: str # base64-encoded

Expand All @@ -300,7 +300,7 @@ def boto_args(self):


class MPURef(MPURefBase):
_completed: bool = pydantic.PrivateAttr(default=False)
_completed: bool = pydantic.v1.PrivateAttr(default=False)

@property
def completed(self):
Expand Down Expand Up @@ -370,7 +370,7 @@ def wrapper(event: AnyDict, context: LambdaContext) -> AnyDict:
)
except asyncio.TimeoutError:
raise LambdaError("Timeout")
except pydantic.ValidationError as e:
except pydantic.v1.ValidationError as e:
# XXX: make it .info()?
logger.exception("ValidationError")
# TODO: expose advanced pydantic error reporting capabilities
Expand Down Expand Up @@ -430,7 +430,7 @@ async def compute_checksum(location: S3ObjectSource, scratch_buckets: T.Dict[str

# XXX: move decorators to shared?
@lambda_wrapper
@pydantic.validate_arguments
@pydantic.v1.validate_arguments
async def lambda_handler(
*,
credentials: AWSCredentials,
Expand Down Expand Up @@ -463,7 +463,7 @@ async def copy(location: S3ObjectSource, target: S3ObjectDestination) -> CopyRes

# XXX: move decorators to shared?
@lambda_wrapper
@pydantic.validate_arguments
@pydantic.v1.validate_arguments
async def lambda_handler_copy(
*,
credentials: AWSCredentials,
Expand Down