MCPcopy Create free account
hub / github.com/pytorch/pytorch / get_file_map

Function get_file_map

scripts/release_notes/classifier.py:217–240  ·  view source on GitHub ↗
(data_folder: Path, regen_data, assert_stored=False)

Source from the content-addressed store, hash-verified

215
216
217def get_file_map(data_folder: Path, regen_data, assert_stored=False):
218 if not regen_data and Path(data_folder / "file_map.pkl").exists():
219 with open(data_folder / "file_map.pkl", "rb") as f:
220 return pickle.load(f)
221 else:
222 if assert_stored:
223 raise FileNotFoundError(
224 "File map not found, you are loading for inference you need to have a file map!"
225 )
226 print("Regenerating File Map")
227 all_data = pd.read_csv(data_folder / "commitlist.csv")
228 # Lets explore files
229 files = all_data.files_changed.to_list()
230
231 all_files = []
232 for file in files:
233 paths = [Path(file_part) for file_part in file.split(" ")]
234 all_files.extend(paths)
235 all_files.append(Path(UNKNOWN_TOKEN))
236 file_set = build_file_set(all_files, MAX_LEN_FILE)
237 file_map = {file: i for i, file in enumerate(file_set)}
238 with open(data_folder / "file_map.pkl", "wb") as f:
239 pickle.dump(file_map, f)
240 return file_map
241
242
243# Generate a dataset for training

Callers 2

__init__Method · 0.90
trainFunction · 0.85

Calls 9

PathClass · 0.85
build_file_setFunction · 0.85
read_csvMethod · 0.80
loadMethod · 0.45
to_listMethod · 0.45
splitMethod · 0.45
extendMethod · 0.45
appendMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…