MCPcopy
hub / github.com/pytorch/vision / CommitDataCache

Class CommitDataCache

scripts/release_notes/retrieve_prs_data.py:139–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137
138
139class CommitDataCache:
140 def __init__(self, path="results/data.json"):
141 self.path = path
142 self.data = {}
143 if os.path.exists(path):
144 self.data = self.read_from_disk()
145
146 def get(self, commit):
147 if commit not in self.data.keys():
148 # Fetch and cache the data
149 self.data[commit] = get_features(commit)
150 self.write_to_disk()
151 return self.data[commit]
152
153 def read_from_disk(self):
154 with open(self.path) as f:
155 data = json.load(f)
156 data = {commit: dict_to_features(dct) for commit, dct in data.items()}
157 return data
158
159 def write_to_disk(self):
160 data = {commit: features._asdict() for commit, features in self.data.items()}
161 with open(self.path, "w") as f:
162 json.dump(data, f)
163
164
165def get_commits_between(base_version, new_version):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…