Skip to content

Commit

Permalink
chore: update ModusDB (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Feb 7, 2025
1 parent 91b030b commit 6d1a9c4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- fix: improve dgraph auth header passing [#752](https://github.com/hypermodeinc/modus/pull/752)
- fix: jwks endpoint should use key ID if available [#753](https://github.com/hypermodeinc/modus/pull/753)
- fix: wasm filename should be last part of package name [#754](https://github.com/hypermodeinc/modus/pull/754)
- chore: update ModusDB [#755](https://github.com/hypermodeinc/modus/pull/755)

## 2025-01-24 - Runtime 0.17.1

Expand Down
20 changes: 10 additions & 10 deletions runtime/db/inferencehistory.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func getInferenceDataJson(val any) ([]byte, error) {
func WritePluginInfo(ctx context.Context, plugin *plugins.Plugin) {

if app.IsDevEnvironment() {
err := writePluginInfoToModusdb(plugin)
err := writePluginInfoToModusdb(ctx, plugin)
if err != nil {
logDbWarningOrError(ctx, err, "Plugin info not written to ModusDB.")
}
Expand Down Expand Up @@ -246,11 +246,11 @@ ON CONFLICT (build_id) DO NOTHING`,
}
}

func writePluginInfoToModusdb(plugin *plugins.Plugin) error {
func writePluginInfoToModusdb(ctx context.Context, plugin *plugins.Plugin) error {
if GlobalModusDbEngine == nil {
return nil
}
_, _, err := modusdb.Create[Plugin](GlobalModusDbEngine, Plugin{
_, _, err := modusdb.Create[Plugin](ctx, GlobalModusDbEngine, Plugin{
Id: plugin.Id,
Name: plugin.Metadata.Name(),
Version: plugin.Metadata.Version(),
Expand Down Expand Up @@ -307,7 +307,7 @@ func WriteInferenceHistoryToDB(ctx context.Context, batch []inferenceHistory) {
}

if app.IsDevEnvironment() {
err := writeInferenceHistoryToModusDb(batch)
err := writeInferenceHistoryToModusDb(ctx, batch)
if err != nil {
logDbWarningOrError(ctx, err, "Inference history not written to ModusDB.")
}
Expand Down Expand Up @@ -356,7 +356,7 @@ VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
}
}

func writeInferenceHistoryToModusDb(batch []inferenceHistory) error {
func writeInferenceHistoryToModusDb(ctx context.Context, batch []inferenceHistory) error {
if GlobalModusDbEngine == nil {
return nil
}
Expand All @@ -377,7 +377,7 @@ func writeInferenceHistoryToModusDb(batch []inferenceHistory) error {
} else {
pluginId = *data.pluginId
}
_, _, err = modusdb.Create[Inference](GlobalModusDbEngine, Inference{
_, _, err = modusdb.Create[Inference](ctx, GlobalModusDbEngine, Inference{
Id: utils.GenerateUUIDv7(),
ModelHash: data.model.Hash(),
Input: string(input),
Expand All @@ -396,18 +396,18 @@ func writeInferenceHistoryToModusDb(batch []inferenceHistory) error {
return nil
}

func QueryPlugins() ([]Plugin, error) {
func QueryPlugins(ctx context.Context) ([]Plugin, error) {
if GlobalModusDbEngine == nil {
return nil, nil
}
_, plugins, err := modusdb.Query[Plugin](GlobalModusDbEngine, modusdb.QueryParams{})
_, plugins, err := modusdb.Query[Plugin](ctx, GlobalModusDbEngine, modusdb.QueryParams{})
return plugins, err
}

func QueryInferences() ([]Inference, error) {
func QueryInferences(ctx context.Context) ([]Inference, error) {
if GlobalModusDbEngine == nil {
return nil, nil
}
_, inferences, err := modusdb.Query[Inference](GlobalModusDbEngine, modusdb.QueryParams{})
_, inferences, err := modusdb.Query[Inference](ctx, GlobalModusDbEngine, modusdb.QueryParams{})
return inferences, err
}
2 changes: 1 addition & 1 deletion runtime/explorer/explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var InferenceHistoryHandler = http.HandlerFunc(inferenceHistoryHandler)

func inferenceHistoryHandler(w http.ResponseWriter, r *http.Request) {

inferences, err := db.QueryInferences()
inferences, err := db.QueryInferences(r.Context())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down
2 changes: 1 addition & 1 deletion runtime/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/renameio/v2 v2.0.0
github.com/google/uuid v1.6.0
github.com/hypermodeinc/modusdb v0.0.0-20250124181856-b77a41ecb3c1
github.com/hypermodeinc/modusdb v0.0.0-20250207181521-a702ca86dda6
github.com/jackc/pgx/v5 v5.7.2
github.com/jensneuse/abstractlogger v0.0.4
github.com/joho/godotenv v1.5.1
Expand Down
4 changes: 2 additions & 2 deletions runtime/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ github.com/hypermodeinc/modus/lib/metadata v0.15.0 h1:Qu75TZg7l43Fi61EhnjasTHZvz
github.com/hypermodeinc/modus/lib/metadata v0.15.0/go.mod h1:vnIwX2DpQyGk93DawGgIaqC5jEdvMeA9tGtvefbwTJw=
github.com/hypermodeinc/modus/lib/wasmextractor v0.13.0 h1:9o8qqAllL9qIPYqc5adF+Aw3XWLmLqPiBPMu0AIyiMI=
github.com/hypermodeinc/modus/lib/wasmextractor v0.13.0/go.mod h1:YCesMU95vF5qkscLMKSYr92OloLe1KGwyiqW2i4OmnE=
github.com/hypermodeinc/modusdb v0.0.0-20250124181856-b77a41ecb3c1 h1:4XPtzPNBUukALNGBbgFYZd/XWj5o7lKQMdS1/2n6hNE=
github.com/hypermodeinc/modusdb v0.0.0-20250124181856-b77a41ecb3c1/go.mod h1:IS/JNdx7dhcHd3yE+NbpNh3tPuti+SEEzAlK2SSKTKk=
github.com/hypermodeinc/modusdb v0.0.0-20250207181521-a702ca86dda6 h1:YE7+e+kz2r4rTZC1RPHDzMu9Grf0H65mEP+iBf2XTLM=
github.com/hypermodeinc/modusdb v0.0.0-20250207181521-a702ca86dda6/go.mod h1:gRz1FsGNefsKGsxDji/7FFtlkO550L/vXcA/KYOoUVI=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
Expand Down

0 comments on commit 6d1a9c4

Please sign in to comment.