-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: add modusdb model tracing for local dev #697
base: main
Are you sure you want to change the base?
feat: add modusdb model tracing for local dev #697
Conversation
…f github.com:hypermodeinc/modus into jai/hyp-2609-move-local-inference-history-to-modusdb
func InitModusDb(ctx context.Context) { | ||
// Initialize the database connection. | ||
var err error | ||
GlobalModusDbEngine, err = modusdb.NewEngine(modusdb.NewDefaultConfig(dataDir)) | ||
if err != nil { | ||
logger.Fatal(ctx).Err(err).Msg("Failed to initialize modusdb.") | ||
return | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only be initializing Modus DB in development, and we should use the Modus home directory for the root of the storage. Consider:
func InitModusDb(ctx context.Context) { | |
// Initialize the database connection. | |
var err error | |
GlobalModusDbEngine, err = modusdb.NewEngine(modusdb.NewDefaultConfig(dataDir)) | |
if err != nil { | |
logger.Fatal(ctx).Err(err).Msg("Failed to initialize modusdb.") | |
return | |
} | |
} | |
func InitModusDb(ctx context.Context) { | |
if config.IsDevEnvironment() { | |
dataDir := filepath.Join(app.ModusHomeDir(), "data") | |
if eng, err := modusdb.NewEngine(modusdb.NewDefaultConfig(dataDir)); err != nil { | |
logger.Fatal(ctx).Err(err).Msg("Failed to initialize modusdb.") | |
} else { | |
GlobalModusDbEngine = eng | |
} | |
} | |
} |
You can add the following to /runtime/app/app.go
:
func ModusHomeDir() string {
modusHome := os.Getenv("MODUS_HOME")
if modusHome == "" {
userHome, _ := os.UserHomeDir()
modusHome = filepath.Join(userHome, ".modus")
}
return modusHome
}
@@ -0,0 +1,36 @@ | |||
/* | |||
* Copyright 2024 Hypermode Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright 2024 Hypermode Inc. | |
* Copyright 2025 Hypermode Inc. |
@@ -0,0 +1,401 @@ | |||
/* | |||
* Copyright 2024 Hypermode Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright 2024 Hypermode Inc. | |
* Copyright 2025 Hypermode Inc. |
@@ -38,7 +38,7 @@ func parseCommandLineFlags() { | |||
var showVersion bool | |||
const versionUsage = "Show the Runtime version number and exit." | |||
flag.BoolVar(&showVersion, "version", false, versionUsage) | |||
flag.BoolVar(&showVersion, "v", false, versionUsage+" (shorthand)") | |||
// flag.BoolVar(&showVersion, "v", false, versionUsage+" (shorthand)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed. I will address separately to remove global flagset usage.
@@ -3,3 +3,5 @@ runtime | |||
|
|||
node_modules | |||
dist | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed.
defaultRoutes["/inferences.json"] = InferenceHistoryHandler | ||
defaultRoutes["/plugins.json"] = PluginHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels weird. Let's discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per our discussion:
- Move
/inferences.json
and the correspondinginferenceHistoryHandler
toexplorer/explorer.go
and connect it there as/explorer/api/inferences
(no.json
extension). Wire it to the explorer's own mux, and update the explorermain.tsx
to use it. - Remove
/plugins.json
since we're not using it in the explorer
j, _ := utils.JsonSerialize(inferences) | ||
_, _ = w.Write(j) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check these errors please
Description
Checklist
All PRs should check the following boxes:
Conventional Commits syntax, leading with
fix:
,feat:
,chore:
,ci:
, etc.the contributing guide.
If the PR includes a code change, then also check the following boxes. (If not, then delete the
next section.)
CHANGELOG.md
file.