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

Allow for anchor net in regression testing. #87

Open
AlexisOlson opened this issue Feb 25, 2019 · 3 comments
Open

Allow for anchor net in regression testing. #87

AlexisOlson opened this issue Feb 25, 2019 · 3 comments

Comments

@AlexisOlson
Copy link

To allow anchor net to be avaiable to test against similar to the code in lczero-server/main.go here:

[...]
	// Regression tests for current best.  Done here because the 'end of match' code logic isn't thread safe, so could create matches multiple times.
	var prevNetwork1 db.Network
	err = db.GetDB().Where("network_number = ?", bestNetwork.NetworkNumber-3).First(&prevNetwork1).Error
	if err == nil {
		createMatch(trainingRun, &prevNetwork1, true, string(params[:]))
	}
	var prevNetwork2 db.Network
	err = db.GetDB().Where("network_number = ?", bestNetwork.NetworkNumber-10).First(&prevNetwork2).Error
	if err == nil {
		createMatch(trainingRun, &prevNetwork2, true, string(params[:]))
	}
[...]

the desired network would need to be available. The following code in lczero-client/lc0_main.go deletes old networks:

[...]
func removeAllExcept(dir string, sha string, keepTime string) error {
	files, err := ioutil.ReadDir(dir)
	if err != nil {
		return err
	}
	for _, file := range files {
		if file.Name() == sha {
			continue
		}
		timeLimit, _ := time.ParseDuration(keepTime)
		if time.Since(file.ModTime()) < timeLimit {
			continue
		}
		fmt.Printf("Removing %v\n", file.Name())
		err := os.RemoveAll(filepath.Join(dir, file.Name()))
		if err != nil {
			return err
		}
	}
	return nil
}
[...]

However, it should be relatively simple to include a condition to not delete specific networks. E.g.

		if file.Name() == "5c222ccd1ccbed2666b3a8ef94d8833d386d2168d51c3e99a0a3fc37a56d2569" {
			continue
		}

It would probably be better to store the sha in a variable declaration or a configuration file.

@borg323
Copy link
Member

borg323 commented Feb 26, 2019

Since we already have the keepTime value from the server, the easiest thing to do is use os.Chtimes() to update the modification time of the net when used for a match. So every net that is used inside the keepTime window will not be deleted, without any hard-coding.
An alternative is to periodically get a touch value from the server and update the modification time of the specified net (if present).

@AlexisOlson
Copy link
Author

So would it make sense to use Chtimes in the if testonly bit of the createMatch function or is there a better place to do that?

func createMatch(trainingRun *db.TrainingRun, network *db.Network, testonly bool, params string) error {
	match := db.Match{
		TrainingRunID: trainingRun.ID,
		CandidateID:   network.ID,
		CurrentBestID: trainingRun.BestNetworkID,
		Done:          false,
		GameCap:       config.Config.Matches.Games,
		Parameters:    params,
	}
	if testonly {
		match.TestOnly = true
	}
	return db.GetDB().Create(&match).Error
}

@borg323
Copy link
Member

borg323 commented Feb 28, 2019

I think the best place is inside getNetwork(), right before https://github.com/LeelaChessZero/lczero-client/blob/master/lc0_main.go#L725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants