Skip to content

fix(292): format the budget key as a number in Bulk_Confidence_AUROC - #396

Merged
sromoam merged 1 commit into
awslabs:devfrom
Thanatos9404:bugfix/292-auroc-notebook-budget-format
Oct 19, 2026
Merged

sromoam merged 1 commit into
awslabs:devfrom
Thanatos9404:bugfix/292-auroc-notebook-budget-format

Conversation

@Thanatos9404

Copy link
Copy Markdown
Contributor

Pull Request

Issue Reference

Fixes #292

Description of Changes

Cell 11 of examples/notebooks/Bulk_Confidence_AUROC.ipynb formatted the string keys of ecab['budgets'] with %, which raises ValueError: Unknown format code '%' for object of type 'str'. It now converts each key with float() first, as the confidence metrics docs already do. The notebook also stores the outputs of a full run.

Changes Made

  • Cell 11: {budget:<12.0%} becomes {float(budget):<12.0%}. This is the only source change.
  • Stored outputs from one top-to-bottom run (execution counts 1 to 10). Notebook and cell metadata are unchanged.

Why These Changes Are Needed

ErrorCaptureAtBudgetMetric keys budgets with strings on purpose, so the dict round-trips through JSONL; the library stays as it is. The table now reads:

Budget       Reviewed     Errors Found    Caught     Gain
------------------------------------------------------------
10%          40           40              41%        4.1x
30%          120          94              96%        3.2x
50%          200          98              100%       2.0x

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • All existing tests pass

