def from_aws_lambda_event(self, event: AwsLambdaEvent) -> InferenceTask[FileLike]: headers = HTTPHeaders.from_dict(event.get('headers', {})) if headers.content_type == "text/csv": f = FileLike(bytes_=event["body"].encode(), name="input.csv") else: # Optimistically assuming Content-Type to be "application/json" f = FileLike(bytes_=event["body"].encode(), name="input.json") return InferenceTask(aws_lambda_event=event, data=f,)
def from_aws_lambda_event(self, event: AwsLambdaEvent) -> InferenceTask[BinaryIO]: parsed_headers = ParsedHeaders.parse(tuple(event.get('headers', {}).items())) if parsed_headers.content_type == "text/csv": bio = io.BytesIO(event["body"].encode()) bio.name = "input.csv" else: # Optimistically assuming Content-Type to be "application/json" bio = io.BytesIO(event["body"].encode()) bio.name = "input.json" return InferenceTask(aws_lambda_event=event, data=bio,)
def from_aws_lambda_event(self, event: AwsLambdaEvent) -> MultiFileTask: request = HTTPRequest( headers=tuple((k, v) for k, v in event.get('headers', {}).items()), body=event['body'], ) return self.from_http_request(request)
def from_aws_lambda_event( self, event: AwsLambdaEvent) -> InferenceTask[BinaryIO]: return InferenceTask( context=InferenceContext(aws_lambda_event=event), data=io.BytesIO(base64.decodebytes(event.get('body', ""))), )
def from_aws_lambda_event(self, event: AwsLambdaEvent) -> InferenceTask[str]: return InferenceTask( aws_lambda_event=event, data=event.get('body', ""), )
def from_aws_lambda_event(self, event: AwsLambdaEvent) -> InferenceTask[bytes]: return InferenceTask( aws_lambda_event=event, data=event.get('body', "").encode(JSON_CHARSET), )
def from_aws_lambda_event( self, event: AwsLambdaEvent) -> InferenceTask[FileLike]: f = FileLike(bytes_=base64.decodebytes(event.get('body', ""))) return InferenceTask(aws_lambda_event=event, data=f)