Hello, I've been following <this> guide, trying to...
# ask-for-help
f
Hello, I've been following this guide, trying to adapt it to my use case. Sadly, whenever I try to make a request I get the following error:
input_df = pd.DataFrame([input_data.dict(exclude={"request_id"})])
AttributeError: 'InferenceApiContext' object has no attribute 'dict'
It seems as though the input isn't being treated as a Json object, but I have no idea what I'm doing wrong. My service code:
input_spec = JSON(pydantic_model = MMRT_Features)
@mmrt_service.api(input=input_spec, output=JSON())
def predict(self, input_data) -> Dict[str, Any]:
# Define pre-processing logic
input_df = pd.DataFrame([input_data.dict(exclude={"request_id"})])
# Get prediction
result = estimator_runner.predict.run(input_df)
return {"Something": result}
If I add the input type like shown in the docs
def predict(self, input_data: MMRT_Features) -> Dict[str, Any]:
then the service won't start anymore giving me the error:
TypeError: Expected type of argument 'input_data' to be 'typing.Union[str, typing.Dict[str, typing.Any], ForwardRef('pydantic.BaseModel'), NoneType]', got '<class 'service.MMRT_Features'>'