I’ve got models which inherit Pydantic’s BaseModel and I use this to define my model attributes and do some validation.
But I see that Lambda Powertools comes with a Parser module which uses Pydantic.
Now that I want to use these models within an AWS lambda execution, is there a benefit to using:
from aws_lambda_powertools.utilities.parser import BaseModel
Instead of sticking with my existing
from pydantic import BaseModel
I can see that the Powertools Parser comes with a useful BaseEnvelope - but is BaseModel in Powertools any different?
And as a followup, if there is a benefit, could I monkey patch within the lambda runtime so I can:
- Keep my models independent of anything Lambda like.
- Spare myself from changing all the imports.
CodePudding user response:
You don't have to update your imports. AWS Lambda Powertools's BaseModel is just a re-export of Pydantic's BaseModel.