Jelajahi Sumber

Add protobuf format support to labours.py

Vadim Markovtsev 7 tahun lalu
induk
melakukan
5f3e096a25
7 mengubah file dengan 632 tambahan dan 81 penghapusan
  1. 7 7
      cmd/hercules/main.go
  2. 53 2
      labours.py
  3. 0 0
      pb/__init__.py
  4. 59 59
      pb/pb.pb.go
  5. 6 6
      pb/pb.proto
  6. 500 0
      pb/pb_pb2.py
  7. 7 7
      pb/utils.go

+ 7 - 7
cmd/hercules/main.go

@@ -294,21 +294,21 @@ func serializeResults(
 	}
 
 	if withFiles {
-		message.BurndownFile = make([]*pb.BurndownSparseMatrix, len(burndownResults.FileHistories))
+		message.BurndownFiles = make([]*pb.BurndownSparseMatrix, len(burndownResults.FileHistories))
 		keys := sortedKeys(burndownResults.FileHistories)
 		i := 0
 		for _, key := range keys {
-			message.BurndownFile[i] = pb.ToBurndownSparseMatrix(
+			message.BurndownFiles[i] = pb.ToBurndownSparseMatrix(
 				burndownResults.FileHistories[key], key)
 			i++
 		}
 	}
 
 	if withPeople {
-		message.BurndownDeveloper = make(
+		message.BurndownDevelopers = make(
 		  []*pb.BurndownSparseMatrix, len(burndownResults.PeopleHistories))
 		for key, val := range burndownResults.PeopleHistories {
-			message.BurndownDeveloper[key] = pb.ToBurndownSparseMatrix(val, reversePeopleDict[key])
+			message.BurndownDevelopers[key] = pb.ToBurndownSparseMatrix(val, reversePeopleDict[key])
 		}
 		message.DevelopersInteraction = pb.DenseToCompressedSparseRowMatrix(
 			burndownResults.PeopleMatrix)
@@ -324,7 +324,7 @@ func serializeResults(
 			Matrix: pb.MapToCompressedSparseRowMatrix(couplesResult.PeopleMatrix),
 		}
 		message.TouchedFiles = &pb.DeveloperTouchedFiles{
-      Developer: make([]*pb.TouchedFiles, len(reversePeopleDict)),
+      Developers: make([]*pb.TouchedFiles, len(reversePeopleDict)),
 		}
 		for key := range reversePeopleDict {
 			files := couplesResult.PeopleFiles[key]
@@ -332,8 +332,8 @@ func serializeResults(
 			for i, f := range files {
 				int32Files[i] = int32(f)
 			}
-			message.TouchedFiles.Developer[key] = &pb.TouchedFiles{
-				File: int32Files,
+			message.TouchedFiles.Developers[key] = &pb.TouchedFiles{
+				Files: int32Files,
 			}
 		}
 	}

+ 53 - 2
labours.py

@@ -107,7 +107,6 @@ class YamlReader(Reader):
             print("\nInvalid unicode in the input: %s\nPlease filter it through "
                   "fix_yaml_unicode.py" % e)
             sys.exit(1)
-        print("done")
         self.data = data
 
     def get_name(self):
@@ -161,7 +160,58 @@ class YamlReader(Reader):
 
 class ProtobufReader(Reader):
     def read(self, file):
-        pass
+        from pb.pb_pb2 import AnalysisResults
+        self.data = AnalysisResults()
+        if file != "-":
+            with open(file, "rb") as fin:
+                self.data.ParseFromString(fin.read())
+        else:
+            self.data.ParseFromString(sys.stdin.buffer.read())
+
+    def get_name(self):
+        return self.data.header.repository
+
+    def get_header(self):
+        header = self.data.header
+        return header.begin_unix_time, header.end_unix_time, \
+            header.sampling, header.granularity
+
+    def get_project_burndown(self):
+        return self._parse_burndown_matrix(self.data.burndown_project)
+
+    def get_files_burndown(self):
+        return [self._parse_burndown_matrix(i) for i in self.data.burndown_files]
+
+    def get_people_burndown(self):
+        return [self._parse_burndown_matrix(i) for i in self.data.burndown_developers]
+
+    def get_ownership_burndown(self):
+        people = self.get_people_burndown()
+        return [p[0] for p in people], {p[0]: p[1].T for p in people}
+
+    def get_people_interaction(self):
+        return [i.name for i in self.data.burndown_developers], \
+            self._parse_sparse_matrix(self.data.developers_interaction).toarray()
+
+    def get_files_coocc(self):
+        node = self.data.file_couples
+        return list(node.index), self._parse_sparse_matrix(node.matrix)
+
+    def get_people_coocc(self):
+        node = self.data.developer_couples
+        return list(node.index), self._parse_sparse_matrix(node.matrix)
+
+    def _parse_burndown_matrix(self, matrix):
+        dense = numpy.zeros((matrix.number_of_rows, matrix.number_of_columns), dtype=int)
+        for y, row in enumerate(matrix.rows):
+            for x, col in enumerate(row.columns):
+                dense[y, x] = col
+        return matrix.name, dense.T
+
+    def _parse_sparse_matrix(self, matrix):
+        from scipy.sparse import csr_matrix
+        return csr_matrix((list(matrix.data), list(matrix.indices), list(matrix.indptr)),
+                          shape=(matrix.number_of_rows, matrix.number_of_columns))
 
 
 READERS = {"yaml": YamlReader, "pb": ProtobufReader}
@@ -172,6 +222,7 @@ def read_input(args):
     sys.stdout.flush()
     reader = READERS[args.input_format]()
     reader.read(args.input)
+    print("done")
     return reader
 
 

+ 0 - 0
pb/__init__.py


+ 59 - 59
pb/pb.pb.go

@@ -108,7 +108,7 @@ func (m *Metadata) GetSampling() int32 {
 type BurndownSparseMatrixRow struct {
 	// the first `len(column)` elements are stored,
 	// the rest `number_of_columns - len(column)` values are zeros
-	Column []uint32 `protobuf:"varint,1,rep,packed,name=column" json:"column,omitempty"`
+	Columns []uint32 `protobuf:"varint,1,rep,packed,name=columns" json:"columns,omitempty"`
 }
 
 func (m *BurndownSparseMatrixRow) Reset()                    { *m = BurndownSparseMatrixRow{} }
@@ -116,9 +116,9 @@ func (m *BurndownSparseMatrixRow) String() string            { return proto.Comp
 func (*BurndownSparseMatrixRow) ProtoMessage()               {}
 func (*BurndownSparseMatrixRow) Descriptor() ([]byte, []int) { return fileDescriptorPb, []int{1} }
 
-func (m *BurndownSparseMatrixRow) GetColumn() []uint32 {
+func (m *BurndownSparseMatrixRow) GetColumns() []uint32 {
 	if m != nil {
-		return m.Column
+		return m.Columns
 	}
 	return nil
 }
@@ -128,7 +128,7 @@ type BurndownSparseMatrix struct {
 	NumberOfRows    int32  `protobuf:"varint,2,opt,name=number_of_rows,json=numberOfRows,proto3" json:"number_of_rows,omitempty"`
 	NumberOfColumns int32  `protobuf:"varint,3,opt,name=number_of_columns,json=numberOfColumns,proto3" json:"number_of_columns,omitempty"`
 	// `len(row)` matches `number_of_rows`
-	Row []*BurndownSparseMatrixRow `protobuf:"bytes,4,rep,name=row" json:"row,omitempty"`
+	Rows []*BurndownSparseMatrixRow `protobuf:"bytes,4,rep,name=rows" json:"rows,omitempty"`
 }
 
 func (m *BurndownSparseMatrix) Reset()                    { *m = BurndownSparseMatrix{} }
@@ -157,9 +157,9 @@ func (m *BurndownSparseMatrix) GetNumberOfColumns() int32 {
 	return 0
 }
 
-func (m *BurndownSparseMatrix) GetRow() []*BurndownSparseMatrixRow {
+func (m *BurndownSparseMatrix) GetRows() []*BurndownSparseMatrixRow {
 	if m != nil {
-		return m.Row
+		return m.Rows
 	}
 	return nil
 }
@@ -240,7 +240,7 @@ func (m *Couples) GetMatrix() *CompressedSparseRowMatrix {
 }
 
 type TouchedFiles struct {
-	File []int32 `protobuf:"varint,1,rep,packed,name=file" json:"file,omitempty"`
+	Files []int32 `protobuf:"varint,1,rep,packed,name=files" json:"files,omitempty"`
 }
 
 func (m *TouchedFiles) Reset()                    { *m = TouchedFiles{} }
@@ -248,16 +248,16 @@ func (m *TouchedFiles) String() string            { return proto.CompactTextStri
 func (*TouchedFiles) ProtoMessage()               {}
 func (*TouchedFiles) Descriptor() ([]byte, []int) { return fileDescriptorPb, []int{5} }
 
-func (m *TouchedFiles) GetFile() []int32 {
+func (m *TouchedFiles) GetFiles() []int32 {
 	if m != nil {
-		return m.File
+		return m.Files
 	}
 	return nil
 }
 
 type DeveloperTouchedFiles struct {
 	// order corresponds to `developer_couples::index`
-	Developer []*TouchedFiles `protobuf:"bytes,1,rep,name=developer" json:"developer,omitempty"`
+	Developers []*TouchedFiles `protobuf:"bytes,1,rep,name=developers" json:"developers,omitempty"`
 }
 
 func (m *DeveloperTouchedFiles) Reset()                    { *m = DeveloperTouchedFiles{} }
@@ -265,9 +265,9 @@ func (m *DeveloperTouchedFiles) String() string            { return proto.Compac
 func (*DeveloperTouchedFiles) ProtoMessage()               {}
 func (*DeveloperTouchedFiles) Descriptor() ([]byte, []int) { return fileDescriptorPb, []int{6} }
 
-func (m *DeveloperTouchedFiles) GetDeveloper() []*TouchedFiles {
+func (m *DeveloperTouchedFiles) GetDevelopers() []*TouchedFiles {
 	if m != nil {
-		return m.Developer
+		return m.Developers
 	}
 	return nil
 }
@@ -277,9 +277,9 @@ type AnalysisResults struct {
 	Header          *Metadata             `protobuf:"bytes,1,opt,name=header" json:"header,omitempty"`
 	BurndownProject *BurndownSparseMatrix `protobuf:"bytes,2,opt,name=burndown_project,json=burndownProject" json:"burndown_project,omitempty"`
 	// this is included if `-files` was specified
-	BurndownFile []*BurndownSparseMatrix `protobuf:"bytes,3,rep,name=burndown_file,json=burndownFile" json:"burndown_file,omitempty"`
+	BurndownFiles []*BurndownSparseMatrix `protobuf:"bytes,3,rep,name=burndown_files,json=burndownFiles" json:"burndown_files,omitempty"`
 	// these two are included if `-people` was specified
-	BurndownDeveloper []*BurndownSparseMatrix `protobuf:"bytes,4,rep,name=burndown_developer,json=burndownDeveloper" json:"burndown_developer,omitempty"`
+	BurndownDevelopers []*BurndownSparseMatrix `protobuf:"bytes,4,rep,name=burndown_developers,json=burndownDevelopers" json:"burndown_developers,omitempty"`
 	// rows and cols order correspond to `burndown_developer`
 	DevelopersInteraction *CompressedSparseRowMatrix `protobuf:"bytes,5,opt,name=developers_interaction,json=developersInteraction" json:"developers_interaction,omitempty"`
 	// these three are included if `-couples` was specified
@@ -307,16 +307,16 @@ func (m *AnalysisResults) GetBurndownProject() *BurndownSparseMatrix {
 	return nil
 }
 
-func (m *AnalysisResults) GetBurndownFile() []*BurndownSparseMatrix {
+func (m *AnalysisResults) GetBurndownFiles() []*BurndownSparseMatrix {
 	if m != nil {
-		return m.BurndownFile
+		return m.BurndownFiles
 	}
 	return nil
 }
 
-func (m *AnalysisResults) GetBurndownDeveloper() []*BurndownSparseMatrix {
+func (m *AnalysisResults) GetBurndownDevelopers() []*BurndownSparseMatrix {
 	if m != nil {
-		return m.BurndownDeveloper
+		return m.BurndownDevelopers
 	}
 	return nil
 }
@@ -363,45 +363,45 @@ func init() {
 func init() { proto.RegisterFile("pb/pb.proto", fileDescriptorPb) }
 
 var fileDescriptorPb = []byte{
-	// 639 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00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
-	0x70, 0xd8, 0x91, 0x55, 0xc4, 0xb8, 0x46, 0x19, 0x27, 0xba, 0xfa, 0x75, 0xb8, 0x7f, 0x5c, 0xd4,
-	0xc1, 0x9a, 0xf9, 0x76, 0x4d, 0x24, 0x27, 0x30, 0xaa, 0xbc, 0x44, 0x49, 0x7d, 0x11, 0xe6, 0xfb,
-	0xf6, 0xe6, 0x83, 0xb0, 0xb9, 0x10, 0xea, 0x55, 0xd5, 0xf6, 0x5c, 0x9e, 0xc1, 0x5e, 0xd7, 0xa5,
-	0x63, 0xf4, 0x7f, 0x62, 0xec, 0x76, 0x90, 0x96, 0xf6, 0x02, 0xc6, 0xba, 0x5e, 0xa6, 0x99, 0x9b,
-	0xf2, 0x07, 0x86, 0x72, 0x18, 0x6e, 0xbd, 0x06, 0x3a, 0xd2, 0x1b, 0xd1, 0xa2, 0x67, 0xfe, 0x99,
-	0x4f, 0xbf, 0x07, 0x00, 0x00, 0xff, 0xff, 0xe3, 0xad, 0x60, 0xf9, 0x42, 0x05, 0x00, 0x00,
+	// 634 bytes of a gzipped FileDescriptorProto
+	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4f, 0x6f, 0xd3, 0x4e,
+	0x10, 0x95, 0x6b, 0x3b, 0x7f, 0xc6, 0x49, 0xd3, 0xee, 0xaf, 0xed, 0xcf, 0xf4, 0x80, 0x8c, 0x55,
+	0xa1, 0x88, 0x3f, 0x46, 0x4a, 0xc5, 0x09, 0x0e, 0x40, 0x51, 0x25, 0x0e, 0x15, 0xb0, 0x2d, 0x67,
+	0xcb, 0x89, 0xb7, 0xed, 0x22, 0x7b, 0xd7, 0xda, 0x5d, 0x37, 0xe9, 0x57, 0xe2, 0xca, 0x97, 0xe2,
+	0xc8, 0x47, 0x40, 0x5e, 0x7b, 0x1d, 0x03, 0x29, 0x70, 0xf3, 0x9b, 0x79, 0x6f, 0x3c, 0x6f, 0x66,
+	0x6c, 0xf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x00,
+	0xff, 0xff, 0x0e, 0x2b, 0xec, 0x5d, 0x4e, 0x05, 0x00, 0x00,
 }

+ 6 - 6
pb/pb.proto

@@ -20,7 +20,7 @@ message Metadata {
 message BurndownSparseMatrixRow {
     // the first `len(column)` elements are stored,
     // the rest `number_of_columns - len(column)` values are zeros
-    repeated uint32 column = 1;
+    repeated uint32 columns = 1;
 }
 
 message BurndownSparseMatrix {
@@ -28,7 +28,7 @@ message BurndownSparseMatrix {
     int32 number_of_rows = 2;
     int32 number_of_columns = 3;
     // `len(row)` matches `number_of_rows`
-    repeated BurndownSparseMatrixRow row = 4;
+    repeated BurndownSparseMatrixRow rows = 4;
 }
 
 message CompressedSparseRowMatrix {
@@ -48,12 +48,12 @@ message Couples {
 }
 
 message TouchedFiles {
-    repeated int32 file = 1;  // values correspond to `file_couples::index`
+    repeated int32 files = 1;  // values correspond to `file_couples::index`
 }
 
 message DeveloperTouchedFiles {
     // order corresponds to `developer_couples::index`
-    repeated TouchedFiles developer = 1;
+    repeated TouchedFiles developers = 1;
 }
 
 message AnalysisResults {
@@ -62,10 +62,10 @@ message AnalysisResults {
     BurndownSparseMatrix burndown_project = 2;
 
     // this is included if `-files` was specified
-    repeated BurndownSparseMatrix burndown_file = 3;
+    repeated BurndownSparseMatrix burndown_files = 3;
 
     // these two are included if `-people` was specified
-    repeated BurndownSparseMatrix burndown_developer = 4;
+    repeated BurndownSparseMatrix burndown_developers = 4;
     // rows and cols order correspond to `burndown_developer`
     CompressedSparseRowMatrix developers_interaction = 5;
 

File diff ditekan karena terlalu besar
+ 500 - 0
pb/pb_pb2.py


+ 7 - 7
pb/utils.go

@@ -5,7 +5,7 @@ func ToBurndownSparseMatrix(matrix [][]int64, name string) *BurndownSparseMatrix
 	  Name: name,
 	  NumberOfRows: int32(len(matrix)),
 	  NumberOfColumns: int32(len(matrix[len(matrix)-1])),
-	  Row: make([]*BurndownSparseMatrixRow, len(matrix)),
+	  Rows: make([]*BurndownSparseMatrixRow, len(matrix)),
   }
   for i, status := range matrix {
 	  nnz := make([]uint32, 0, len(status))
@@ -22,11 +22,11 @@ func ToBurndownSparseMatrix(matrix [][]int64, name string) *BurndownSparseMatrix
 			  nnz = append(nnz, uint32(v))
 		  }
 	  }
-	  r.Row[i] = &BurndownSparseMatrixRow{
-		  Column: make([]uint32, len(nnz)),
+	  r.Rows[i] = &BurndownSparseMatrixRow{
+		  Columns: make([]uint32, len(nnz)),
 	  }
 	  for j := range nnz {
-		  r.Row[i].Column[j] = nnz[len(nnz) - 1 - j]
+		  r.Rows[i].Columns[j] = nnz[len(nnz) - 1 - j]
 	  }
 	}
 	return &r
@@ -42,15 +42,15 @@ func DenseToCompressedSparseRowMatrix(matrix [][]int64) *CompressedSparseRowMatr
 	}
 	r.Indptr[0] = 0
 	for _, row := range matrix {
+		nnz := 0
 		for x, col := range row {
-			nnz := 0
 			if col != 0 {
 				r.Data = append(r.Data, col)
 				r.Indices = append(r.Indices, int32(x))
 				nnz += 1
 			}
-			r.Indptr = append(r.Indptr, r.Indptr[len(r.Indptr) - 1] + int64(nnz))
 		}
+		r.Indptr = append(r.Indptr, r.Indptr[len(r.Indptr) - 1] + int64(nnz))
 	}
 	return &r
 }
@@ -68,8 +68,8 @@ func MapToCompressedSparseRowMatrix(matrix []map[int]int64) *CompressedSparseRow
 		for x, col := range row {
 			r.Data = append(r.Data, col)
 			r.Indices = append(r.Indices, int32(x))
-			r.Indptr = append(r.Indptr, r.Indptr[len(r.Indptr) - 1] + int64(len(row)))
 		}
+		r.Indptr = append(r.Indptr, r.Indptr[len(r.Indptr) - 1] + int64(len(row)))
 	}
 	return &r
 }