MCPcopy Create free account
hub / github.com/InternScience/SciReason / main

Function main

opencompass/cli/main.py:247–439  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

245
246
247def main():
248 args = parse_args()
249 if args.num_gpus is not None:
250 raise ValueError('The `--num-gpus` argument is deprecated, please use '
251 '`--hf-num-gpus` to describe number of gpus used for '
252 'the HuggingFace model instead.')
253
254 if args.dry_run:
255 args.debug = True
256 # initialize logger
257 logger = get_logger(log_level='DEBUG' if args.debug else 'INFO')
258
259 cfg = get_config_from_arg(args)
260 if args.work_dir is not None:
261 cfg['work_dir'] = args.work_dir
262 else:
263 cfg.setdefault('work_dir', os.path.join('outputs', 'default'))
264
265 # cfg_time_str defaults to the current time
266 cfg_time_str = dir_time_str = datetime.now().strftime('%Y%m%d_%H%M%S')
267 if args.reuse:
268 if args.reuse == 'latest':
269 if not os.path.exists(cfg.work_dir) or not os.listdir(
270 cfg.work_dir):
271 logger.warning('No previous results to reuse!')
272 else:
273 dirs = os.listdir(cfg.work_dir)
274 dir_time_str = sorted(dirs)[-1]
275 else:
276 dir_time_str = args.reuse
277 logger.info(f'Reusing experiements from {dir_time_str}')
278 elif args.mode in ['eval', 'viz'] and not args.read_from_station:
279 raise ValueError(
280 'You must specify -r or --reuse, or you have to specify '
281 '--read-from-station and --station-path when running in eval '
282 'or viz mode!')
283
284 # update "actual" work_dir
285 cfg['work_dir'] = osp.join(cfg.work_dir, dir_time_str)
286 current_workdir = cfg['work_dir']
287 logger.info(f'Current exp folder: {current_workdir}')
288
289 os.makedirs(osp.join(cfg.work_dir, 'configs'), exist_ok=True)
290
291 # dump config
292 output_config_path = osp.join(cfg.work_dir, 'configs',
293 f'{cfg_time_str}_{os.getpid()}.py')
294 cfg.dump(output_config_path)
295 # Config is intentally reloaded here to avoid initialized
296 # types cannot be serialized
297 cfg = Config.fromfile(output_config_path, format_python_code=False)
298
299 # get existed results from station
300 if args.read_from_station:
301 existing_results_list = read_from_station(cfg, args)
302 rs_exist_results = [comb['combination'] for comb in existing_results_list]
303 cfg['rs_exist_results'] = rs_exist_results
304

Callers 2

run.pyFile · 0.90
main.pyFile · 0.70

Calls 14

get_loggerFunction · 0.90
get_config_from_argFunction · 0.90
read_from_stationFunction · 0.90
LarkReporterClass · 0.90
pretty_print_configFunction · 0.90
fill_infer_cfgFunction · 0.90
fill_eval_cfgFunction · 0.90
save_to_stationFunction · 0.90
build_from_cfgFunction · 0.90
getMethod · 0.80
postMethod · 0.80
buildMethod · 0.80

Tested by

no test coverage detected