Rename FodId hash to match_key to match the Model Terms vocabulary - #69
Merged
Conversation
The stable, comparable part of a 51Did, being the payload bytes after the flags and licence id, is called the match key in the Model Terms for Marketing and in the patent, so the reader now uses the same word. FodId.match_key is the new property. FodId.hash stays as an alias that returns the same bytes and warns with DeprecationWarning, and will be removed in a future release. The internal field, the payload reader's locals and the length helper move to match key naming as well. HASH_OFFSET and HASH_LENGTH keep their names because the SHA-256 wording behind them is still true, and their docstrings now describe the match key field. The package docstring and the PyPI description say match key.
The terminology section, the payload layout tables, the usage and comparison snippets and the guarantees now say match key, and the usage section notes that hash remains as a deprecated alias of match_key. The offline example prints and compares the match key.
Every assertion on the stable part of a 51Did reads match_key, and the canonical test bytes are named as the match key. One new test reads the deprecated hash alias, asserts the same bytes come back and that a DeprecationWarning is raised.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The stable, comparable part of a 51Did (the payload bytes after the flags and licence id) is now called the match key. The Model Terms for Marketing, which will be published later, and the patent both use that word, so the code uses the same one. Previously the Python reader exposed those bytes as
FodId.hash. This mirrors the .NET rename in 51Degrees/pipeline-dotnet#348 and the Rust one in 51Degrees/rust#19.Change
FodId.hashproperty toFodId.match_key.FodId.hashas a deprecated alias that returns the same bytes and warns withDeprecationWarning(warnings.warn(..., DeprecationWarning, stacklevel=2)), so existing callers keep working and see where to move. The alias will be removed in a future release._match_keyfield, thematch_keyparameters of_assignand_build, the locals in_read_payloadand_unpack_or_raise, the_match_key_lengthhelper (was_value_length) and the local inDidClient's_payload_length_valid.HASH_OFFSETandHASH_LENGTHkeep their names because the SHA-256 wording behind them stays true. Their docstrings, and theGUID_LENGTHone, now describe the match key field. SHA-256 andHASHED_EMAILwording is unchanged.FodIdandFodIdParseStatusdocstrings, the package docstring, the PyPI description insetup.py, the readme (terminology, payload layout tables, usage and comparison snippets, lower bounds section, guarantees) and the offline exampleexamples/fodid_example.pyto the match key vocabulary. The readme usage section notes the deprecated alias.match_keyand add one test,test_deprecated_hash_alias_returns_match_key_and_warns, which reads the alias, asserts the same bytes come back and asserts theDeprecationWarning.Before and after for a caller
fod_id.hashstill works and returns the same bytes, with aDeprecationWarning.Tests
tox -e pyinfiftyone_pipeline_didon this branch: 142 passed, 2 skipped. That is main's 141 passed, 2 skipped (measured on the same checkout before the change) plus the new alias test. The two skipped tests are the live cloud ones, as on main.The same suite under Python 3.9, the package floor, run with
python -m unittest discoverand-W error::DeprecationWarning: 144 tests, OK, 2 skipped. Running with deprecation warnings as errors shows nothing outside the alias test touches the deprecated name.The offline example
examples/fodid_example.pyruns clean with-W error::DeprecationWarning, prints the match key and reports a different envelope with the same match key across two issues of the same payload.Part of the cross-repository match key vocabulary rename (documentation, website, .NET reader, Rust reader and cloud internals in separate PRs).
Produced with AI assistance under James Rosewell's direction and needs human review.