Skip to content

Full unit physical dimension migration into Schema Side#1888

Merged
benflexcompute merged 45 commits intoBenY/CentralizedSchemafrom
BenY/FullUnitMigration
Mar 17, 2026
Merged

Full unit physical dimension migration into Schema Side#1888
benflexcompute merged 45 commits intoBenY/CentralizedSchemafrom
BenY/FullUnitMigration

Conversation

@benflexcompute
Copy link
Collaborator

@benflexcompute benflexcompute commented Mar 12, 2026

Note

Medium Risk
Touches many core simulation/meshing/result models and unit conversion paths; type changes and new deserialization/conversion behavior could surface as runtime validation or unit-handling regressions across existing user params and results workflows.

Overview
Migrates SDK models off flow360.component.simulation.unit_system dimension types to schema-side physical-dimension types. Most LengthType/AngleType/etc. usages are replaced with flow360_schema.framework.physical_dimensions equivalents (e.g., Length.Vector3, Length.PositiveFloat64, Time.PositiveFloat64) across meshing params, primitives/entities, operating conditions, materials, volume/surface models, and outputs.

Updates deserialization and cached-metadata parsing to use schema deserialize() instead of pydantic model_validate(). This affects project utilities, entity info merging, selector/materializer paths, and Flow360BaseModel.from_file().

Simplifies unit conversion plumbing and tightens non-dimensionalization behavior. need_conversion() now treats any unit-carrying value as convertible, unit_converter is removed from simulation/conversion.py, and a new RestrictedUnitSystem is introduced to block conversions when base dimensions aren’t defined; case CSV result conversions now build a schema unit system context and call .in_base() directly.

Examples updated to import unyt directly (import unyt as u) instead of SDK-provided unit aliases.

Written by Cursor Bugbot for commit c737897. This will update automatically on new commits. Configure here.

benflexcompute and others added 30 commits February 12, 2026 11:20
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…#1856)

Co-authored-by: benflexcompute <ben@flexcompute.com>
Co-authored-by: Ben <106089368+benflexcompute@users.noreply.github.com>
- Delete _Flow360BaseUnit hierarchy, Flow360ConversionUnitSystem,
  is_flow360_unit, old UnitSystem(pd.BaseModel), _PredefinedUnitSystem,
  and all predefined subclasses (~1400 lines removed)
- Import UnitSystem, predefined systems, unit_system_manager, and
  BaseSystemType from flow360-schema
- SimulationParams.unit_system field now uses UnitSystemConfig
- conversion.py: replace unit_converter() with RestrictedUnitSystem
- services.py: use _UNIT_SYSTEMS lookup and DeserializationContext
- Update tests for removed flow360_acceleration_unit and _PredefinedUnitSystem

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Fix SimulationParams.__init__ to handle deserialization path (model_validate)
  when no unit system context is active
- Add angle to RestrictedUnitSystem supported dimensions
- Fix UnitSystemConfig subscript: use .resolve() before __getitem__
- Add resolve() to MockUnitSystem in test fixture
- Remove deleted _Flow360BaseUnit references from conftest, test_entities,
  test_unit_system, test_unit_conversions
- Add operating_condition to test SimulationParams constructions that need
  full unit system for _preprocess
- Update floating point comparisons to use np.isclose for bet disk tests
- Replace flow360_unit_system with SI_unit_system in test generator

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolve JSON ref file conflicts by keeping branch content changes
and re-sorting keys with tools/sort_ref_json.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
benflexcompute and others added 4 commits March 13, 2026 09:25
Replace all XxxType.Point/Vector/Axis/Pair/Range/Array references
with schema-side equivalents (Length.Vector3, Length.Vector2, etc.)
across 10 files (54 non-scalar shape references + 1 AngleType.Positive).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@benflexcompute benflexcompute force-pushed the BenY/CentralizedSchema branch from 099f32d to 2c3709d Compare March 16, 2026 17:47
benflexcompute and others added 8 commits March 16, 2026 14:34
- Replace LengthType/AngleType/AngularVelocityType scalar variants with
  schema-side equivalents across 6 source files (38 instances)
- Fix validation_context.py to use schema TypeAdapter instead of
  LengthType.validate for project_length_unit deserialization
