autotraderuk / fastapi-mlflow

Deploy mlflow models as JSON APIs with minimal new code
Apache License 2.0
19 stars 4 forks source link

Improve error handling for missing field mappings #10

Closed Andrew-Crosby closed 1 year ago

Andrew-Crosby commented 1 year ago

https://github.com/autotraderuk/fastapi-mlflow/blob/98701a0f5af535ceedda78c07759f5a3b6b62b8e/fastapi_mlflow/_mlflow_types.py#L30

The MLFlow to Python type lookup should use [] rather than .get(...), and throw a descriptive error if the type is not found.

The use of .get(...) masks missing type mappings and instead creates a field of type None leading to cryptic ValidationErrors at request time.

bloomonkey commented 1 year ago

Thanks for the report @Andrew-Crosby

Yes, agree that a start-up time error is probably preferable to a request time error here.

A possible alternative would be to assume that every unmapped type is an object (which might also fix #11 ), though not sure how that would get mapped into JSON... I'll investigate

bloomonkey commented 1 year ago

Will release as 0.4.1, probably next week