Example #1
0
    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())
Example #2
0
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)
Example #3
0
def hash_ml_dataset(instances):
  """
  Returns the hash of a WekaInstances object.
  """
  return crypto.sha1(str(instances))
Example #4
0
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)))
Example #5
0
def hash_kernel(*features):
  """
  Returns the hash of a kernel.
  """
  return crypto.sha1(".".join([str(feature) for feature in features]))
Example #6
0
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)))
Example #7
0
def hash_kernel(*features):
    """
    Returns the hash of a kernel.
    """
    return crypto.sha1(".".join([str(feature) for feature in features]))
Example #8
0
def hash_ml_dataset(instances):
    """
    Returns the hash of a WekaInstances object.
    """
    return crypto.sha1(str(instances))