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

feat: add modusdb model tracing for local dev #697

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

jairad26
Copy link
Member

@jairad26 jairad26 commented Jan 9, 2025

Description

image image image

Checklist

All PRs should check the following boxes:

  • I have given this PR a title using the
    Conventional Commits syntax, leading with fix:,
    feat:, chore:, ci:, etc.
    • The title should also be used for the commit message when the PR is squashed and merged.
  • I have formatted and linted my code with Trunk, per the instructions in
    the contributing guide.

If the PR includes a code change, then also check the following boxes. (If not, then delete the
next section.)

  • I have added an entry to the CHANGELOG.md file.
    • Add to the "UNRELEASED" section at the top of the file, creating one if it doesn't yet exist.
    • Be sure to include the link to this PR, and please sort the section numerically by PR number.
  • I have manually tested the new or modified code, and it appears to behave correctly.
  • I have added or updated unit tests where appropriate, if applicable.

@jairad26 jairad26 changed the title add modusdb inference history for local dev feat: add modusdb model tracing for local dev Jan 10, 2025
@jairad26 jairad26 marked this pull request as ready for review January 16, 2025 18:58
@jairad26 jairad26 requested a review from a team as a code owner January 16, 2025 18:58
@jairad26 jairad26 enabled auto-merge (squash) January 16, 2025 19:09
Comment on lines +22 to +30
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
}
}
Copy link
Member

@mattjohnsonpint mattjohnsonpint Jan 16, 2025

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:

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Copyright 2024 Hypermode Inc.
* Copyright 2025 Hypermode Inc.

@@ -0,0 +1,401 @@
/*
* Copyright 2024 Hypermode Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* 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)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this commented?

Copy link
Member

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

Copy link
Member

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.

Comment on lines +142 to +143
defaultRoutes["/inferences.json"] = InferenceHistoryHandler
defaultRoutes["/plugins.json"] = PluginHandler
Copy link
Member

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.

Copy link
Member

@mattjohnsonpint mattjohnsonpint Jan 17, 2025

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 corresponding inferenceHistoryHandler to explorer/explorer.go and connect it there as /explorer/api/inferences (no .json extension). Wire it to the explorer's own mux, and update the explorer main.tsx to use it.
  • Remove /plugins.json since we're not using it in the explorer

Comment on lines +277 to +278
j, _ := utils.JsonSerialize(inferences)
_, _ = w.Write(j)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check these errors please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants