Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Unified Diff: golden/go/analysis/analysis.go

Issue 650253003: Added HTTP endpoints for Correctness counts (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Fixed typos Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | golden/go/db/db.go » ('j') | golden/go/skiacorrectness/main.go » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: golden/go/analysis/analysis.go
diff --git a/golden/go/analysis/analysis.go b/golden/go/analysis/analysis.go
index ede75ef81bb61ee232d13f56b865c0f9c3294238..7123f2db449be2b09549d2ecfa98a3ee2a1774a0 100644
--- a/golden/go/analysis/analysis.go
+++ b/golden/go/analysis/analysis.go
@@ -17,10 +17,10 @@ import (
// Stores a Trace with labels and digests in memory. CommitIds, Digests and
// Labels are of the same length, identical indices refer to the same digest.
type LabeledTrace struct {
- Params map[string]string `json:"params"`
- CommitIds []int `json:"commitIds"`
- Digests []string `json:"digests"`
- Labels []types.Label `json:"labels`
+ Params map[string]string
+ CommitIds []int
+ Digests []string
+ Labels []types.Label
}
func NewLabeledTrace(params map[string]string, capacity int) *LabeledTrace {
@@ -41,12 +41,14 @@ func (lt *LabeledTrace) addLabeledDigests(commitIds []int, digests []string, lab
// Aggregates the Traces in tile and provides the commits that the
// CommitIds in LabeledTrace refer to.
+// LabeledTile and LabeledTrace are used to store the cannonical information
+// extracted from the tiles. The (redundant) output data is derived from these.
type LabeledTile struct {
- Commits []*ptypes.Commit `json:"commits"`
+ Commits []*ptypes.Commit
// Traces are indexed by the primary key (test name). This is somewhat
// redundant, but this also output format.
- Traces map[string][]*LabeledTrace `json:"traces"`
+ Traces map[string][]*LabeledTrace
}
func NewLabeledTile() *LabeledTile {
@@ -81,6 +83,29 @@ func (t *LabeledTile) getLabeledTrace(trace ptypes.Trace) (string, *LabeledTrace
return pKey, newLT
}
+// GUITileCounts is an output type for the aggregated label counts.
+// The tupples in Counts store: untriaged, positive, negatives
+type GUITileCounts struct {
+ Commits []*ptypes.Commit `json:"commits"`
+ Counts map[string][][3]int64 `json:"counts"`
jcgregorio 2014/10/17 18:07:52 [3]int64 is a little ambiguous as far as figuring
stephana 2014/10/17 20:01:45 Done.
+}
+
+// GUITestCounts is an output type for a single test that contains the
+// aggregated counts over all traces and invidual trace labels.
+type GUITestCounts struct {
+ Commits []*ptypes.Commit `json:"commits"`
+ Aggregated [][3]int64 `json:"aggregated"`
+ Traces []*GUILabeledTrace `json:"traces"`
+}
+
+// GUILabeledTrace is an output type for the labels of a trace.
+type GUILabeledTrace struct {
+ Params map[string]string `json:"params"`
+
+ // Contains (commitId, lable) pairs.
+ Labels [][2]uint64 `json:"labels"`
jcgregorio 2014/10/17 18:07:52 Why not map[int64]int64 or []struct{ ID int64, Lab
stephana 2014/10/17 20:01:45 Done.
+}
+
// Analyzer continuously manages the tasks, like pollint for new traces
// on disk, etc.
type Analyzer struct {
@@ -88,9 +113,15 @@ type Analyzer struct {
diffStore diff.DiffStore
tileStore ptypes.TileStore
+ // Canonical data structure to hold our information about commits, digests
+ // and labels.
currentTile *LabeledTile
- // Lock to protect the expectations and the current labeled tile.
+ // Output data structures that are derived from currentTile.
+ currentTileCounts *GUITileCounts
+ currentTestCounts map[string]*GUITestCounts
+
+ // Lock to protect the expectations and current* variables.
mutex sync.Mutex
}
@@ -110,18 +141,18 @@ func NewAnalyzer(expStore expstorage.ExpectationsStore, tileStore ptypes.TileSto
// Returns an entire Tile which is a collection of 'traces' over a series of
// of commits. Each trace contains the digests and their labels based on
// out knowledge base about digests (expectations).
-func (a *Analyzer) GetLabeledTile() *LabeledTile {
+func (a *Analyzer) GetTileCounts() (*GUITileCounts, error) {
a.mutex.Lock()
defer a.mutex.Unlock()
- return a.currentTile
+ return a.currentTileCounts, nil
}
-func (a *Analyzer) GetLabeledTraces(testName string) []*LabeledTrace {
+func (a *Analyzer) GetTestCounts(testName string) (*GUITestCounts, error) {
a.mutex.Lock()
defer a.mutex.Unlock()
- return a.currentTile.Traces[testName]
+ return a.currentTestCounts[testName], nil
}
func (a *Analyzer) SetDigestLabels(labeledTestDigests map[string]types.TestClassification, userId string) (map[string][]*LabeledTrace, error) {
@@ -160,8 +191,12 @@ func (a *Analyzer) loop(timeBetweenPolls time.Duration) {
errorTileLoadingCounter.Inc(1)
} else {
newLabeledTile := a.processTile(tile)
+ newTileCounts, newTestCounts := a.getOutputCounts(newLabeledTile)
+
a.mutex.Lock()
a.currentTile = newLabeledTile
+ a.currentTileCounts = newTileCounts
+ a.currentTestCounts = newTestCounts
a.mutex.Unlock()
}
runsCounter.Inc(1)
@@ -248,3 +283,45 @@ func (a *Analyzer) labelDigests(testName string, digests []string, targetLabels
return nil
}
+
+// Derive the output counts from the given labeled tile.
+func (a *Analyzer) getOutputCounts(labeledTile *LabeledTile) (*GUITileCounts, map[string]*GUITestCounts) {
+ // Stores the aggregated counts of a tile for each test.
+ tileCountsMap := make(map[string][][3]int64, len(labeledTile.Traces))
+
+ // Stores the aggregated counts for each test and individual trace information.
+ testCountsMap := make(map[string]*GUITestCounts, len(labeledTile.Traces))
+
+ for testName, testTraces := range labeledTile.Traces {
+ acc := make([][3]int64, len(labeledTile.Commits))
+ tempTraces := make([]*GUILabeledTrace, 0, len(testTraces))
+
+ for _, oneTrace := range testTraces {
+ tempTrace := &GUILabeledTrace{
+ Params: oneTrace.Params,
+ Labels: make([][2]uint64, len(oneTrace.CommitIds)),
+ }
+
+ for i, ci := range oneTrace.CommitIds {
+ // Increment the tuple element based on Label constant values.
+ acc[ci][oneTrace.Labels[i]]++
+ tempTrace.Labels[i][0] = uint64(ci)
+ tempTrace.Labels[i][1] = uint64(oneTrace.Labels[i])
+ }
+ }
+
+ tileCountsMap[testName] = acc
+ testCountsMap[testName] = &GUITestCounts{
+ Commits: labeledTile.Commits,
+ Aggregated: acc,
+ Traces: tempTraces,
+ }
+ }
+
+ tileCounts := &GUITileCounts{
+ Commits: labeledTile.Commits,
+ Counts: tileCountsMap,
+ }
+
+ return tileCounts, testCountsMap
+}
« no previous file with comments | « no previous file | golden/go/db/db.go » ('j') | golden/go/skiacorrectness/main.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698