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

remove http timeout and add context timeout on collections #422

Merged
merged 2 commits into from
Oct 4, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Update the runtime's manifest usage [#417](https://github.com/hypermodeinc/modus/pull/417)
- Add Modus Go SDK [#418](https://github.com/hypermodeinc/modus/pull/418)
- Add Local Model Invocation Support [#421](https://github.com/hypermodeinc/modus/pull/421)
- Remove HTTP Timeout, Add Context Timeout on Collections [#422](https://github.com/hypermodeinc/modus/pull/422)

## 2024-10-02 - Version 0.12.7

Expand Down
13 changes: 10 additions & 3 deletions runtime/collections/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"fmt"
"math"
"sort"
"time"

"github.com/hypermodeinc/modus/runtime/collections/in_mem"
"github.com/hypermodeinc/modus/runtime/collections/index"
Expand Down Expand Up @@ -101,7 +102,9 @@ func UpsertToCollection(ctx context.Context, collectionName, namespace string, k
return nil, err
}

executionInfo, err := wasmhost.CallFunction(ctx, embedder, texts)
callCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
executionInfo, err := wasmhost.CallFunction(callCtx, embedder, texts)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -190,7 +193,9 @@ func SearchCollection(ctx context.Context, collectionName string, namespaces []s

texts := []string{text}

executionInfo, err := wasmhost.CallFunction(ctx, embedder, texts)
callCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
executionInfo, err := wasmhost.CallFunction(callCtx, embedder, texts)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -331,7 +336,9 @@ func NnClassify(ctx context.Context, collectionName, namespace, searchMethod, te

texts := []string{text}

executionInfo, err := wasmhost.CallFunction(ctx, embedder, texts)
callCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
executionInfo, err := wasmhost.CallFunction(callCtx, embedder, texts)
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion runtime/collections/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"errors"
"fmt"
"slices"
"time"

"github.com/hypermodeinc/modus/pkg/manifest"
"github.com/hypermodeinc/modus/runtime/collections/in_mem"
Expand Down Expand Up @@ -218,7 +219,9 @@ func processTexts(ctx context.Context, col interfaces.CollectionNamespace, vecto
keysBatch := keys[i:end]
textsBatch := texts[i:end]

executionInfo, err := wasmhost.CallFunction(ctx, vectorIndex.GetEmbedderName(), textsBatch)
callCtx, cancel := context.WithTimeout(ctx, 60*time.Second)
defer cancel()
executionInfo, err := wasmhost.CallFunction(callCtx, vectorIndex.GetEmbedderName(), textsBatch)
if err != nil {
return err
}
Expand Down
4 changes: 1 addition & 3 deletions runtime/utils/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
"time"
)

var httpClient = &http.Client{
Timeout: 10 * time.Second,
}
var httpClient = &http.Client{}

func HttpClient() *http.Client {
return httpClient
Expand Down
Loading