Anonymizer icon indicating copy to clipboard operation
Anonymizer copied to clipboard

fix(rewrite): handle all-failed repair batches without missing-Parquet crashes

Open lipikaramaswamy opened this issue 1 month ago • 1 comments

Priority Level

High (Major functionality broken)

Describe the bug

When every record in a rewrite-repair batch fails generation after repeated provider timeouts, notebook execution aborts with an AnonymizerWorkflowError wrapping a DataDesignerGenerationError and FileNotFoundError for the batch's nonexistent Parquet output. The missing-output error obscures the generation failures and prevents otherwise successful records from being returned.

Observed during notebook CI for PR #330 at commit b27e39e3a659f173c3ba92fcafa3153563fa667e:

  • Notebooks 01–03 completed.
  • Notebook 04 (rewriting biographies) completed detection: 683 entities across 25 records, zero detection failures.
  • The first repair batch then generated 0 of 8 requested records after retryable provider timeouts.
  • Notebook 04 raised; notebook 05 never ran.
  • The CPU PyTorch installation succeeded; the earlier disk-quota failure did not recur.

Steps/Code to reproduce bug

Observed run: https://github.com/NVIDIA-NeMo/Anonymizer/actions/runs/40271396191 Job: https://github.com/NVIDIA-NeMo/Anonymizer/actions/runs/40271396191/job/121404788506

Run the Build notebooks workflow on the affected commit. The workflow builds a wheel and executes all tutorial sources using:

make convert-notebooks ANONYMIZER_NOTEBOOK_PACKAGE="<built-wheel>[notebooks]"

Trigger condition: every row in a nonempty rewrite-repair-0 batch exhausts generation attempts, leaving no generated dataset. Provider timeouts are nondeterministic; a regression test should inject this condition rather than depend on a live outage.

Relevant value-free log evidence:

Observed retryable model-task error: kind=timeout; the row task will be deferred.
Provider showing degraded performance: 100% of last 20 task outcomes were retryable errors (timeout=20); cumulative outcomes: timeout=20; deferred_tasks=4.
Generated 0 of 8 requested records (0%).
FileNotFoundError: [Errno 2] No such file or directory: '.anonymizer-artifacts/rewrite-repair-0/parquet-files'
AnonymizerWorkflowError: Workflow failed: Failed to load generated dataset — all records may have been dropped due to generation failures.

The workflow's list of configured model aliases does not identify which upstream model caused the timeouts; investigate provider/task metadata before attributing an outage to a particular model.

Expected behavior

Handle a completely failed repair batch through the existing failed-record contract:

  • Preserve successful records outside the failed batch.
  • Surface affected repair records explicitly as FailedRecord entries with safe stage/cause metadata.
  • Do not admit unrepaired rows as successful or silently return source text.
  • Do not attempt to load nonexistent dataset output or replace the generation cause with a missing-Parquet exception.
  • Continue to distinguish genuine configuration, transport, and filesystem failures from an expected empty result after generation exhaustion.

Additional context

Investigate the boundary between NddAdapter.run_workflow() (src/anonymizer/engine/ndd/adapter.py) and RewriteWorkflow._run_evaluate_repair_loop() (src/anonymizer/engine/rewrite/rewrite_workflow.py). The traceback passes through the adapter's DataDesigner execution/loading path during rewrite-repair-0.

The provider timeouts are the observed trigger; handling an all-failed batch is the application issue. This is separate from PR #330's GLiNER span and CI storage fixes. Detection succeeded in the failing biography notebook; legal notebook validation remains incomplete.

Acceptance:

  • [ ] Deterministic regression covering all repair tasks failing with no Parquet output.
  • [ ] Successful non-repair rows survive; failed row identities and count remain correct.
  • [ ] Partial repair success still follows the existing contract.
  • [ ] Error/trace metadata contains no source values or credentials.
  • [ ] The entire batch failing no longer causes the secondary missing-output crash.

lipikaramaswamy avatar Oct 26 '26 06:10 lipikaramaswamy

I traced this: when every record in a batch fails generation, no Parquet is written, create() raises a generation error caused by a FileNotFoundError, and NddAdapter.run_workflow() re-wraps it as AnonymizerWorkflowError. The fix is to treat that case (excluding early shutdown and any other cause) as an empty result, so every input record comes back as a FailedRecord through the existing contract. I have a branch with deterministic regression tests and a plan doc at plans/331/all-failed-batch.md. Could a maintainer add the triaged label so I can open the PR?

pcbeingused33 avatar Nov 04 '26 03:11 pcbeingused33