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