Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
e364b7a
fix(importers): resolve unstated threshold and clip as the Python pat…
sromoam Oct 15, 2026
adbda67
fix(importers): credit a zero threshold to the comparator only when i…
sromoam Oct 16, 2026
3637981
Merge origin/dev into fix/334-348-importer-defaults
sromoam Oct 28, 2026
530e77f
test: pin the free-form clip default from #334 in the extension refer…
sromoam Oct 28, 2026
ede3216
Merge remote-tracking branch 'origin/dev' into m408
sromoam Oct 29, 2026
60703e0
fix(334): name an adopted comparator threshold in the explain() trail
sromoam Oct 29, 2026
626f6dd
fix(348): resolve comparator keys on a nested model as the Python pat…
sromoam Oct 29, 2026
7dfab62
docs(348): document the nested-model comparator warning and the new d…
sromoam Oct 29, 2026
83f1556
docs(348): say the nested-object default threshold is fixed, not the …
sromoam Oct 30, 2026
6e51532
fix(348): plural warning verbs, keep ValueError for a list comparator…
sromoam Oct 30, 2026
fe8b830
Merge origin/dev into fix/334-348-importer-defaults
sromoam Nov 17, 2026
c6878eb
fix(importers): check an adopted comparator threshold and resolve nes…
sromoam Nov 17, 2026
2934248
docs(importers): state the threshold and clip defaults the importers …
sromoam Nov 17, 2026
dad0ca9
fix(importers): load a comparator that requires threshold on an array…
sromoam Nov 17, 2026
f7a4640
test(importers): pin the union, nested-warning and explain() behaviou…
sromoam Nov 17, 2026
1caa1cb
docs(importers): correct the free-form clip, nested comparator and wa…
sromoam Nov 17, 2026
ff19b01
docs(importers): scope the free-form clip claim to each object, and n…
sromoam Nov 17, 2026
a7ab802
docs(thresholds): state that an invalid field threshold raises, on ev…
sromoam Nov 17, 2026
09dcedd
fix(thresholds): raise on a field threshold that is not a number from…
sromoam Nov 17, 2026
a17802c
test(thresholds): pin the raise for an invalid field threshold on eve…
sromoam Nov 17, 2026
4f0fb4a
docs(thresholds): one message per path, int or float only, match_thre…
sromoam Nov 17, 2026
f5ad746
fix(thresholds): check Annotated fields, quote values as written, no …
sromoam Nov 17, 2026
3991537
test(thresholds): pin the per-path messages, Annotated, postponed ann…
sromoam Nov 17, 2026
be9b0b0
fix(thresholds): load an in-range Decimal, Fraction or numpy threshol…
sromoam Nov 17, 2026
d78cb3c
fix(thresholds): give every threshold message a fix, and the list ref…
sromoam Nov 17, 2026
526061b
fix(thresholds): check a forward-referenced field when the class is d…
sromoam Nov 17, 2026
7aa8375
docs(thresholds): a number from 0.0 to 1.0, on the class, config and …
sromoam Nov 17, 2026
55e4023
fix(thresholds): keep the runtime match_threshold check of evaluate()…
sromoam Nov 17, 2026
1654b58
fix(thresholds): check forward-referenced lists, keep numpy verdicts,…
sromoam Nov 17, 2026
32febb2
fix(importers): name a titled schema's model in its warnings, and say…
sromoam Nov 17, 2026
89b7e07
docs(thresholds): scope the runtime check, forward-referenced lists, …
sromoam Nov 17, 2026
9794614
docs(thresholds): a bare alias name for a list is ignored once resolv…
sromoam Nov 17, 2026
9d4a8a5
chore: merge origin/dev into fix/334-348-importer-defaults
sromoam Nov 17, 2026
0cad533
fix(thresholds): check an Annotated field whose type is defined furth…
sromoam Nov 17, 2026
4e59553
docs(thresholds): numpy float16 and float32 compare as Python floats,…
sromoam Nov 17, 2026
f7c7782
fix(auto): a runtime match_threshold=False does not warn that the thr…
sromoam Nov 17, 2026
60cc3a2
fix(thresholds): correct the threshold messages whose advice was wron…
sromoam Nov 17, 2026
d77fb56
docs(thresholds): scope the numpy, runtime, class match_threshold and…
sromoam Nov 17, 2026
e9228d7
fix(thresholds): evaluate Annotated metadata as pydantic does, once p…
sromoam Nov 17, 2026
44d21f9
fix(thresholds): a list-of-models message no longer tells an element …
sromoam Nov 17, 2026
96f5567
fix(thresholds): an unresolved dict or tuple gets the usual fix, and …
sromoam Nov 17, 2026
c4612ba
docs(thresholds): scope the Python list warning, name match_threshold…
sromoam Nov 17, 2026
9b2b5a9
docs(changelog): rewrap the threshold-rule paragraph
sromoam Nov 17, 2026
3a18858
test(thresholds): pin that a numpy float16 or float32 match_threshold…
sromoam Nov 17, 2026
cb26400
test(thresholds): drop the postponed Annotated case from the dict-or-…
sromoam Nov 17, 2026
8ce3b28
Revert "fix(thresholds): evaluate Annotated metadata as pydantic does…
sromoam Nov 17, 2026
5d85b9b
Revert "fix(thresholds): check an Annotated field whose type is defin…
sromoam Nov 17, 2026
605ea32
docs(thresholds): an Annotated field written as a string that names s…
sromoam Nov 17, 2026
a5230d5
fix(thresholds): a class loads when the working directory no longer e…
sromoam Nov 18, 2026
d86e94e
docs(importers): a threshold a custom comparator's constructor sets i…
sromoam Nov 18, 2026
43579b1
docs(thresholds): scope the Annotated, numpy float64 and array-sentin…
sromoam Nov 18, 2026
2b8d1b0
fix(evaluate): a runtime match_threshold of any real type in range is…
sromoam Nov 18, 2026
f7149a4
docs(thresholds): scope the Set at, None and unread-key claims
sromoam Nov 18, 2026
a93086a
docs(changelog): give the TP-to-FD example for a comparator's constru…
sromoam Nov 18, 2026
726726f
ci(thresholds): mark the test's exec calls reviewed, and skip the mad…
sromoam Nov 18, 2026
f0800a4
Merge origin/dev into fix/334-348-importer-defaults
sromoam Nov 23, 2026
b78859f
test(thresholds): patch in the NaN threshold the report test needs
sromoam Nov 23, 2026
e7ccbdc
test(thresholds): name the bool match_threshold test for the refusal …
sromoam Nov 23, 2026
619b714
fix(importers): name the model in the nested-model warnings as the er…
sromoam Nov 23, 2026
006f558
Merge dev into fix/334-348-importer-defaults
sromoam Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(348): plural warning verbs, keep ValueError for a list comparator…
…, and correct the README and test names
  • Loading branch information
