def _ComputeHash(config: sampler_pb2.Sampler) -> str: """Compute sampler hash. The hash is computed from the serialized representation of the config proto. """ return crypto.sha1(config.SerializeToString())
def export_todir(s: session_t, table, dir: Path) -> None: fs.mkdir(dir) q = s.query(table) num = s.query(sql.sql.func.count(table.id)).scalar() for result in ProgressBar(max_value=num)(q): buf = result.toProtobuf().SerializeToString() checksum = crypto.sha1(buf) with open(f"{dir}/{checksum}.pb", "wb") as f: f.write(buf)
def hash_ml_dataset(instances): """ Returns the hash of a WekaInstances object. """ return crypto.sha1(str(instances))
def hash_scenario(device_id, kernel_id, dataset_id): """ Returns the hash of a scenario. """ return crypto.sha1(".".join((device_id, kernel_id, dataset_id)))
def hash_kernel(*features): """ Returns the hash of a kernel. """ return crypto.sha1(".".join([str(feature) for feature in features]))