You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have installed aws-lambda-powertools without any optional dependencies and am not using any parser features. I expect to be able to use Batch Processor without any errors.
When including BatchProcessor to process SQS Records (without Models) batch/base.py imports "ValidationError" from parser which requires the "pydantic" dependency and breaks the optional constraint.
Current Behaviour
ModuleNotFoundError: No module named 'pydantic'
Code snippet
importjsonfromaws_lambda_powertoolsimportLogger, Tracerfromaws_lambda_powertools.utilities.batchimportBatchProcessor, EventType, process_partial_responsefromaws_lambda_powertools.utilities.parser.modelsimportSqsRecordModelfromaws_lambda_powertools.utilities.typingimportLambdaContextfromaws_lambda_powertools.utilities.parserimportBaseModelfromaws_lambda_powertools.utilities.parser.typesimportJsonclassOrder(BaseModel):
item: dictclassOrderSqsRecord(SqsRecordModel):
body: Json[Order] # deserialize order data from JSON stringprocessor=BatchProcessor(event_type=EventType.SQS, model=OrderSqsRecord)
tracer=Tracer()
logger=Logger()
@tracer.capture_methoddefrecord_handler(record: OrderSqsRecord):
returnrecord.body.item@logger.inject_lambda_context@tracer.capture_lambda_handlerdeflambda_handler(event, context: LambdaContext):
returnprocess_partial_response(event=event, record_handler=record_handler, processor=processor, context=context)
Possible Solution
remove line 29. Change Exception handling to use String Comparison instead to detect ValidationError so works whether Pydantic is available or not?
Expected Behaviour
I have installed aws-lambda-powertools without any optional dependencies and am not using any parser features. I expect to be able to use Batch Processor without any errors.
When including BatchProcessor to process SQS Records (without Models) batch/base.py imports "ValidationError" from parser which requires the "pydantic" dependency and breaks the optional constraint.
Current Behaviour
ModuleNotFoundError: No module named 'pydantic'
Code snippet
Possible Solution
remove line 29. Change Exception handling to use String Comparison instead to detect ValidationError so works whether Pydantic is available or not?
e.g.
Instead of:
Perhaps:
Steps to Reproduce
AWS Lambda Powertools for Python version
latest
AWS Lambda function runtime
3.9
Packaging format used
PyPi
Debugging logs
The text was updated successfully, but these errors were encountered: