add tests and types for pipeline interface
This commit is contained in:
@@ -4,12 +4,15 @@ from datetime import datetime as Datetime
|
||||
|
||||
from delta_barth.analysis import forecast
|
||||
from delta_barth.management import SESSION
|
||||
from delta_barth.types import JsonResponse, JsonStatus
|
||||
|
||||
|
||||
def pipeline_sales_forecast(
|
||||
company_id: int | None,
|
||||
start_date: Datetime | None,
|
||||
) -> str:
|
||||
) -> tuple[JsonResponse, JsonStatus]:
|
||||
result = forecast.pipeline(SESSION, company_id=company_id, start_date=start_date)
|
||||
response = JsonResponse(result.response.model_dump_json())
|
||||
status = JsonStatus(result.status.model_dump_json())
|
||||
|
||||
return result.model_dump_json()
|
||||
return response, status
|
||||
|
||||
@@ -110,6 +110,10 @@ class PipeResult(t.Generic[R]):
|
||||
self.results = response
|
||||
|
||||
|
||||
JsonResponse = t.NewType("JsonResponse", str)
|
||||
JsonStatus = t.NewType("JsonStatus", str)
|
||||
|
||||
|
||||
# ** API
|
||||
class ApiCredentials(BaseModel):
|
||||
model_config: ConfigDict = ConfigDict(str_strip_whitespace=True)
|
||||
|
||||
Reference in New Issue
Block a user