MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / get_code_data_eval

Function get_code_data_eval

codegeex/mindspore/src/dataset.py:201–232  ·  view source on GitHub ↗
(code_data_path, args_opt, process_fn=None, scale=1)

Source from the content-addressed store, hash-verified

199
200
201def get_code_data_eval(code_data_path, args_opt, process_fn=None, scale=1):
202 datasets = []
203 paths = []
204
205 for dir in sorted(os.listdir(code_data_path)):
206 sub_dirs = os.listdir(os.path.join(code_data_path, dir))
207 for sub_dir in sub_dirs:
208 if os.path.exists(os.path.join(code_data_path, dir, sub_dir, 'data.mdb')) and os.path.exists(
209 os.path.join(code_data_path, dir, sub_dir, 'lock.mdb')):
210 paths.append(os.path.join(code_data_path, dir, sub_dir))
211
212 for full_path in paths:
213 if os.path.isdir(full_path):
214 print(f"Loading code data {full_path}")
215 data = LMDBDataset(
216 full_path,
217 process_fn=process_fn,
218 )
219 data = PadDataset(
220 data,
221 args_opt.seq_length,
222 args_opt.eod_id,
223 )
224 data = SubsetDataset(
225 data,
226 0,
227 len(data) // 10,
228 )
229 datasets.append(data)
230 datasets = ConcatDataset(datasets)
231 print(f"==valid dataset has {len(datasets)} items")
232 return datasets

Callers 1

create_datasetFunction · 0.85

Calls 5

LMDBDatasetClass · 0.85
PadDatasetClass · 0.85
SubsetDatasetClass · 0.85
ConcatDatasetClass · 0.85
existsMethod · 0.45

Tested by

no test coverage detected