- Fix entity_expansion_utils.py to wrap MirrorStatus.model_validate
  in DeserializationContext when deserializing from dict
- Update test assertions for new serialization format (bare SI values
  instead of legacy {value, units} dicts)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix solver_translator missing no_unit context for reference_velocity
- Replace DeserializationContext+model_validate with deserialize() in
  source code (entity_expansion_utils, entity_info, services, etc.)
- Replace model_validate with deserialize() in tests for serialized data
- Update BET disk golden JSON for new serialization format (bare floats)
- Update regex patterns for new validator error messages
- Fix project_length_unit format in test data (unyt quantity, not string)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ize()

Systematic cleanup: wherever DeserializationContext wraps a single
model_validate call on serialized data, use the new deserialize()
classmethod instead. Keeps DeserializationContext only where it wraps
complex flows, TypeAdapter calls, or combined context managers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix snappy _convert_list_to_unyt_array to not wrap bare numbers as
  dimensionless unyt_array (let schema validators handle unit attachment)
- Fix services.py generate_process_json to get mesh_unit from validated
  asset cache instead of raw dict
- Update test assertions for new error loc paths (no trailing 'value')
- Update 8 golden JSON ref files for new serialization format
- Update test JSON data: project_length_unit "m" -> 1.0

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The model_validator was named 'deserialize' which collides with the new
Flow360BaseModel.deserialize() classmethod. Renamed to
'preprocess_variable_declaration' since it's a Pydantic model_validator
invoked automatically, not called directly by anyone.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Resolve all 13 merge conflicts keeping FullUnitMigration (ours):
- Use .deserialize() over DeserializationContext+model_validate
- Keep new schema type imports over old types
- Drop duplicate udim registrations (already in schema package)
- Drop old _DimensionedType system (~950 lines)
- Add pylint disable=no-member for Pydantic field false positives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@benflexcompute benflexcompute marked this pull request as ready for review March 17, 2026 15:46
@flexcompute flexcompute deleted a comment from github-actions bot Mar 17, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

Coverage report (flow360)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  flow360/component
  geometry.py 437
  project.py 639, 658
  project_utils.py
  flow360/component/results
  case_results.py 515
  flow360/component/simulation
  conversion.py 74, 78-79
  entity_info.py
  entity_operation.py
  primitives.py
  services.py 127, 768-772, 1187, 1210-1215, 1230-1235, 1261-1266, 1336, 1346
  simulation_params.py 176, 188-191, 193, 292, 298-303, 381, 448
  unit_system.py 331-337
  flow360/component/simulation/draft_context
  mirror.py
  flow360/component/simulation/framework
  param_utils.py
  flow360/component/simulation/meshing_param
  volume_params.py
  flow360/component/simulation/models
  turbulence_quantities.py
  flow360/component/simulation/models/bet
  bet_translator_interface.py
  flow360/component/simulation/outputs
  render_config.py
  flow360/component/simulation/run_control
  stopping_criterion.py
  flow360/component/simulation/translator
  solver_translator.py
  surface_meshing_translator.py
  utils.py 175
  flow360/component/simulation/user_code/core
  types.py 1667
  flow360/component/simulation/validation
  validation_context.py
  flow360/component/simulation/web
  asset_base.py
  flow360/plugins/report
  report_items.py
Project Total  

The report is truncated to 25 files out of 45. To see the full report, please visit the workflow summary page.

This report was generated by python-coverage-comment-action

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1996fed601

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The supported set starts with {length, angle} (2 elements) and grows
to 5 when all optional units are provided, but the early-return guard
checked == 4, making it dead code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…system

1. _init_check_unit_system: use properly resolved UnitSystem in else
   branch instead of unconditionally overwriting with raw kwarg_unit_system
2. flow360_unit_system: cache RestrictedUnitSystem per-instance to avoid
   leaking entries into unyt's global registry on every property access.
   Cache invalidated in _private_set_length_unit when base_length changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@benflexcompute benflexcompute merged commit b039d60 into BenY/CentralizedSchema Mar 17, 2026
18 checks passed
@benflexcompute benflexcompute deleted the BenY/FullUnitMigration branch March 17, 2026 22:31
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