Skip to content
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

Add additional CSV files that sum up: overall, per-language #83

Closed
4 tasks done
zimmski opened this issue Apr 28, 2024 · 0 comments
Closed
4 tasks done

Add additional CSV files that sum up: overall, per-language #83

zimmski opened this issue Apr 28, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@zimmski
Copy link
Member

zimmski commented Apr 28, 2024

Tasks:

  • Introduce an Interface on the Assessment collection types for printing them in a CSV
  • Collapse the Assessment list by Language and Model
  • Generate a summary CSV for each Language by Model
  • Generate a summary CSV by Model

This is what we generated for v0.4.0 2088210 with the following script. However, we need to sum up ALL columns. Not just the score. We did that but it did not land in the CSVs.

package main

import (
	"encoding/csv"
	"fmt"
	"os"
	"sort"
	"strconv"

	"golang.org/x/exp/maps"
)

type data struct {
	score             int64
	responseNoError   int64
	responseNotEmpty  int64
	responseWithCode  int64
	filesExecuted     int64
	coverageStatement int64
	responseNoExcess  int64
}

func main() {
	file, err := os.Open("docs/reports/v0.4.0/evaluation.csv")
	if err != nil {
		panic(err)
	}

	rows, err := csv.NewReader(file).ReadAll()
	if err != nil {
		panic(err)
	}

	modelsSummed := map[string]*data{}
	golangSummed := map[string]*data{}
	javaSummed := map[string]*data{}

	for i := 1; i < len(rows); i++ {
		row := rows[i]
		score, err := strconv.ParseInt(row[3], 10, 64)
		if err != nil {
			panic(err)
		}
		coverageStatement, err := strconv.ParseInt(row[4], 10, 64)
		if err != nil {
			panic(err)
		}
		filesExecuted, err := strconv.ParseInt(row[5], 10, 64)
		if err != nil {
			panic(err)
		}
		responseNoError, err := strconv.ParseInt(row[6], 10, 64)
		if err != nil {
			panic(err)
		}
		responseNoExcess, err := strconv.ParseInt(row[7], 10, 64)
		if err != nil {
			panic(err)
		}
		responseNotEmpty, err := strconv.ParseInt(row[8], 10, 64)
		if err != nil {
			panic(err)
		}
		responseWithCode, err := strconv.ParseInt(row[9], 10, 64)
		if err != nil {
			panic(err)
		}
		r, ok := modelsSummed[row[0]]
		if !ok {
			r = &data{}
			modelsSummed[row[0]] = r
		}
		r.score += score
		r.coverageStatement += coverageStatement
		r.filesExecuted += filesExecuted
		r.responseNoError += responseNoError
		r.responseNoExcess += responseNoExcess
		r.responseNotEmpty += responseNotEmpty
		r.responseWithCode += responseWithCode
		if row[1] == "golang" {
			r, ok := golangSummed[row[0]]
			if !ok {
				r = &data{}
				golangSummed[row[0]] = r
			}
			r.score += score
			r.coverageStatement += coverageStatement
			r.filesExecuted += filesExecuted
			r.responseNoError += responseNoError
			r.responseNoExcess += responseNoExcess
			r.responseNotEmpty += responseNotEmpty
			r.responseWithCode += responseWithCode
		} else {
			r, ok := javaSummed[row[0]]
			if !ok {
				r = &data{}
				javaSummed[row[0]] = r
			}
			r.score += score
			r.coverageStatement += coverageStatement
			r.filesExecuted += filesExecuted
			r.responseNoError += responseNoError
			r.responseNoExcess += responseNoExcess
			r.responseNotEmpty += responseNotEmpty
			r.responseWithCode += responseWithCode
		}
	}

	{
		fmt.Println("Overall")
		names := maps.Keys(modelsSummed)
		sort.Strings(names)
		fmt.Println("model,score,response-no-error,response-not-empty,response-with-code,files-executed,coverage-statement,response-no-excess")
		for _, name := range names {
			r := modelsSummed[name]
			fmt.Printf("%s,%d,%d,%d,%d,%d,%d,%d\n", name, r.score, r.responseNoError, r.responseNotEmpty, r.responseWithCode, r.filesExecuted, r.coverageStatement, r.responseNoExcess)
		}
	}
	{
		fmt.Println("Golang")
		names := maps.Keys(golangSummed)
		sort.Strings(names)
		fmt.Println("model,score,response-no-error,response-not-empty,response-with-code,files-executed,coverage-statement,response-no-excess")
		for _, name := range names {
			r := golangSummed[name]
			fmt.Printf("%s,%d,%d,%d,%d,%d,%d,%d\n", name, r.score, r.responseNoError, r.responseNotEmpty, r.responseWithCode, r.filesExecuted, r.coverageStatement, r.responseNoExcess)
		}
	}
	{
		fmt.Println("Java")
		names := maps.Keys(javaSummed)
		sort.Strings(names)
		fmt.Println("model,score,response-no-error,response-not-empty,response-with-code,files-executed,coverage-statement,response-no-excess")
		for _, name := range names {
			r := javaSummed[name]
			fmt.Printf("%s,%d,%d,%d,%d,%d,%d,%d\n", name, r.score, r.responseNoError, r.responseNotEmpty, r.responseWithCode, r.filesExecuted, r.coverageStatement, r.responseNoExcess)
		}
	}
}

@zimmski zimmski added the enhancement New feature or request label Apr 28, 2024
@zimmski zimmski added this to the v0.5.0 milestone Apr 28, 2024
@zimmski zimmski assigned Munsio and unassigned bauersimon May 6, 2024
@Munsio Munsio changed the title Add additinal CSV files that sum up: overall, per-language Add additional CSV files that sum up: overall, per-language May 6, 2024
Munsio added a commit that referenced this issue May 6, 2024
…dencies

When we refactor the index of "AssessmentPerModel" to be a pointer to a model instead of a string we would run into cyclic dependencies.

Part of #83
Munsio added a commit that referenced this issue May 6, 2024
Munsio added a commit that referenced this issue May 6, 2024
Munsio added a commit that referenced this issue May 7, 2024
Change the Index of the "AssessmentPerModel" map to be a pointer to a Model to avoid unexpected overrides when dealing with string indexes.

Part of #83
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
"WalkByScore" function is now a method of "AssessmentPerModel"
Change the Index of the "AssessmentPerModel" map to be a pointer to a Model to avoid unexpected overrides when dealing with string indexes.

Part of #83
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
Munsio added a commit that referenced this issue May 7, 2024
@zimmski zimmski mentioned this issue May 16, 2024
45 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants