You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(motor): tank geometry union + fluid density function + tank_kind guard
Paired API-side work for the jarvis tank/fluid migration (branch
feat/tank-fluid-schema-migration in jarvis-ts). Mirrors what that repo
now sends on the wire:
Schema (src/models/sub/tanks.py):
- MotorTank.geometry is a discriminated union on geometry_kind:
* custom → legacy piecewise (TankGeometry)
* cylindrical → CylindricalTank(radius, height, spherical_caps)
* spherical → SphericalTank(radius)
- TankFluids.density accepts float or List[(T_K, rho)] temperature
samples; pressure dependence deferred.
- New validate_tank_kind_fields model_validator mirrors the
validate_dry_inertia_for_kind pattern from motor.py — rejects
payloads whose tank_kind omits required kind-specific fields at
the API boundary with a kind-named 422 instead of letting rocketpy
crash deeper in construction.
- discretize is now optional (defaults to 100).
Service (src/services/motor.py):
- _build_rocketpy_tank_geometry dispatches on geometry_kind to
TankGeometry/CylindricalTank/SphericalTank.
- _build_rocketpy_fluid instantiates a real rocketpy.Fluid and wraps
sampled density in a 1D Function-of-temperature callable; scalars
pass through. (Eliminates the duck-typed Pydantic-into-rocketpy
pattern that worked by accident.)
Inverse path (src/services/flight.py):
- _extract_fluid_density collapses Function-valued density back to a
scalar at rocketpy's reference state (273.15 K, 101325 Pa) — lossy
round-trip is documented; samples-roundtrip not supported in this
iteration.
- Geometry inverse always emits the 'custom' segment list shape; all
three rocketpy geometry subclasses expose a piecewise .geometry dict
so one code path covers them uniformly.
Tests:
- test_motors_route.py: 8 new cases covering each geometry_kind,
sampled density, invalid discriminator, and all four tank_kind guard
paths (MASS / MASS_FLOW / LEVEL / ULLAGE missing sub-fields).
- tests/unit/test_services/test_motor_service.py: new suite exercising
the adapter end-to-end against real rocketpy for each
geometry×variant combination plus sampled density roundtrip.
Routes (src/routes/motor.py):
- POST /motors docstring gained an example payload showing the
discriminated geometry union and sampled density shape.
Gitignore:
- Added .context and .pylint.d/ to keep local tooling artifacts out
of the tree.
Full suite: 173/173 pass.
0 commit comments