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

Function monkey_run

opencompass/runners/local_api.py:26–52  ·  view source on GitHub ↗

Hack for infer task run, add tokens for multiprocess.

(self, tokens: SyncManager.Semaphore)

Source from the content-addressed store, hash-verified

24
25
26def monkey_run(self, tokens: SyncManager.Semaphore):
27 """Hack for infer task run, add tokens for multiprocess."""
28 self.logger.info(f'Task {task_abbr_from_cfg(self.cfg)}')
29 for model_cfg, dataset_cfgs in zip(self.model_cfgs, self.dataset_cfgs):
30 self.max_out_len = model_cfg.get('max_out_len', None)
31 self.min_out_len = model_cfg.get('min_out_len', None)
32 self.batch_size = model_cfg.get('batch_size', None)
33 self.model = build_model_from_cfg(model_cfg)
34 # add global tokens for concurrents
35 assert self.model.is_api, 'Only API model is supported.'
36 self.model.tokens = tokens
37
38 for dataset_cfg in dataset_cfgs:
39 self.model_cfg = model_cfg
40 self.dataset_cfg = dataset_cfg
41 self.infer_cfg = self.dataset_cfg['infer_cfg']
42 self.dataset = build_dataset_from_cfg(self.dataset_cfg)
43 self.sub_cfg = {
44 'models': [self.model_cfg],
45 'datasets': [[self.dataset_cfg]],
46 }
47 out_path = get_infer_output_path(
48 self.model_cfg, self.dataset_cfg,
49 osp.join(self.work_dir, 'predictions'))
50 if osp.exists(out_path):
51 continue
52 self._inference()
53
54
55old_stdout = sys.stdout

Callers

nothing calls this directly

Calls 6

task_abbr_from_cfgFunction · 0.90
build_model_from_cfgFunction · 0.90
build_dataset_from_cfgFunction · 0.90
get_infer_output_pathFunction · 0.90
getMethod · 0.80
_inferenceMethod · 0.45

Tested by

no test coverage detected