Skip to content

Commit af09326

Browse files
Munsiobauersimon
authored andcommitted
CLI flag for specifying a run ID starting index to be able to distribute runs
Part of #403
1 parent 67310ca commit af09326

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

cmd/eval-dev-quality/cmd/evaluate.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ type Evaluate struct {
7373
Configuration string `long:"configuration" description:"Configuration file to set up an evaluation run."`
7474
// ExecutionTimeout holds the timeout for an execution.
7575
ExecutionTimeout uint `long:"execution-timeout" description:"Execution timeout for compilation and tests in minutes." default:"5"`
76+
// RunIDStartsAt holds the offset increment for the run id used in creating the result folders.
77+
RunIDStartsAt uint `long:"run-id-starts-at" description:"Sets the starting index for the run ID." default:"1"`
7678
// Runs holds the number of runs to perform.
7779
Runs uint `long:"runs" description:"Number of runs to perform." default:"1"`
7880
// RunsSequential indicates that interleaved runs are disabled and runs are performed sequentially.
@@ -175,6 +177,8 @@ func (command *Evaluate) Initialize(args []string) (evaluationContext *evaluate.
175177
language.DefaultExecutionTimeout = time.Duration(command.ExecutionTimeout) * time.Minute
176178
}
177179

180+
evaluationContext.RunIDStartsAt = command.RunIDStartsAt
181+
178182
if command.Runs == 0 {
179183
command.logger.Panicf("number of configured runs must be greater than zero")
180184
}

evaluate/evaluate.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type Context struct {
3838
// TestdataPath determines the testdata path where all repositories reside grouped by languages.
3939
TestdataPath string
4040

41+
// RunIDStartsAt holds the run ID starting index created when running a evaluation multiple times.
42+
RunIDStartsAt uint
4143
// Runs holds the number of runs to perform.
4244
Runs uint
4345
// RunsSequential indicates that interleaved runs are disabled and runs are performed sequentially.
@@ -148,6 +150,7 @@ func Evaluate(ctx *Context) {
148150
} else {
149151
runCount = rl + 1
150152
}
153+
runID := ctx.RunIDStartsAt + runCount - 1
151154

152155
if err := temporaryRepository.Reset(logger); err != nil {
153156
logger.Panicf("ERROR: unable to reset temporary repository path: %s", err)
@@ -177,7 +180,7 @@ func Evaluate(ctx *Context) {
177180
}
178181

179182
// Write the task assessment to the evaluation CSV file.
180-
if err := evaluationFile.WriteEvaluationRecord(model, language, temporaryRepository.Name(), runCount, assessment); err != nil {
183+
if err := evaluationFile.WriteEvaluationRecord(model, language, temporaryRepository.Name(), runID, assessment); err != nil {
181184
logger.Panicf("ERROR: cannot write evaluation record: %s", err)
182185
}
183186
}
@@ -271,6 +274,7 @@ func Evaluate(ctx *Context) {
271274
} else {
272275
runCount = rl + 1
273276
}
277+
runID := ctx.RunIDStartsAt + runCount - 1
274278

275279
if err := temporaryRepository.Reset(logger); err != nil {
276280
logger.Panicf("ERROR: unable to reset temporary repository path: %s", err)
@@ -292,7 +296,7 @@ func Evaluate(ctx *Context) {
292296
}
293297

294298
// Write the task assessment to the evaluation CSV file.
295-
if err := evaluationFile.WriteEvaluationRecord(model, language, temporaryRepository.Name(), runCount, assessment); err != nil {
299+
if err := evaluationFile.WriteEvaluationRecord(model, language, temporaryRepository.Name(), runID, assessment); err != nil {
296300
logger.Panicf("ERROR: cannot write evaluation record: %s", err)
297301
}
298302
}

evaluate/evaluate_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
modeltesting "github.com/symflower/eval-dev-quality/model/testing"
3030
"github.com/symflower/eval-dev-quality/provider"
3131
providertesting "github.com/symflower/eval-dev-quality/provider/testing"
32+
"github.com/symflower/gota/dataframe"
33+
"github.com/symflower/gota/series"
3234
)
3335

3436
var (
@@ -1235,6 +1237,7 @@ func TestEvaluate(t *testing.T) {
12351237
repositoryPath,
12361238
},
12371239

1240+
RunIDStartsAt: 11,
12381241
Runs: 3,
12391242
RunsSequential: false,
12401243
},
@@ -1395,7 +1398,14 @@ func TestEvaluate(t *testing.T) {
13951398
assert.Equal(t, 1, strings.Count(data, "creating temporary repository"), "create only one temporary repository")
13961399
},
13971400
filepath.Join(string(evaluatetask.IdentifierWriteTests), log.CleanModelNameForFileSystem(mockedModelID), "golang", "golang", "plain", "evaluation.log"): nil,
1398-
"evaluation.csv": nil,
1401+
"evaluation.csv": func(t *testing.T, filePath string, data string) {
1402+
dataFrame := dataframe.ReadCSV(strings.NewReader(data))
1403+
assert.NoError(t, dataFrame.Err)
1404+
1405+
expectedColumnRun := series.New([]int{11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13}, series.Int, "run")
1406+
actualColumnRun := dataFrame.Col("run")
1407+
assert.Equal(t, expectedColumnRun, actualColumnRun)
1408+
},
13991409
},
14001410
})
14011411
}
@@ -1425,6 +1435,7 @@ func TestEvaluate(t *testing.T) {
14251435
repositoryPath,
14261436
},
14271437

1438+
RunIDStartsAt: 21,
14281439
Runs: 3,
14291440
RunsSequential: true,
14301441
},
@@ -1585,7 +1596,14 @@ func TestEvaluate(t *testing.T) {
15851596
assert.Contains(t, data, "\"msg\":\"starting run\",\"count\":3,\"total\":3,")
15861597
assert.NotRegexp(t, `\\\"msg\\\":\\\"starting run\\\",\\\"count\\\":\d+,\\\"total\\\":\d+\}`, data)
15871598
},
1588-
"evaluation.csv": nil,
1599+
"evaluation.csv": func(t *testing.T, filePath string, data string) {
1600+
dataFrame := dataframe.ReadCSV(strings.NewReader(data))
1601+
assert.NoError(t, dataFrame.Err)
1602+
1603+
expectedColumnRun := series.New([]int{21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23}, series.Int, "run")
1604+
actualColumnRun := dataFrame.Col("run")
1605+
assert.Equal(t, expectedColumnRun, actualColumnRun)
1606+
},
15891607
},
15901608
})
15911609
}

0 commit comments

Comments
 (0)