MCPcopy Create free account
hub / github.com/OpenBMB/AgentCPM-GUI / _load_data_

Method _load_data_

eval/run_eval_agent.py:43–71  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

41 self.data = self._split_to_steps_(self.episode_data)
42
43 def _load_data_(self):
44 valid_paths = defaultdict(list)
45 for subset in self.DATASET_DIR:
46 subdata_dir = self.DATASET_DIR[subset].format(self.data_dir)
47 if os.path.exists(subdata_dir):
48 sequence_names = os.listdir(subdata_dir)
49 for seq_name in sequence_names:
50 seq_dir = os.path.join(subdata_dir, seq_name)
51 if not os.path.isdir(seq_dir): continue
52 episode_path = os.path.join(seq_dir, f"{seq_name}.json")
53 valid_paths[subset].append(episode_path)
54
55 sampled_paths = []
56 for subset, v_paths in valid_paths.items():
57 N = len(v_paths)
58 k = int(self.ratio * N)
59 sampled_paths += random.sample(v_paths, k) if self.ratio < 1.0 else v_paths
60
61 ep_data = []
62 for episode_path in sampled_paths:
63 try:
64 with open(episode_path, "r") as f:
65 episode_data = json.load(f)
66 ep_data.append(episode_data)
67 except json.JSONDecodeError as e:
68 logging.error(f"JSON decoding failed, file: {episode_path}, error: {e}")
69 except Exception as e:
70 logging.error(f"Error occurred when loading file {episode_path}: {e}")
71 return ep_data
72
73 def _split_to_steps_(self, episode_data):
74 data = []

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected