diff --git a/internal/server/runner.go b/internal/server/runner.go index 8ac0329..6849b9c 100644 --- a/internal/server/runner.go +++ b/internal/server/runner.go @@ -193,9 +193,6 @@ func (r *Runner) predict(req PredictionRequest) (chan PredictionResponse, error) log.Errorw("prediction rejected: server is defunct") return nil, ErrDefunct } - if req.CreatedAt == "" { - req.CreatedAt = util.NowIso() - } r.mu.Lock() if len(r.pending) >= r.maxConcurrency { r.mu.Unlock() @@ -210,6 +207,13 @@ func (r *Runner) predict(req PredictionRequest) (chan PredictionResponse, error) r.mu.Unlock() log.Infow("received prediction request", "id", req.Id) + if req.CreatedAt == "" { + req.CreatedAt = util.NowIso() + } + // Start here so that input downloads are counted towards predict_time + if req.StartedAt == "" { + req.StartedAt = util.NowIso() + } inputPaths := make([]string, 0) input, err := handleInputPaths(req.Input, r.doc, &inputPaths, base64ToInput) @@ -228,6 +232,7 @@ func (r *Runner) predict(req PredictionRequest) (chan PredictionResponse, error) Input: req.Input, Id: req.Id, CreatedAt: req.CreatedAt, + StartedAt: req.StartedAt, } pr := PendingPrediction{ request: req, diff --git a/internal/server/types.go b/internal/server/types.go index ca98f74..dd7f64f 100644 --- a/internal/server/types.go +++ b/internal/server/types.go @@ -93,6 +93,7 @@ type PredictionRequest struct { Input any `json:"input"` Id string `json:"id"` CreatedAt string `json:"created_at"` + StartedAt string `json:"started_at"` Webhook string `json:"webhook,omitempty"` WebhookEventsFilter []WebhookEvent `json:"webhook_events_filter,omitempty"` OutputFilePrefix string `json:"output_file_prefix,omitempty"` diff --git a/python/coglet/file_runner.py b/python/coglet/file_runner.py index 45a9c3e..027abc8 100644 --- a/python/coglet/file_runner.py +++ b/python/coglet/file_runner.py @@ -163,7 +163,6 @@ async def _predict(self, pid: str, req: Dict[str, Any]) -> None: assert self.runner is not None resp: Dict[str, Any] = { - 'started_at': util.now_iso(), 'status': 'starting', } context_dict = {}