OCDocker.OCScore.Utils.ContentHash module

Cryptographic content hashes for OCScore provenance artifacts.

Usage:

from OCDocker.OCScore.Utils.ContentHash import hash_feature_list from OCDocker.OCScore.Utils.ContentHash import hash_file

OCDocker.OCScore.Utils.ContentHash.hash_bytes(payload)[source]

Return the SHA-256 hex digest of payload.

Parameters:

payload (bytes)

Return type:

str

OCDocker.OCScore.Utils.ContentHash.hash_dataframe_partition(df, indices, *, id_columns=('name', 'receptor', 'ligand'))[source]

Return a stable hash for dataframe rows referenced by indices.

Parameters:
  • df (DataFrame)

  • indices (Sequence[int])

  • id_columns (Sequence[str])

Return type:

str

OCDocker.OCScore.Utils.ContentHash.hash_feature_list(features)[source]

Return a stable hash for an ordered feature-name list.

Parameters:

features (Sequence[str])

Return type:

str

OCDocker.OCScore.Utils.ContentHash.hash_file(path, *, chunk_size=1048576)[source]

Return the SHA-256 hex digest of a file’s contents.

Parameters:
  • path (str | Path)

  • chunk_size (int)

Return type:

str

OCDocker.OCScore.Utils.ContentHash.hash_json_dict(payload)[source]

Return a stable hash for a JSON-serializable mapping.

Parameters:

payload (dict[str, Any])

Return type:

str

OCDocker.OCScore.Utils.ContentHash.hash_split_indices(indices)[source]

Return a stable hash for an ordered index list.

Parameters:

indices (Sequence[int])

Return type:

str

OCDocker.OCScore.Utils.ContentHash.hash_text(text)[source]

Return the SHA-256 hex digest of UTF-8 encoded text.

Parameters:

text (str)

Return type:

str