-
Notifications
You must be signed in to change notification settings - Fork 5
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
Extracting filesystem accesses; 'workspace inspect' command #13
Draft
warpfork
wants to merge
9
commits into
master
Choose a base branch
from
extracting-dabs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a641316
Extracting filesystem access better.
warpfork 45e4552
Fix some regressions from the conversions to using fs.FS.
warpfork f8c6210
Begin outlining a 'workspace inspect' command.
warpfork 8fdb3c6
Hoist out a ComputeStats func for plots.
warpfork 0f16955
ComputeStats on a plot needs to be recursive!
warpfork fd29e04
Appease error analyzer.
warpfork 450b5e6
'workspace inspect' command now generates many checkmarks.
warpfork 5b9f07d
'workspace inspect' now has valence opinions on these checkboxes.
warpfork 0fbe91a
'workspace inspect' attempts to align output now.
warpfork File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,24 @@ import ( | |
"os" | ||
"path/filepath" | ||
|
||
"github.com/warpfork/warpforge/pkg/dab" | ||
|
||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/warpfork/warpforge/pkg/dab" | ||
"github.com/warpfork/warpforge/pkg/plotexec" | ||
) | ||
|
||
var cmdDefWorkspaceInspect = cli.Command{ | ||
Name: "inspect", | ||
Usage: "Inspect and report upon the situation of the current workspace (how many modules are there, have we got a cached evaluation of them, etc).", | ||
Action: cmdFnWorkspaceInspect, | ||
// Aliases: []string{"winspect"}, // doesn't put them at the top level. Womp. | ||
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "gohard", | ||
Usage: "whether to spend effort checking the health of modules found; if false, just list them.", | ||
Value: true, | ||
}, | ||
}, | ||
} | ||
|
||
func cmdFnWorkspaceInspect(c *cli.Context) error { | ||
|
@@ -33,7 +41,7 @@ func cmdFnWorkspaceInspect(c *cli.Context) error { | |
fmt.Fprintf(c.App.Writer, "Workspace: %s%s\n", wsFs, wsPath) | ||
|
||
// Search for modules within the workspace. | ||
fs.WalkDir(wsFs, wsPath, func(path string, d fs.DirEntry, err error) error { | ||
return fs.WalkDir(wsFs, wsPath, func(path string, d fs.DirEntry, err error) error { | ||
// fmt.Fprintf(c.App.Writer, "hi: %s%s\n", wsFs, path) | ||
|
||
if err != nil { | ||
|
@@ -66,12 +74,50 @@ func cmdFnWorkspaceInspect(c *cli.Context) error { | |
modName = "!!Unknown!!" | ||
} | ||
|
||
everythingParses := false | ||
importsResolve := false | ||
noticeIngestUsage := false | ||
noticeMountUsage := false | ||
havePacksCached := false // maybe should have a variant for "or we have a replay we're hopeful about"? | ||
haveRunrecord := false | ||
haveHappyExit := false | ||
if c.Bool("gohard") { | ||
if err != nil { | ||
goto _checksDone | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oy. |
||
} | ||
plot, err := dab.PlotFromFile(wsFs, filepath.Join(filepath.Dir(path), dab.MagicFilename_Plot)) | ||
if err != nil { | ||
goto _checksDone | ||
} | ||
everythingParses = true | ||
plotStats, err := plotexec.ComputeStats(plot, wss) | ||
if err != nil { | ||
return err // if it's hardcore catalog errors, rather than just unresolvables, I'm out | ||
} | ||
if plotStats.ResolvableCatalogInputs == plotStats.InputsUsingCatalog { | ||
importsResolve = true | ||
} | ||
if plotStats.InputsUsingIngest > 0 { | ||
noticeIngestUsage = true | ||
} | ||
if plotStats.InputsUsingMount > 0 { | ||
noticeMountUsage = true | ||
} | ||
// TODO: havePacksCached is not supported right now :( | ||
// TODO: haveRunrecord needs to both do resolve, and go peek at memos, and yet (obviously) not actually run. | ||
// TODO: haveHappyExit needs the above. | ||
} | ||
_checksDone: | ||
|
||
// Tell me about it. | ||
fmt.Fprintf(c.App.Writer, "Module found: %q -- at path %q\n", modName, modPathWithinWs) | ||
fmt.Fprintf(c.App.Writer, "Module found: %q -- at path %q", modName, modPathWithinWs) | ||
if c.Bool("gohard") { | ||
fmt.Fprintf(c.App.Writer, " -- %v %v %v %v %v %v %v", | ||
everythingParses, importsResolve, noticeIngestUsage, noticeMountUsage, havePacksCached, haveRunrecord, haveHappyExit) | ||
} | ||
fmt.Fprintf(c.App.Writer, "\n") | ||
} | ||
|
||
return nil | ||
}) | ||
|
||
return nil | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Haha. Maybe
health-check
?