MCPcopy
hub / github.com/deepspeedai/DeepSpeedExamples / write

Method write

Megatron-LM/data_utils/datasets.py:292–313  ·  view source on GitHub ↗

given a generator of metrics for each of the data points X_i, write the metrics, text, and labels to a csv file

(self, writer_gen=None, path=None, skip_header=False)

Source from the content-addressed store, hash-verified

290 return {'text': x, 'length': len(x), 'label': y}
291
292 def write(self, writer_gen=None, path=None, skip_header=False):
293 """
294 given a generator of metrics for each of the data points X_i,
295 write the metrics, text, and labels to a csv file
296 """
297 if path is None:
298 path = self.path+'.results'
299 print('generating csv at ' + path)
300 with open(path, 'w') as csvfile:
301 c = csv.writer(csvfile, delimiter=self.delim)
302 if writer_gen is not None:
303 #if first item of generator is a header of what the metrics mean then write header to csv file
304 if not skip_header:
305 header = (self.label_key,)+tuple(next(writer_gen))+(self.text_key,)
306 c.writerow(header)
307 for i, row in enumerate(writer_gen):
308 row = (self.Y[i],)+tuple(row)+(self.X[i],)
309 c.writerow(row)
310 else:
311 c.writerow([self.label_key, self.text_key])
312 for row in zip(self.Y, self.X):
313 c.writerow(row)
314
315class json_dataset(data.Dataset):
316 """

Callers 15

http_getFunction · 0.45
http_getFunction · 0.45
write_predictionsFunction · 0.45
write_predictionsFunction · 0.45
http_getFunction · 0.45
http_getFunction · 0.45
save_checkpointFunction · 0.45
write_fileFunction · 0.45
save_vocabularyMethod · 0.45
http_getFunction · 0.45
save_json_streamMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected