FABLE Model
This package contains model classes that are used in the FABLE (Federated Anonymized Bloom filter Linkage Engine) ecosystem's services for validation purposes. They were developed with the intention of creating HTTP-based services to perform Bloom filter-based record linkage in a federated setting. It includes models for data transformation, masking and bit vector matching routines that are used by the FABLE PPRL service as well as models used by the FABLE Broker service. Validation, serialization and deserialization are done using Pydantic. It is rare to use this package directly. Rather, it powers the functionalities of other packages.
Installation
pip install fable-model
PPRL service
Models for entity pre-processing, masking and bit vector matching are exposed through this package. The following examples are taken from the test suites of the PPRL service package and show additional validation steps in addition to the ones native to Pydantic.
Entity transformation
from fable_model import (
EntityTransformRequest,
TransformConfig,
EmptyValueHandling,
AttributeValueEntity,
AttributeTransformerConfig,
NumberTransformer,
GlobalTransformerConfig,
NormalizationTransformer,
CharacterFilterTransformer,
)
# This is a valid config.
_ = EntityTransformRequest(
config=TransformConfig(empty_value=EmptyValueHandling.ignore),
entities=[
AttributeValueEntity(
id="001",
attributes={
"bar1": " 12.345 ",
"bar2": " 12.345 "
}
)
],
attribute_transformers=[
AttributeTransformerConfig(
attribute_name="bar1",
transformers=[
NumberTransformer(decimal_places=2)
]
)
],
global_transformers=GlobalTransformerConfig(
before=[
NormalizationTransformer()
],
after=[
CharacterFilterTransformer(characters=".")
]
)
)
from uuid import uuid4
# Validation will fail since no transformers have been defined.
_ = EntityTransformRequest(
config=TransformConfig(empty_value=EmptyValueHandling.ignore),
entities=[
AttributeValueEntity(
id=str(uuid4()),
attributes={
"foo": "bar"
}
)
],
attribute_transformers=[]
)
# => ValidationError: attribute and global transformers are empty: must contain at least one
Entity masking
from fable_model import (
EntityMaskRequest,
MaskConfig,
HashConfig,
HashFunction,
HashAlgorithm,
DoubleHash,
CLKFilter,
AttributeValueEntity,
StaticAttributeConfig,
AttributeSalt,
CLKRBFFilter,
)
# This is a valid config.
_ = EntityMaskRequest(
config=MaskConfig(
token_size=2,
hash=HashConfig(
function=HashFunction(algorithms=[HashAlgorithm.sha1]),
strategy=DoubleHash()
),
filter=CLKFilter(filter_size=1024, hash_values=5),
padding="_"
),
entities=[
AttributeValueEntity(
id="001",
attributes={
"first_name": "John",
"last_name": "Doe",
"date_of_birth": "1987-06-05",
"gender": "m"
}
)
]
)
# This is an invalid config since salting an attribute can only be done through a fixed value
# or another attribute on an entity, not both at the same time.
_ = EntityMaskRequest(
config=MaskConfig(
token_size=2,
hash=HashConfig(
function=HashFunction(algorithms=[HashAlgorithm.sha1]),
strategy=DoubleHash()
),
filter=CLKFilter(filter_size=1024, hash_values=5),
padding="_"
),
entities=[
AttributeValueEntity(
id="001",
attributes={
"first_name": "foobar",
"salt": "0123456789"
}
)
],
attributes=[
StaticAttributeConfig(
attribute_name="first_name",
salt=AttributeSalt(
value="my_salt",
attribute="salt"
)
)
]
)
# => ValidationError: value and attribute cannot be set at the same time
# This also fails if neither a static value nor an attribute are set for salting.
_ = EntityMaskRequest(
config=MaskConfig(
token_size=2,
hash=HashConfig(
function=HashFunction(algorithms=[HashAlgorithm.sha1]),
strategy=DoubleHash()
),
filter=CLKFilter(filter_size=1024, hash_values=5),
padding="_"
),
entities=[
AttributeValueEntity(
id="001",
attributes={
"first_name": "foobar",
"salt": "0123456789"
}
)
],
attributes=[
StaticAttributeConfig(
attribute_name="first_name",
salt=AttributeSalt()
)
]
)
# => ValidationError: neither value nor attribute is set
# When using a weighted filter (RBF, CLKRBF), an error will be thrown if any attribute configuration
# provided is static, not weighted. The same applies vice versa, meaning if CLK is specified as a filter and
# weighted attribute configurations are provided.
_ = EntityMaskRequest(
config=MaskConfig(
token_size=2,
hash=HashConfig(
function=HashFunction(algorithms=[HashAlgorithm.sha1]),
strategy=DoubleHash()
),
filter=CLKRBFFilter(hash_values=5),
padding="_"
),
entities=[
AttributeValueEntity(
id="001",
attributes={
"first_name": "foobar",
"salt": "0123456789"
}
)
],
attributes=[
StaticAttributeConfig(
attribute_name="first_name",
salt=AttributeSalt(value="my_salt")
)
]
)
# => ValidationError: `clkrbf` filters require weighted attribute configurations, but static ones were found
# Weighted filters (RBF, CLKRBF) always require weighted attribute configurations. If none
# are provided, validation fails.
_ = EntityMaskRequest(
config=MaskConfig(
token_size=2,
hash=HashConfig(
function=HashFunction(algorithms=[HashAlgorithm.sha1]),
strategy=DoubleHash()
),
filter=CLKRBFFilter(hash_values=5),
padding="_"
),
entities=[
AttributeValueEntity(
id="001",
attributes={
"first_name": "foobar",
"salt": "0123456789"
}
)
]
)
# => ValidationError: `clkrbf` filters require weighted attribute configurations, but none were found
# If a configuration is provided for an attribute that doesn't exist on some entities, validation fails.
_ = EntityMaskRequest(
config=MaskConfig(
token_size=2,
hash=HashConfig(
function=HashFunction(algorithms=[HashAlgorithm.sha1]),
strategy=DoubleHash()
),
filter=CLKFilter(filter_size=1024, hash_values=5),
padding="_"
),
entities=[
AttributeValueEntity(
id="001",
attributes={
"first_name": "foobar"
}
)
],
attributes=[
StaticAttributeConfig(
attribute_name="last_name",
salt=AttributeSalt(value="my_salt")
)
]
)
# => ValidationError: some configured attributes are not present on entities: `last_name` on entities with ID `001`
Bit vector matching
from fable_model import (
VectorMatchRequest,
MatchConfig,
SimilarityMeasure,
BitVectorEntity,
SimilarityAggregator,
)
_ = VectorMatchRequest(
config=MatchConfig(
measures=[SimilarityMeasure.jaccard, SimilarityMeasure.cosine],
thresholds=0.8,
aggregator=SimilarityAggregator.avg,
),
domain=[
BitVectorEntity(
id="D001",
value="kY7yXn+rmp8L0nyGw5NlMw=="
)
],
range=[
BitVectorEntity(
id="R001",
value="qig0C1i8YttqhPwo4VqLlg=="
)
]
)
Broker service
The broker module contains models used by the Broker service to validate
requests and responses to create, manage and delete matching sessions.
Follow the link to the repository of that service for further information.
License
MIT.
Metadata
Release files for fable-model 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fable_model-0.4.0.tar.gz | 10.3 kB | With provenance | Details for fable_model-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fable_model-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for fable_model-0.4.0-py3-none-any.whl |
Total release size: 21.3 kB
Release files / fable_model-0.4.0.tar.gz
| Download URL | fable_model-0.4.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc3f3b4bee314670ce39380299e6389816cda1d68efe17d881d17219091eb9e7
|
|
BLAKE2b-256 checksum How to use checksums |
678b86b3fa918b14da1d5e80a26bd13fe716f4730214131f6aa4bd17706937a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logRelease files / fable_model-0.4.0-py3-none-any.whl
| Download URL | fable_model-0.4.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1336672654c2d66e2dc0d1b5e9a9d05c27f5f6629b053c75534d729c91cd05c5
|
|
BLAKE2b-256 checksum How to use checksums |
a7f0b9d7f6fbc1fd8438da0a21fc6dda686599fce11ad22b9ac958bafda6c576
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logSecurity for fable-model 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for fable_model-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.