Skip to content

fix: stop passing dataset=None to fit_cls when sensitivity Job is complete - #1259

Merged
Jammy2211 merged 1 commit into
mainfrom
feature/cluster-f-sensitivity-job-dataset
May 8, 2026
Merged

Jammy2211 merged 1 commit into
mainfrom
feature/cluster-f-sensitivity-job-dataset

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Fixes AttributeError: 'NoneType' object has no attribute 'data' on re-runs of sensitivity mapping. Job.perform() was producing dataset = None as a "skip simulation if job is complete" optimization (commit 41095a0, Oct 2024), then handing that None straight to base_fit_cls / perturb_fit_cls. Consumer Analysis classes that unpack dataset.data / dataset.noise_map in __init__ — including the user-facing autofit_workspace/scripts/features/sensitivity_mapping.py tutorial — crashed.

The fix is a 7-line change: always call simulate_cls. Re-runs still skip the expensive non-linear search via Search.fit's load-from-zip path (paths.restore() unzips, paths.is_complete returns True, result_via_completed_fit loads samples from disk). Only the typically-cheap simulator call is no longer optimized away.

The library's own test_perform_twice test in test_autofit/non_linear/grid/test_sensitivity/test_functionality.py masked the contract issue because the test conftest's Analysis.__init__ simply stores dataset without unpacking — real workspace code unpacks it eagerly.

API Changes

None — internal change only. Job.perform() is library-internal; no public symbols added, removed, renamed, or signature-changed. The behavioural change is "re-runs of sensitivity mapping no longer crash" — strictly a fix.

Test Plan

  • pytest test_autofit/non_linear/grid/test_sensitivity/ passes 25/25 (incl. test_perform_twice).
  • autofit_workspace_test/scripts/database/scrape/sensitivity.py reproduced the AttributeError on re-run pre-fix; passes on a clean two-run cycle post-fix (first run completes, second run hits is_complete=True for both cells via zip presence, Search.fit.restore() unzips, load path returns).

Known limitation (out of scope)

If a previous run was killed mid-fit (leaving e.g. [perturb].zip present but [base].zip missing), the re-run will hit a different failure on that cell: Search.fit finds no zip to restore for the missing side, paths.is_complete is False, the resume logic kicks in, and Fitness.check_log_likelihood raises SearchException because the new (non-deterministic) simulator output's FoM doesn't match the persisted partial-fit FoM. That's a separate bug from this one — flagged for follow-up. This PR fixes only the is_complete=True path that produced None.

🤖 Generated with Claude Code

…plete

Job.perform() in autofit/non_linear/grid/sensitivity/job.py used to
short-circuit `dataset = None` when `is_complete` was True (commit
41095a0, Oct 2024 "skip simulation if job is complete") but still called
base_fit_cls / perturb_fit_cls with that None. Consumer Analysis classes
that unpack `dataset.data` / `dataset.noise_map` in __init__ — including
the user-facing autofit_workspace/scripts/features/sensitivity_mapping.py
tutorial — crash on re-runs with `AttributeError: 'NoneType' object has
no attribute 'data'`.

Always call simulate_cls. The expensive non-linear search is still skipped
on re-runs via Search.fit's load-from-zip path (paths.restore() unzips,
paths.is_complete returns True, result_via_completed_fit loads samples
from disk). Only the typically-cheap simulator cost is no longer
optimized away.

The library's own `test_perform_twice` test in
`test_autofit/non_linear/grid/test_sensitivity/test_functionality.py`
masked the contract issue because the test conftest's `Analysis.__init__`
simply stores `dataset` without unpacking — real workspace code unpacks
it eagerly.
@Jammy2211 Jammy2211 added the pending-release PR queued for the next release build label May 8, 2026
@Jammy2211
Jammy2211 merged commit 7646624 into main May 8, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the feature/cluster-f-sensitivity-job-dataset branch May 8, 2026 12:31
@Jammy2211 Jammy2211 removed the pending-release PR queued for the next release build label Sep 4, 2026
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.

1 participant