MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / upload_benchmark_data

Function upload_benchmark_data

tensorflow/tools/test/upload_test_benchmarks.py:141–187  ·  view source on GitHub ↗

Parse benchmark data and use the client to upload it to the datastore. Parse the given benchmark data from the serialized JSON-format used to write the test results file. Create the different datastore Entities from that data and upload them to the datastore in a batch using the client conne

(client, data)

Source from the content-addressed store, hash-verified

139
140
141def upload_benchmark_data(client, data):
142 """Parse benchmark data and use the client to upload it to the datastore.
143
144 Parse the given benchmark data from the serialized JSON-format used to write
145 the test results file. Create the different datastore Entities from that data
146 and upload them to the datastore in a batch using the client connection.
147
148 Args:
149 client: datastore client connection
150 data: JSON-encoded benchmark data
151 """
152 test_result = json.loads(data)
153
154 test_name = text_type(test_result["name"])
155 start_time = datetime.datetime.utcfromtimestamp(
156 float(test_result["startTime"]))
157 batch = []
158
159 # Create the Test Entity containing all the test information as a
160 # non-indexed JSON blob.
161 t_key = client.key("Test")
162 t_val = datastore.Entity(t_key, exclude_from_indexes=["info"])
163 t_val.update({
164 "test": test_name,
165 "start": start_time,
166 "info": text_type(data)
167 })
168 batch.append(t_val)
169
170 # Create one Entry Entity for each benchmark entry. The wall-clock timing is
171 # the attribute to be fetched and displayed. The full entry information is
172 # also stored as a non-indexed JSON blob.
173 for ent in test_result["entries"].get("entry", []):
174 ent_name = text_type(ent["name"])
175 e_key = client.key("Entry")
176 e_val = datastore.Entity(e_key, exclude_from_indexes=["info"])
177 e_val.update({
178 "test": test_name,
179 "start": start_time,
180 "entry": ent_name,
181 "timing": ent["wallTime"],
182 "info": text_type(json.dumps(ent))
183 })
184 batch.append(e_val)
185
186 # Put the whole batch of Entities in the datastore.
187 client.put_multi(batch)
188
189
190def upload_benchmark_files(opts):

Callers 1

upload_benchmark_filesFunction · 0.85

Calls 4

keyMethod · 0.45
updateMethod · 0.45
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected