Skip to content

fix(): Fix coordinate transformation writes to frozen BETDisk fields#1979

Merged
benflexcompute merged 1 commit into
release-candidate/25.8from
hotfix/25.8-fix-coordinate-transform-frozen-sequences
Apr 9, 2026
Merged

fix(): Fix coordinate transformation writes to frozen BETDisk fields#1979
benflexcompute merged 1 commit into
release-candidate/25.8from
hotfix/25.8-fix-coordinate-transform-frozen-sequences

Conversation

@benflexcompute
Copy link
Copy Markdown
Collaborator

@benflexcompute benflexcompute commented Apr 9, 2026

Summary

Fix coordinate-system translation so it no longer rewrites frozen list / tuple fields when traversing nested simulation models.

Root Cause

_apply_transformations_to_model() rebuilt and reassigned every sequence field unconditionally:

  • scalar sequences like BETDisk.mach_numbers were reconstructed even though no transformation applied
  • frozen list[Flow360BaseModel] fields such as twists, chords, and sectional_polars also hit the same outer setattr

That caused translation to fail with errors like Cannot modify immutable/frozen fields: mach_numbers.

What Changed

  • kept _transform_sequence_item() behavior unchanged
  • updated the sequence branch in _apply_transformations_to_model() to only rebuild and reassign the outer sequence when an item is actually replaced
  • continued to recurse into nested Flow360BaseModel items in place without rewriting the outer container
  • added a regression test covering a minimal BETDisk + CoordinateSystemStatus setup

Validation

Passed locally:

  • python3 -m py_compile flow360/component/simulation/translator/utils.py tests/simulation/translator/test_translation_utils.py
  • direct import and execution of test_apply_coordinate_system_transformations_skips_frozen_non_entity_sequences()

Local environment blocker:

  • python3 -m pytest tests/simulation/translator/test_translation_utils.py -q
  • fails before test collection because the local pytest_asyncio plugin is incompatible with the installed pytest version (ImportError: cannot import name 'FixtureDef' from 'pytest')

Follow-up

The same issue exists on release-candidate/25.9 and should be forward-ported in a separate follow-up PR.


Note

Medium Risk
Changes recursive coordinate-system transformation traversal to stop reassigning list/tuple fields unless an element is actually replaced, which could affect how nested models are mutated during translation. Risk is moderate because it touches shared preprocessing logic, but the behavioral change is narrowly scoped and covered by a regression test.

Overview
Fixes coordinate-system preprocessing so _apply_transformations_to_model() no longer rebuilds and setattrs every list/tuple field unconditionally; it now only reassigns the outer sequence when at least one element was transformed.

Adds a regression test using a minimal BETDisk setup to verify entity coordinate translation occurs while frozen/non-entity sequences (e.g. mach_numbers, twists, chords) are not rewritten.

Reviewed by Cursor Bugbot for commit 67bb07c. Bugbot is set up for automated code reviews on this repo. Configure here.

@benflexcompute benflexcompute changed the title Fix coordinate transformation writes to frozen BETDisk fields fix(): Fix coordinate transformation writes to frozen BETDisk fields Apr 9, 2026
@benflexcompute benflexcompute marked this pull request as ready for review April 9, 2026 17:51
@benflexcompute benflexcompute merged commit af66c7e into release-candidate/25.8 Apr 9, 2026
39 checks passed
@benflexcompute benflexcompute deleted the hotfix/25.8-fix-coordinate-transform-frozen-sequences branch April 9, 2026 18:38
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.

2 participants