sromoam committed Oct 30, 2026
commit 6e51532551f55763173f03498fa35126e2d088b7
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ Each release links to full notes on the
too, except that its `clip_under_threshold` now reads `false`; Exact scores
0 or 1, so its scores do not move. `explain()` names an adopted comparator
threshold in `why` (`config: comparator_config.threshold=0.9 (overrides
above)`), as it already named a field `threshold`; on the schema path it now
names both
above)`), as it already named a field `threshold`. The schema path named
neither and now names both, along with `-weight` and `-clip-under-threshold`
overrides.

- **Breaking:** `match_threshold` on a **primitive** field now raises
`ValueError`. It is the object-level threshold; nothing read it on a leaf, so
Expand Down
2 changes: 1 addition & 1 deletion src/stickler/structured_object_evaluator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ result = gt.compare_with(pred)
- `x-aws-stickler-weight`: field importance weight (default: 1.0)
- `x-aws-stickler-clip-under-threshold`: clip scores below threshold to 0.0 (boolean, default: true; false on a free-form object)

An object with `properties` is scored field by field, so `x-aws-stickler-comparator` has no effect there and warns; only the `threshold` in `-comparator-config` is read. On an array of models neither is read, and both warn. The config path does the same for `comparator` and `comparator_config` on `structured_model`, `optional_structured_model` and `list_structured_model`, except that `comparator` on `list_structured_model` raises.
An object with `properties` is scored field by field, so `x-aws-stickler-comparator` has no effect there and warns; only the `threshold` in `-comparator-config` is read. On an array of models `-comparator-config` is not read and warns; `x-aws-stickler-comparator` is accepted only as `LevenshteinComparator`, and any other raises ([#468](https://github.com/awslabs/stickler/issues/468)). The config path does the same for `comparator` and `comparator_config` on `structured_model`, `optional_structured_model` and `list_structured_model`, except that `comparator` on `list_structured_model` raises.

**Object-level extensions**, valid on the root schema or on any object-typed property:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,21 @@ def _nested_model_keys_warning(
importers before, so a raise would break configs that load today.
"""
subject = " and ".join(keys)
verb = "has" if len(keys) == 1 else "have"
# A phrase from _config_keys_phrase can name several keys on its own.
plural = len(keys) > 1 or any(" keys " in k for k in keys)
verb, be = ("have", "are") if plural else ("has", "is")
if is_list:
return (
f"{subject} {verb} no effect on field '{field_path}' and "
f"{'is' if len(keys) == 1 else 'are'} ignored: it is {shape}, whose "
f"{be} ignored: it is {shape}, whose "
"elements are paired by Hungarian matching, so neither a comparator "
"nor its threshold is read for it. Set comparators on the "
f"{members} inside each element, and the pairing threshold with "
f"{threshold_key}."
)
return (
f"{subject} {verb} no effect on field '{field_path}' and "
f"{'is' if len(keys) == 1 else 'are'} ignored: it is {shape}, scored "
f"{be} ignored: it is {shape}, scored "
"field by field, so its comparator is never called. Set comparators on "
f"the {members} inside it, and this field's threshold with "
f"{threshold_key}."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,9 +748,13 @@ def _comparison_from_extensions(
UserWarning,
)
if "comparator" in extensions:
extensions["comparator"] = create_comparator(
field_info.json_schema_extra["x-aws-stickler-comparator"], {}
)
try:
extensions["comparator"] = create_comparator(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: rebuilding the comparator with create_comparator(name, {}) gives errors that name no field, and lets non-TypeError exceptions escape.

On an array of objects with both a comparator and a comparator-config, a comparator with a required argument fails like this: Failed to create NeedsPattern with config {}: missing 1 required positional argument. The message names no field, and it blames an argument the author did supply. A constructor that raises RuntimeError escapes from_json_schema, which documents only ValueError. A custom class named LevenshteinComparator that requires config loaded on the merge base and raises on head.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in c6878eb and dad0ca9. On an array of objects, the comparator is now rebuilt with every config key except threshold, so a comparator that requires another key still builds. Your custom LevenshteinComparator case loads, as it does on dev. A comparator whose constructor requires threshold itself falls back to the one built from your full config (dad0ca9). It is never called there, so it loads as on dev, and explain() reports 0.5, as for any array of objects. If the comparator still cannot be built, the error is a ValueError naming the field and the key, whatever the constructor raised, so your RuntimeError case no longer escapes from_json_schema. Your NeedsPattern repro gets the same error as on dev: a List[StructuredModel] field cannot have a comparator.

field_info.json_schema_extra["x-aws-stickler-comparator"], {}
)
except TypeError as exc:
# Raised ValueError before the config was dropped; keep it.
raise ValueError(str(exc)) from exc

if annotation is None and extensions.get("infer"):
# A list of objects is matched element-wise by Hungarian matching, so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ def test_the_neighbouring_keys_were_always_read(self):
False,
)

def test_an_unstated_threshold_falls_back_to_the_class_match_threshold(self):
"""`0.7` here is `StructuredModel.match_threshold`, not `ComparableField`'s.

Named for the right mechanism. `ComparableField`'s own default is `0.5`
(`comparable_field.py`, `_LEGACY_DEFAULT_THRESHOLD`) and that is what a
SCALAR property falls back to; a nested model falls back to the class
gate instead. Calling this "the object-grade default" pointed at 0.5 and
asserted 0.7.
def test_an_unstated_threshold_is_a_fixed_default_for_a_nested_model(self):
"""`0.7` here is a fixed importer default for a nested model.

The nested class's own `match_threshold` does not change it, and it is
not `ComparableField`'s default either: that is `0.5`
(`comparable_field.py`, `_LEGACY_DEFAULT_THRESHOLD`), which a SCALAR
property falls back to. Python gives a different answer here (#468).
"""
model = StructuredModel.from_json_schema(_schema())
assert model._get_comparison_info("inner").threshold == 0.7
Expand Down
Loading