Esempio n. 1
0
 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,)
Esempio n. 2
0
 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,)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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', ""))),
     )
Esempio n. 5
0
 def from_aws_lambda_event(self,
                           event: AwsLambdaEvent) -> InferenceTask[str]:
     return InferenceTask(
         aws_lambda_event=event,
         data=event.get('body', ""),
     )
Esempio n. 6
0
 def from_aws_lambda_event(self,
                           event: AwsLambdaEvent) -> InferenceTask[bytes]:
     return InferenceTask(
         aws_lambda_event=event,
         data=event.get('body', "").encode(JSON_CHARSET),
     )
Esempio n. 7
0
 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)