This commit is contained in:
2026-05-02 14:03:48 +03:30
parent f704e1188c
commit ef593153ba
14 changed files with 1286 additions and 18 deletions
+27 -4
View File
@@ -10,9 +10,20 @@ from .growth_simulation import (
)
def build_yield_prediction_payload(*, farm_uuid: str, plant_name: str | None = None) -> dict[str, Any]:
def build_yield_prediction_payload(
*,
farm_uuid: str,
plant_name: str | None = None,
irrigation_recommendation: dict[str, Any] | None = None,
fertilization_recommendation: dict[str, Any] | None = None,
) -> dict[str, Any]:
simulator = CurrentFarmChartSimulator()
result = simulator.simulate(farm_uuid=farm_uuid, plant_name=plant_name)
result = simulator.simulate(
farm_uuid=farm_uuid,
plant_name=plant_name,
irrigation_recommendation=irrigation_recommendation,
fertilization_recommendation=fertilization_recommendation,
)
yield_estimate = float((result.get("metrics") or {}).get("yield_estimate") or 0.0)
predicted_yield_tons = round(max(yield_estimate / 1000.0, 0.0), 2)
return {
@@ -31,8 +42,20 @@ def build_yield_prediction_payload(*, farm_uuid: str, plant_name: str | None = N
class YieldPredictionService:
def get_yield_prediction(self, *, farm_uuid: str, plant_name: str | None = None) -> dict[str, Any]:
def get_yield_prediction(
self,
*,
farm_uuid: str,
plant_name: str | None = None,
irrigation_recommendation: dict[str, Any] | None = None,
fertilization_recommendation: dict[str, Any] | None = None,
) -> dict[str, Any]:
try:
return build_yield_prediction_payload(farm_uuid=farm_uuid, plant_name=plant_name)
return build_yield_prediction_payload(
farm_uuid=farm_uuid,
plant_name=plant_name,
irrigation_recommendation=irrigation_recommendation,
fertilization_recommendation=fertilization_recommendation,
)
except GrowthSimulationError:
raise