examples/run_examples.py is not on dev (#291 was closed), so the runner from that branch (ff04e21) was used without committing it: uv run --with nbclient --with nbformat --with ipykernel python examples/run_examples.py --only Bulk_Confidence fails at cell 11 on dev and passes on this branch. The stored outputs come from jupyter nbconvert --to notebook --execute; repeat runs give identical output (the cells seed random with 42), with stickler imported from the checkout's src/.

Reviewers

@sromoam

Checklist

  • Code follows the project's coding standards
  • Self-review of code completed
  • Documentation updated (if applicable)
  • CHANGELOG.md entry added under [Unreleased], or not needed because
    nothing user-visible changed (see RELEASING.md): example notebook only, nothing in the published package changes
  • Tests added/updated for new functionality
  • All CI checks are passing
  • Ready for review

Additional Notes

Running the notebooks in CI is #118, so this PR adds no runner.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ErrorCaptureAtBudgetMetric keys budgets with strings such as "0.10" so the
dict round-trips through JSONL, and cell 11 of the notebook applied the %
format code to those strings, so it raised ValueError: Unknown format code
'%' for object of type 'str'. Convert the key with float() before
formatting, as the confidence metrics docs already do.

Store the outputs of a full run, so a reader sees the real numbers.

@sromoam sromoam left a comment

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.

Thanks @Thanatos9404, this fixes #292. The budget keys are the f"{budget:.2f}" strings from _budget_key, so float(budget) parses them. I re-ran the notebook's code cells against this branch and against current dev, and both reproduce the stored outputs exactly. Approving.

Optional polish, for this PR or later, whichever you prefer:

  • Sections 4 and 6 call the generator "well-calibrated", but the stored ECE is 0.2257. It discriminates well (AUROC 0.987) without being calibrated, so "informative confidence" would be more accurate.
  • In the ECE table the last bin is closed ([0.9, 1.0]), because ECEMetric puts 1.0 there. The data columns also sit one space left of the headers.
  • bins=10 bins should read bins=10.

@github-actions

Copy link
Copy Markdown

Security Scan Results

ASH Security Scan Report

  • Report generated: 2026-10-19T16:02:50+00:00
  • Time since scan: 2 minutes

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-10-19T16:00:30+00:00
  • ASH version: 3.1.2

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

  • Severity levels:
    • Suppressed (S): Findings that have been explicitly suppressed and don't affect scanner status
    • Critical (C): Highest severity findings that require immediate attention
    • High (H): Serious findings that should be addressed soon
    • Medium (M): Moderate risk findings
    • Low (L): Lower risk findings
    • Info (I): Informational findings with minimal risk
  • Duration (Time): Time taken by the scanner to complete its execution
  • Actionable: Number of findings at or above the threshold severity level that require attention
  • Result:
    • PASSED = No findings at or above threshold
    • FAILED = Findings at or above threshold
    • MISSING = Required dependencies not available
    • SKIPPED = Scanner explicitly disabled
    • ERROR = Scanner execution error
  • Threshold: The minimum severity level that will cause a scanner to fail
    • Thresholds: ALL, LOW, MEDIUM, HIGH, CRITICAL
    • Source: Values in parentheses indicate where the threshold is set:
      • global (global_settings section in the ASH_CONFIG used)
      • config (scanner config section in the ASH_CONFIG used)
      • scanner (default configuration in the plugin, if explicitly set)
  • Statistics calculation:
    • All statistics are calculated from the final aggregated SARIF report
    • Suppressed findings are counted separately and do not contribute to actionable findings
    • Scanner status is determined by comparing actionable findings to the threshold
Scanner Suppressed Critical High Medium Low Info Actionable Result Threshold
bandit 0 3 0 0 5755 0 3 FAILED MEDIUM (global)
cdk-nag 0 0 0 0 0 0 0 PASSED MEDIUM (global)
cfn-nag 0 0 0 0 0 0 0 MISSING MEDIUM (global)
checkov 0 0 0 0 0 0 0 PASSED MEDIUM (global)
detect-secrets 0 1 0 0 0 0 1 SKIPPED MEDIUM (global)
grype 0 0 0 0 0 0 0 MISSING MEDIUM (global)
npm-audit 0 0 0 0 0 0 0 PASSED MEDIUM (global)
opengrep 0 0 0 0 0 0 0 MISSING MEDIUM (global)
semgrep 3 0 0 0 0 0 0 PASSED MEDIUM (global)
syft 0 0 0 0 0 0 0 MISSING MEDIUM (global)

Top 2 Hotspots

Files with the highest number of security findings:

Finding Count File Location
2 tests/comparators/test_anls_leaf_semantics.py
2 tests/structured_object_evaluator/test_rollup_node_semantics.py

Detailed Findings

Show 4 actionable findings

Finding 1: SECRET-HEX-HIGH-ENTROPY-STRING

  • Severity: HIGH
  • Scanner: detect-secrets
  • Rule ID: SECRET-HEX-HIGH-ENTROPY-STRING
  • Location: tests/comparators/test_anls_leaf_semantics.py:89

Description:
Secret of type 'Hex High Entropy String' detected in file 'tests/comparators/test_anls_leaf_semantics.py' at line 89

Code Snippet:

Secret of type Hex High Entropy String detected

Finding 2: B108

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B108
  • Location: tests/comparators/test_anls_leaf_semantics.py:210-212

Description:
Probable insecure usage of temp file/directory.

Code Snippet:

uuid.UUID(int=1),
            pathlib.Path("/tmp/x"),
            b"bytes",

Finding 3: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1362-1368

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

def published_label(node: dict, section: str, object_lists: set) -> str:
            counts_objects = eval(  # noqa: S307
                cond.group(1),
                {},
                {"data": node, "section": section, "OBJECT_LISTS": object_lists},
            )
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Finding 4: B307

  • Severity: HIGH
  • Scanner: bandit
  • Rule ID: B307
  • Location: tests/structured_object_evaluator/test_rollup_node_semantics.py:1367-1369

Description:
Use of possibly insecure function - consider using safer ast.literal_eval.

Code Snippet:

)
            return eval(unit.group(1), {}, {"counts_objects": counts_objects})  # noqa: S307

Report generated by Automated Security Helper (ASH) at 2026-10-19T16:02:51+00:00

@sromoam
sromoam merged commit 99cc2fe into awslabs:dev Oct 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Bulk_Confidence_AUROC notebook raises ValueError on execution, and always has

2 participants