github.com/distbuild/reclient@v0.0.0-20240401075343-3de72e395564/experiments/cmd/runner/main.go (about)

     1  // Copyright 2023 Google LLC
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package main is the main package for the experiment runner binary.
    16  //
    17  // Use the runner tool to run experiments defined in an experiment textproto
    18  // file. Example:
    19  //
    20  // bazelisk run //experiments/cmd/runner:runner -- --exp_def_path=$PWD/experiments/examples/multi-region.textproto
    21  //
    22  // To view logging info as the experiment is running, run with --alsologtostderr.
    23  package main
    24  
    25  import (
    26  	"flag"
    27  	"fmt"
    28  
    29  	"github.com/bazelbuild/reclient/experiments/internal/pkg/runner"
    30  
    31  	log "github.com/golang/glog"
    32  )
    33  
    34  var (
    35  	gcpProject   = flag.String("gcp_project", "foundry-x-experiments", "Name of the GCP project to run experiments on")
    36  	resBucket    = flag.String("results_bucket", "foundry-x-experiments-results", "Name of the GCS bucket to store results")
    37  	expDefPath   = flag.String("exp_def_path", "", "Path to the .textproto file containing the experiment definition")
    38  	dateSuffix   = flag.String("date_suffix", "", "Date string suffix to use instead of checking the current time")
    39  	logFrequency = flag.Int("log_frequency", -1, "Time between polling the log file for updates, in seconds. Default 5 for virtual machine experiments, 0 (disabled) for workstation experiments")
    40  )
    41  
    42  func main() {
    43  	flag.Parse()
    44  	expName, err := runner.RunExperiment(*expDefPath, *dateSuffix, *gcpProject, *resBucket, *logFrequency)
    45  	if err != nil {
    46  		log.Fatalf("Experiment did not run succesfully: %v", err)
    47  	}
    48  	fmt.Println("experiment run successfully.")
    49  	fmt.Printf("you can store experiment results in bigquery for querying. "+
    50  		"see experiments/cmd/tabulator for more info. example: \n"+
    51  		"bazelisk run //experiments/cmd/tabulator:tabulator -- --experiment_name=%v\n", expName)
    52  }