UPDATE
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user