mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-08-31 12:46:38 +00:00
fix(server): /v1/prediction/import accepts pydantic-validated DataFrame bodies
A PUT body that pydantic validates as PydanticDateTimeDataFrame (or PydanticDateTimeData) reached json.dumps(data), which cannot serialize BaseModel instances - every such import failed with HTTP 400 "Object of type PydanticDateTimeDataFrame is not JSON serializable". Serialize models via model_dump_json(), keep json.dumps for plain dicts.
This commit is contained in:
@@ -993,7 +993,7 @@ def fastapi_prediction_import_provider(
|
||||
if not provider.enabled() and not force_enable:
|
||||
raise HTTPException(status_code=404, detail=f"Provider '{provider_id}' not enabled.")
|
||||
try:
|
||||
provider.import_from_json(json_str=json.dumps(data))
|
||||
provider.import_from_json(json_str=data.model_dump_json() if hasattr(data, "model_dump_json") else json.dumps(data))
|
||||
provider.update_datetime = to_datetime(in_timezone=get_config().general.timezone)
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user