()
| 159 | |
| 160 | |
| 161 | def main(): |
| 162 | args = parse_args() |
| 163 | config = load_config(args.config) |
| 164 | logger.info(f"Successfully loaded configuration from: {args.config}") |
| 165 | |
| 166 | # Extract settings |
| 167 | plot_cfg = config.get("plot_configs", {}) |
| 168 | exps_cfg = config.get("exps_configs", {}) |
| 169 | |
| 170 | output_path = plot_cfg.get("output_path", "./plots") |
| 171 | scalar_keys_to_plot = plot_cfg.get("scalar_keys", []) |
| 172 | |
| 173 | if not scalar_keys_to_plot: |
| 174 | logger.warning("No 'scalar_keys' specified in 'plot_configs'.") |
| 175 | return |
| 176 | |
| 177 | # Build scalar location maps for each experiment group |
| 178 | scalar_maps = {} |
| 179 | for exp_name, exp_details in exps_cfg.items(): |
| 180 | logger.info(f"Scanning for scalars in experiment group: {exp_name}") |
| 181 | for path in exp_details.get("paths", []): |
| 182 | if os.path.isdir(path): |
| 183 | scalar_maps[exp_name] = build_scalar_location_map(path) |
| 184 | if scalar_maps[exp_name]: |
| 185 | logger.info( |
| 186 | f"Scalar map for '{exp_name}' created successfully from path: {path}" |
| 187 | ) |
| 188 | break |
| 189 | if exp_name not in scalar_maps: |
| 190 | logger.warning( |
| 191 | f"Could not create a scalar map for '{exp_name}'. All paths might be invalid." |
| 192 | ) |
| 193 | scalar_maps[exp_name] = {} |
| 194 | |
| 195 | # Main Loop: Generate one plot for each specified scalar key |
| 196 | for scalar_key in scalar_keys_to_plot: |
| 197 | logger.info(f"\n--- Generating plot for scalar_key: '{scalar_key}' ---") |
| 198 | experiments_data_for_this_plot = {} |
| 199 | |
| 200 | for exp_name, exp_details in exps_cfg.items(): |
| 201 | scalar_map = scalar_maps.get(exp_name, {}) |
| 202 | if scalar_key not in scalar_map: |
| 203 | logger.warning( |
| 204 | f"Scalar '{scalar_key}' not found for experiment '{exp_name}'. Skipping this curve." |
| 205 | ) |
| 206 | continue |
| 207 | |
| 208 | target_folder = scalar_map[scalar_key] |
| 209 | logger.info( |
| 210 | f"Processing '{exp_name}': Found '{scalar_key}' in '{target_folder}' folder." |
| 211 | ) |
| 212 | |
| 213 | all_runs_data = [] |
| 214 | for path in exp_details.get("paths", []): |
| 215 | log_dir = os.path.join(path, "monitor", "tensorboard", target_folder) |
| 216 | if os.path.isdir(log_dir): |
| 217 | run_data = parse_tensorboard_log(log_dir, scalar_key) |
| 218 | if not run_data.empty: |
no test coverage detected