Skip to content

Set started_at to before input downloads #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions internal/server/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions internal/server/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 0 additions & 1 deletion python/coglet/file_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down