aws / sagemaker-huggingface-inference-toolkit

Apache License 2.0
221 stars 60 forks source link

How to access CustomAttributes in async inferece request input_fn #89

Open dcdieci opened 1 year ago

dcdieci commented 1 year ago

I need to access CustomAttributes in async request.

I tried to access it inside a custom input_fn

def input_fn(self, input_data, content_type):

self.context coud give access to custom properties

but I am not sure about this

        try:
            if not self.initialized:
                self.initialize(context)

(I am new to python). But this looks like it would instantiate the class once and fill the context once, so it would not get update on each request with the additional context params i guess?!

anyhow. it looks like self will not be accessible inside def input_fn(self, input_data, content_type): hence no access to additional params. @philschmid Any idea about how to access additional CustomAttributes ?

dcdieci commented 1 year ago

ideally the context will be passed on a per request base

processed_data = self.preprocess(input_data, content_type, context)

https://github.com/aws/sagemaker-huggingface-inference-toolkit/blob/2237804030f15157f932adfca86f9b06e04f244c/src/sagemaker_huggingface_inference_toolkit/handler_service.py#L188