From 8acc5efb4876c853a09a8bb80d8fa35626eec338 Mon Sep 17 00:00:00 2001 From: Mehul Kar Date: Fri, 2 Sep 2022 15:54:29 -0700 Subject: [PATCH] More logging to understand how it works --- cli/internal/run/run.go | 5 +++-- cli/internal/taskhash/taskhash.go | 15 +++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/internal/run/run.go b/cli/internal/run/run.go index bc1e3dfdaad77c..cac25c4ee119c6 100644 --- a/cli/internal/run/run.go +++ b/cli/internal/run/run.go @@ -1038,7 +1038,8 @@ func (g *completeGraph) getPackageTaskVisitor(ctx gocontext.Context, visitor fun fmt.Printf("\t taskID: %#v\n", taskID) fmt.Printf("\t task: %#v\n", task) fmt.Printf("\t Pipeline:\n\t\t%#v\n", g.Pipeline) - fmt.Printf("\t taskDefintion (looked up with taskID):\n\t\t%#v\n", taskDefinition) + fmt.Printf("----------------------------\n") + fmt.Printf("\t taskDefintion (looked up with taskID \"%#v\"):\n\t\t%#v\n", taskID, taskDefinition) if !ok { // then check for regular tasks fallbackTaskDefinition, notcool := g.Pipeline[task] @@ -1047,7 +1048,7 @@ func (g *completeGraph) getPackageTaskVisitor(ctx gocontext.Context, visitor fun return nil } // override if we need to... - fmt.Printf("\t fallbackTaskDefinition (looked up with task) %#v\n", fallbackTaskDefinition) + fmt.Printf("\t fallbackTaskDefinition (looked up with task \"%#v\") %#v\n", task, fallbackTaskDefinition) taskDefinition = fallbackTaskDefinition } return visitor(ctx, &nodes.PackageTask{ diff --git a/cli/internal/taskhash/taskhash.go b/cli/internal/taskhash/taskhash.go index 8676b39307fab4..0e2084191da9cc 100644 --- a/cli/internal/taskhash/taskhash.go +++ b/cli/internal/taskhash/taskhash.go @@ -159,6 +159,7 @@ type packageFileHashes map[packageFileHashKey]string // in the task graph. Must be called before calculating task hashes. func (th *Tracker) CalculateFileHashes(allTasks []dag.Vertex, workerCount int, repoRoot turbopath.AbsolutePath) error { fmt.Printf("CalculateFileHashes()\n") + hashTasks := make(util.Set) for i, v := range allTasks { @@ -172,7 +173,6 @@ func (th *Tracker) CalculateFileHashes(allTasks []dag.Vertex, workerCount int, r } pkgName, _ := util.GetPackageTaskFromId(taskID) if pkgName == th.rootNode { - fmt.Printf("\tContinue\n") continue } @@ -181,19 +181,18 @@ func (th *Tracker) CalculateFileHashes(allTasks []dag.Vertex, workerCount int, r return fmt.Errorf("missing pipeline entry %v", taskID) } - taskDefinition.Inputs = append(taskDefinition.Inputs, "./package.json") + // taskDefinition.Inputs = append(taskDefinition.Inputs, "./package.json") pfs := &packageFileSpec{ pkg: pkgName, inputs: taskDefinition.Inputs, } - fmt.Printf("\ttaskDefinition.Inputs: %v\n", taskDefinition.Inputs) - fmt.Printf("\tpfs.inputs: %v\n", pfs.inputs) - hashTasks.Add(pfs) } + fmt.Printf("\thashTasks\n\t\t %#v\n", hashTasks) + hashes := make(map[packageFileHashKey]string) hashQueue := make(chan *packageFileSpec, workerCount) hashErrs := &errgroup.Group{} @@ -211,14 +210,14 @@ func (th *Tracker) CalculateFileHashes(allTasks []dag.Vertex, workerCount int, r } th.mu.Lock() pfsKey := packageFileSpec.ToKey() - fmt.Printf("\tadding to hashes\n") - fmt.Printf("\t\t\"%v\": %v\n", pfsKey, hash) + fmt.Printf("\tadding key \"%#v\" with value \"%#v\"\n", pfsKey, hash) hashes[pfsKey] = hash th.mu.Unlock() } return nil }) } + for ht := range hashTasks { hashQueue <- ht.(*packageFileSpec) } @@ -229,7 +228,7 @@ func (th *Tracker) CalculateFileHashes(allTasks []dag.Vertex, workerCount int, r } th.packageInputsHashes = hashes - fmt.Printf("\tth.packageInputsHashes: %v\n", th.packageInputsHashes) + fmt.Printf("\t tracker:\n\t\t%#v\n", th) return nil }