Get all the sweep parameters and the corresponding results

Hi everyone,

I’m trying to use wand.sweep for hyperparameter tuning.
I’m wondering if I can get all the hyperparameters and the corresponding results in my code.

The purpose is that I already saved the best model for each run automatically in my train() function.
After the sweep finished, I’d like to validate the top 3 models on my isolated test dataset.
So, I want to get the top 3 parameter groups so that I can get those models from my folder.

Here’s my code:

if __name__ == '__main__':
    parser = get_parser()
    args = parser.parse_args()
    myConfig = MyConfig(**vars(args))
    print(myConfig.print_attr())

   
    """
    wandb configuration
    """
    sweep_config['parameters'] = {
        'LDs': {
            'distribution': 'uniform',
            'min': 0.6,
            'max': 1
        },
        'LRs': {
            'distribution': 'uniform',
            'min': 1e-6,
            'max': 1e-3
        },
        'WDs': {
            'distribution': 'uniform',
            'min': 1e-5,
            'max': 1e-1
        },
        'Bs': {
            'values': [32, 64, 128]  # Explore other batch sizes
        },
    }

    sweep_id = wandb.sweep(sweep_config, project=myConfig.wandb_name)
    wandb.agent(sweep_id, train_each_hyperparameter, count=myConfig.num_samples)

    # todo
    run_params_results=getAllRuns() ?
    run_params_results.sort( run_params_results['results'] ) ?
    run_index=0
    for params, results in run_params_results.items():
        cur_model=getModelByParams(params) # don't worry about this. It should be my own function.
        run_index+=1
        if run_index>3:
              break
       

Basically, my main question would be this line:

 run_params_results=getAllRuns() ?
  1. Will wandb.agent(sweep_id, train_func) block until the sweep is finished?
  2. How can I get all runs to use like the getAllRuns() above?

Thanks for your time.