-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_cmd.py
executable file
·22 lines (18 loc) · 5.02 KB
/
convert_cmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import json
config_str = '''{"gpus":{"desc":null,"value":null},"ipus":{"desc":null,"value":null},"loss":{"desc":null,"value":"CPNLL"},"mode":{"desc":null,"value":"train"},"_wandb":{"desc":null,"value":{"m":[{"1":"trainer/global_step","6":[3]},{"1":"val_loss","5":1,"6":[1]},{"1":"val_loss_true","5":1,"6":[1]},{"1":"val_mae","5":1,"6":[1]},{"1":"val_rmse","5":1,"6":[1]},{"1":"val_mse","5":1,"6":[1]},{"1":"epoch","5":1,"6":[1]},{"1":"train_loss","5":1,"6":[1]},{"1":"train_loss_true","5":1,"6":[1]},{"1":"train_mae","5":1,"6":[1]},{"1":"train_rmse","5":1,"6":[1]},{"1":"train_mse","5":1,"6":[1]},{"1":"test_loss","5":1,"6":[1]},{"1":"test_loss_true","5":1,"6":[1]},{"1":"test_mae","5":1,"6":[1]},{"1":"test_rmse","5":1,"6":[1]},{"1":"test_mse","5":1,"6":[1]},{"1":"test_predictions_WEBSTER._type","5":1,"6":[1]},{"1":"test_predictions_WEBSTER.sha256","5":1,"6":[1]},{"1":"test_predictions_WEBSTER.size","5":1,"6":[1]},{"1":"test_predictions_WEBSTER.path","5":1,"6":[1]}],"t":{"1":[1,9,41,51,55,77],"2":[1,9,41,51,55,77],"3":[2,5,7,23],"4":"3.8.2","5":"0.14.0","8":[5]},"framework":"lightning","start_time":1683645249.557247,"cli_version":"0.14.0","is_jupyter_run":false,"python_version":"3.8.2","is_kaggle_kernel":false}},"logger":{"desc":null,"value":true},"cluster":{"desc":null,"value":"WEBSTER"},"devices":{"desc":null,"value":1},"loss_fn":{"desc":null,"value":"censored_poisson_negative_log_likelihood"},"plugins":{"desc":null,"value":null},"val_end":{"desc":null,"value":"2019-05-02"},"censored":{"desc":null,"value":true},"max_time":{"desc":null,"value":null},"profiler":{"desc":null,"value":null},"strategy":{"desc":null,"value":null},"test_end":{"desc":null,"value":"2019-06-30"},"amp_level":{"desc":null,"value":null},"benchmark":{"desc":null,"value":null},"input_dim":{"desc":null,"value":8},"max_steps":{"desc":null,"value":-1},"min_steps":{"desc":null,"value":null},"num_nodes":{"desc":null,"value":1},"precision":{"desc":null,"value":32},"tpu_cores":{"desc":null,"value":null},"train_end":{"desc":null,"value":"2019-01-01"},"batch_size":{"desc":null,"value":16},"covariates":{"desc":null,"value":true},"dataloader":{"desc":null,"value":"EVChargersDataset"},"hidden_dim":{"desc":null,"value":44},"max_epochs":{"desc":null,"value":30},"min_epochs":{"desc":null,"value":null},"model_name":{"desc":null,"value":"LSTM"},"num_layers":{"desc":null,"value":1},"pretrained":{"desc":null,"value":null},"accelerator":{"desc":null,"value":"gpu"},"amp_backend":{"desc":null,"value":null},"train_start":{"desc":null,"value":"2017-01-01"},"auto_lr_find":{"desc":null,"value":false},"censor_level":{"desc":null,"value":"2"},"fast_dev_run":{"desc":null,"value":false},"weight_decay":{"desc":null,"value":0.06622145460281466},"forecast_lead":{"desc":null,"value":1},"learning_rate":{"desc":null,"value":0.0005661019045297409},"num_processes":{"desc":null,"value":null},"censor_dynamic":{"desc":null,"value":true},"detect_anomaly":{"desc":null,"value":false},"inference_mode":{"desc":null,"value":true},"sync_batchnorm":{"desc":null,"value":false},"overfit_batches":{"desc":null,"value":0},"sequence_length":{"desc":null,"value":336},"track_grad_norm":{"desc":null,"value":-1},"auto_select_gpus":{"desc":null,"value":null},"default_root_dir":{"desc":null,"value":null},"forecast_horizon":{"desc":null,"value":1},"save_predictions":{"desc":null,"value":true},"gradient_clip_val":{"desc":null,"value":null},"limit_val_batches":{"desc":null,"value":null},"log_every_n_steps":{"desc":null,"value":50},"multiple_stations":{"desc":null,"value":false},"limit_test_batches":{"desc":null,"value":null},"val_check_interval":{"desc":null,"value":null},"enable_progress_bar":{"desc":null,"value":true},"limit_train_batches":{"desc":null,"value":null},"move_metrics_to_cpu":{"desc":null,"value":false},"replace_sampler_ddp":{"desc":null,"value":true},"enable_checkpointing":{"desc":null,"value":true},"enable_model_summary":{"desc":null,"value":true},"num_sanity_val_steps":{"desc":null,"value":2},"auto_scale_batch_size":{"desc":null,"value":false},"limit_predict_batches":{"desc":null,"value":null},"resume_from_checkpoint":{"desc":null,"value":null},"accumulate_grad_batches":{"desc":null,"value":null},"check_val_every_n_epoch":{"desc":null,"value":1},"gradient_clip_algorithm":{"desc":null,"value":null},"multiple_trainloader_mode":{"desc":null,"value":"max_size_cycle"},"reload_dataloaders_every_n_epochs":{"desc":null,"value":0}}'''
config = json.loads(config_str)
def extract_command_line_args(config):
args = []
for key, value in config.items():
if not isinstance(value, dict) or "desc" not in value or "value" not in value or '_wandb' in key or 'loss_fn' in key or 'node_features' in key:
continue
if value["value"] is not None:
if isinstance(value['value'], bool) and value['value'] == True:
args.append(f"--{key}")
elif value['value'] == False:
continue
else:
args.append(f"--{key}={value['value']}")
return " ".join(args)
command_line_args = extract_command_line_args(config)
print('python main.py ' + command_line_args)