def main(args): comet_api = API() comet_files = Path(args.root_dir).glob("**/comet.url") exp_dict = {} df_list = [] df_keys = [] for path in comet_files: print(f"Retrieving data from {path}") with open(path, "r") as f: url = f.readline() key = url.split("/")[-1].strip() exp_dict.update({key: {"path": path}}) exp = comet_api.get_experiment(workspace=args.workspace, project_name=args.project, experiment=key) metrics = exp.get_metrics() df = metrics2df(metrics) df["path"] = path df_list.append(df) df_keys.append(path.parent) if args.save_each_csv: df.to_csv(path.parent / "comet.csv") df = pd.concat(df_list, keys=df_keys, names=["path", "step"]) if args.output_csv: df.to_csv(args.output_csv)
"Also grab the state dictionary of the optimizer at the end of the specified epoch" ) #XMUs9uI19KQNdYrQhuXPnAfpB args = parser.parse_args() experiment_key = args.experiment_key epoch_number = args.epoch_number apikey = args.api_key get_optimizer_weights = args.get_optimizer_weights output_directory = os.path.join(args.output_directory, experiment_key) if not os.path.isdir(output_directory): os.makedirs(output_directory) api = API(api_key=apikey) experiment: APIExperiment = api.get_experiment("electric-turtle", "probabilisticbeziercurves", experiment_key) assetlist = experiment.get_asset_list() assetdict = {d['fileName']: d['assetId'] for d in assetlist} #lookahead_indices = int(experiment.get_parameters_summary(parameter="lookahead_indices")["valueCurrent"]) print("Getting hyperparameters from comet") datasets_file_name = "datasets.yaml" experiment_file_name = "experiment_config.yaml" config_file_name = "model_config.yaml" config_yaml = experiment.get_asset(assetdict[config_file_name], return_type="text") config = yaml.load(io.StringIO(config_yaml), Loader=yaml.SafeLoader) print("Got config from comet") print(config) datasets_yaml = experiment.get_asset(assetdict[datasets_file_name],
} #XMUs9uI19KQNdYrQhuXPnAfpB args = parser.parse_args() experiment_key = args.experiment_key epoch_number = args.epoch_number restkey = args.restkey output_directory = os.path.join(args.output_directory, experiment_key + "_from_comet") if not os.path.isdir(output_directory): os.makedirs(output_directory) if restkey is None: api = API() else: api = API(rest_api_key=restkey) experiment: APIExperiment = api.get_experiment("electric-turtle", "deepracingposepredictor", experiment_key) assetlist = experiment.get_asset_list() assetdict = {d['fileName']: d['assetId'] for d in assetlist} #get network weight file weightfilename = "epoch_%d_params.pt" % (epoch_number, ) optimizerfilename = "epoch_%d_optimizer.pt" % (epoch_number, ) print("Getting network weights from comet") params_binary = experiment.get_asset(assetdict[weightfilename]) #get optimizer weight file print("Getting optimizer weights from comet") optimizer_binary = experiment.get_asset(assetdict[optimizerfilename])
parser.add_argument("--epoch_number", type=int, required=False, default=100, help="Experiment key to grab from comet.") parser.add_argument("--output_directory", type=str, required=False, default=".", help="Where to put the config and data files.") #XMUs9uI19KQNdYrQhuXPnAfpB args = parser.parse_args() experiment_key = args.experiment_key epoch_number = args.epoch_number restkey = args.restkey output_directory = os.path.join(args.output_directory, experiment_key + "_from_comet") if not os.path.isdir(output_directory): os.makedirs(output_directory) if restkey is None: api = API() else: api = API(rest_api_key=restkey) experiment : APIExperiment = api.get_experiment("electric-turtle", "deepracingpilotnet", experiment_key) assetlist = experiment.get_asset_list() assetdict = {d['fileName']: d['assetId'] for d in assetlist} #get network weight file weightfilename = "pilotnet_epoch_%d_params.pt" %(epoch_number,) print("Getting network weights from comet") params_binary = experiment.get_asset(assetdict[weightfilename]) outputweightfile = os.path.join(output_directory,weightfilename) with open(outputweightfile, 'wb') as f: f.write(params_binary) #get parameters
help="Where to put the config and data files.") #XMUs9uI19KQNdYrQhuXPnAfpB args = parser.parse_args() experiment_key = args.experiment_key epoch_number = args.epoch_number restkey = args.restkey output_directory = os.path.join(args.output_directory, experiment_key) if not os.path.isdir(output_directory): os.makedirs(output_directory) if restkey is None: api = API() else: api = API(rest_api_key=restkey) experiment: APIExperiment = api.get_experiment("electric-turtle", "deepracingcnnlstm", experiment_key) assetlist = experiment.get_asset_list() assetdict = {d['fileName']: d['assetId'] for d in assetlist} #print(assetdict) #get network weight file weightfilename = "CNNLSTM_epoch_%d_params.pt" % (epoch_number, ) weightfilenamealt = "epoch_%d_params.pt" % (epoch_number, ) weightfilenamealtalt = "pilotnet_epoch_%d_params.pt" % (epoch_number, ) print("Getting network weights from comet") try: params_binary = experiment.get_asset(assetdict[weightfilename]) except KeyError as e: try: params_binary = experiment.get_asset(assetdict[weightfilename])