-
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package plotexec | ||
|
||
import ( | ||
"github.com/warpfork/warpforge/pkg/workspace" | ||
"github.com/warpfork/warpforge/wfapi" | ||
) | ||
|
||
// Might not match the package name -- funcs in this file certainly don't exec anything. | ||
|
||
type PlotStats struct { | ||
InputsUsingCatalog int | ||
InputsUsingIngest int | ||
InputsUsingMount int | ||
ResolvableCatalogInputs int | ||
ResolvedCatalogInputs map[wfapi.CatalogRef]wfapi.WareID // might as well remember it if we already did all that work. | ||
UnresolvedCatalogInputs map[wfapi.CatalogRef]struct{} | ||
} | ||
|
||
// ComputeStats counts up how many times a plot uses various features, | ||
// and also checks for reference resolvablity. | ||
func ComputeStats(plot wfapi.Plot, wsSet workspace.WorkspaceSet) (PlotStats, error) { | ||
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. The is one thing in this PR that should definitely be rescued: this ComputeStats function is more correct than where it was hoisted from. The old occurrence isn't recursive, which is... wrong. |
||
v := PlotStats{ | ||
ResolvedCatalogInputs: make(map[wfapi.CatalogRef]wfapi.WareID), | ||
UnresolvedCatalogInputs: make(map[wfapi.CatalogRef]struct{}), | ||
} | ||
for _, input := range plot.Inputs.Values { | ||
inputBasis := input.Basis() // unwrap if it's a complex filtered thing. | ||
switch { | ||
// This switch should be exhaustive on the possible members of PlotInputSimple. | ||
case inputBasis.WareID != nil: | ||
// not interesting :) | ||
case inputBasis.Mount != nil: | ||
v.InputsUsingMount++ | ||
case inputBasis.Literal != nil: | ||
// not interesting :) | ||
case inputBasis.Pipe != nil: | ||
// not interesting :) | ||
case inputBasis.CatalogRef != nil: | ||
v.InputsUsingCatalog++ | ||
ware, _, err := wsSet.GetCatalogWare(*inputBasis.CatalogRef) | ||
if err != nil { | ||
return v, err // These mean catalog read failed entirely, so we're in deep water. | ||
} | ||
if ware == nil { | ||
v.UnresolvedCatalogInputs[*inputBasis.CatalogRef] = struct{}{} | ||
} else { | ||
v.ResolvableCatalogInputs++ | ||
v.ResolvedCatalogInputs[*inputBasis.CatalogRef] = *ware | ||
} | ||
case inputBasis.Ingest != nil: | ||
v.InputsUsingIngest++ | ||
default: | ||
panic("unreachable") | ||
} | ||
} | ||
return v, 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.
So? I don't really care and I don't think this comment is useful.