Skip to content
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

Revert "Send requestID and streamID through to the runner for logging" #3386

Merged
merged 1 commit into from
Feb 10, 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
9 changes: 2 additions & 7 deletions ai/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,19 +604,14 @@ func (w *Worker) TextToSpeech(ctx context.Context, req GenTextToSpeechJSONReques
return resp.JSON200, nil
}

func (w *Worker) LiveVideoToVideo(ctx context.Context, requestID, streamID string, req GenLiveVideoToVideoJSONRequestBody) (*LiveVideoToVideoResponse, error) {
func (w *Worker) LiveVideoToVideo(ctx context.Context, req GenLiveVideoToVideoJSONRequestBody) (*LiveVideoToVideoResponse, error) {
// Live video containers keep running after the initial request, so we use a background context to borrow the container.
c, err := w.borrowContainer(context.Background(), "live-video-to-video", *req.ModelId)
if err != nil {
return nil, err
}

setHeaders := func(ctx context.Context, req *http.Request) error {
req.Header.Set("requestID", requestID)
req.Header.Set("streamID", streamID)
return nil
}
resp, err := c.Client.GenLiveVideoToVideoWithResponse(ctx, req, setHeaders)
resp, err := c.Client.GenLiveVideoToVideoWithResponse(ctx, req)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion core/ai.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type AI interface {
SegmentAnything2(context.Context, worker.GenSegmentAnything2MultipartRequestBody) (*worker.MasksResponse, error)
ImageToText(context.Context, worker.GenImageToTextMultipartRequestBody) (*worker.ImageToTextResponse, error)
TextToSpeech(context.Context, worker.GenTextToSpeechJSONRequestBody) (*worker.AudioResponse, error)
LiveVideoToVideo(context.Context, string, string, worker.GenLiveVideoToVideoJSONRequestBody) (*worker.LiveVideoToVideoResponse, error)
LiveVideoToVideo(context.Context, worker.GenLiveVideoToVideoJSONRequestBody) (*worker.LiveVideoToVideoResponse, error)
Warm(context.Context, string, string, worker.RunnerEndpoint, worker.OptimizationFlags) error
Stop(context.Context) error
HasCapacity(string, string) bool
Expand Down
8 changes: 4 additions & 4 deletions core/ai_orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,10 @@ func (orch *orchestrator) TextToImage(ctx context.Context, requestID string, req
return res.Results, nil
}

func (orch *orchestrator) LiveVideoToVideo(ctx context.Context, requestID, streamID string, req worker.GenLiveVideoToVideoJSONRequestBody) (interface{}, error) {
func (orch *orchestrator) LiveVideoToVideo(ctx context.Context, requestID string, req worker.GenLiveVideoToVideoJSONRequestBody) (interface{}, error) {
// local AIWorker processes job if combined orchestrator/ai worker
if orch.node.AIWorker != nil {
workerResp, err := orch.node.LiveVideoToVideo(ctx, requestID, streamID, req)
workerResp, err := orch.node.LiveVideoToVideo(ctx, req)
if err == nil {
return orch.node.saveLocalAIWorkerResults(ctx, *workerResp, requestID, "application/json")
} else {
Expand Down Expand Up @@ -1060,8 +1060,8 @@ func (n *LivepeerNode) TextToSpeech(ctx context.Context, req worker.GenTextToSpe
return n.AIWorker.TextToSpeech(ctx, req)
}

func (n *LivepeerNode) LiveVideoToVideo(ctx context.Context, requestID, streamID string, req worker.GenLiveVideoToVideoJSONRequestBody) (*worker.LiveVideoToVideoResponse, error) {
return n.AIWorker.LiveVideoToVideo(ctx, requestID, streamID, req)
func (n *LivepeerNode) LiveVideoToVideo(ctx context.Context, req worker.GenLiveVideoToVideoJSONRequestBody) (*worker.LiveVideoToVideoResponse, error) {
return n.AIWorker.LiveVideoToVideo(ctx, req)
}

// transcodeFrames converts a series of image URLs into a video segment for the image-to-video pipeline.
Expand Down
11 changes: 2 additions & 9 deletions server/ai_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@ func (h *lphttp) StartLiveVideoToVideo() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
remoteAddr := getRemoteAddr(r)
ctx := clog.AddVal(r.Context(), clog.ClientIP, remoteAddr)
streamID := r.Header.Get("streamID")
requestID := r.Header.Get("requestID")

if requestID == "" {
requestID = string(core.RandomManifestID())
}
ctx = clog.AddVal(ctx, "request_id", requestID)
ctx = clog.AddVal(ctx, "stream_id", streamID)
requestID := string(core.RandomManifestID())

var req worker.GenLiveVideoToVideoJSONRequestBody
if err := jsonDecoder[worker.GenLiveVideoToVideoJSONRequestBody](&req, r); err != nil {
Expand Down Expand Up @@ -238,7 +231,7 @@ func (h *lphttp) StartLiveVideoToVideo() http.Handler {
}

// Send request to the worker
_, err = orch.LiveVideoToVideo(ctx, requestID, streamID, workerReq)
_, err = orch.LiveVideoToVideo(ctx, requestID, workerReq)
if err != nil {
if monitor.Enabled {
monitor.AIProcessingError(err.Error(), pipeline, modelID, ethcommon.Address{}.String())
Expand Down
17 changes: 1 addition & 16 deletions server/ai_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -1039,24 +1039,9 @@ func submitLiveVideoToVideo(ctx context.Context, params aiRequestParams, sess *A
}
return nil, err
}
paymentHeaders, balUpdate, err := prepareAIPayment(ctx, sess, initPixelsToPay)
if err != nil {
if monitor.Enabled {
monitor.AIRequestError(err.Error(), "LiveVideoToVideo", *req.ModelId, sess.OrchestratorInfo)
}
return nil, err
}
setHeaders, balUpdate, err := prepareAIPayment(ctx, sess, initPixelsToPay)
defer completeBalanceUpdate(sess.BroadcastSession, balUpdate)

setHeaders := func(ctx context.Context, req *http.Request) error {
if err := paymentHeaders(ctx, req); err != nil {
return err
}
req.Header.Set("requestID", params.liveParams.requestID)
req.Header.Set("streamID", params.liveParams.streamID)
return nil
}

// Send request to orchestrator
resp, err := client.GenLiveVideoToVideoWithResponse(ctx, req, setHeaders)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion server/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type Orchestrator interface {
SegmentAnything2(ctx context.Context, requestID string, req worker.GenSegmentAnything2MultipartRequestBody) (interface{}, error)
ImageToText(ctx context.Context, requestID string, req worker.GenImageToTextMultipartRequestBody) (interface{}, error)
TextToSpeech(ctx context.Context, requestID string, req worker.GenTextToSpeechJSONRequestBody) (interface{}, error)
LiveVideoToVideo(ctx context.Context, requestID, streamID string, req worker.GenLiveVideoToVideoJSONRequestBody) (interface{}, error)
LiveVideoToVideo(ctx context.Context, requestID string, req worker.GenLiveVideoToVideoJSONRequestBody) (interface{}, error)
}

// Balance describes methods for a session's balance maintenance
Expand Down
Loading