Skip to content

Add dynamic shapes for inputs and outputs#62

Merged
chrislupp merged 4 commits intodevelopfrom
feature/dynamic_var_shape
Apr 9, 2026
Merged

Add dynamic shapes for inputs and outputs#62
chrislupp merged 4 commits intodevelopfrom
feature/dynamic_var_shape

Conversation

@chrislupp
Copy link
Copy Markdown
Collaborator

@chrislupp chrislupp commented Apr 9, 2026

Summary

  • Adds support for dynamic variable shapes, allowing disciplines to declare variables with dynamic_shape=True so that the client can set the shape at runtime (Add dynamic shapes for inputs and outputs Philote-MDO#6)
  • Adds a bool dynamic_shape field to VariableMetaData in data.proto and a new SetVariableShapes streaming RPC to DisciplineService in disciplines.proto
  • OpenMDAO bindings automatically map dynamic-shape variables to shape_by_conn=True and send resolved shapes back to the server before partials setup
  • Includes FlexibleDiscipline example and 22 new tests with 100% code coverage

Test plan

  • All 278 tests pass (pytest tests/)
  • 100% code coverage confirmed (pytest --cov=philote_mdo)
  • Backward compatibility verified — existing static-shape disciplines (Paraboloid, Rosenbrock, Sellar, Quadratic) work unchanged
  • Verify CI passes on all Python versions (3.9–3.12)

Introduce custom exception classes (PhiloteValidationError, PhiloteServerError),
parameter validation in discipline base classes, gRPC error propagation via
context.abort() in all server RPC methods, and client-side input validation
with gRPC error wrapping. Fix missing space in RemoteImplicitComponent error
message.
Cover all previously uncovered error handling paths: PhiloteValidationError
and general Exception branches in server RPC methods, gRPC error wrapping
in all client methods, and num_par_fd validation in OpenMDAO components.
Disciplines can now declare variables with `dynamic_shape=True` in
`add_input`/`add_output`, indicating that the client is allowed to set
the variable's shape at runtime. A new `SetVariableShapes` gRPC RPC
lets clients send resolved shapes after querying variable definitions.

Protocol changes:
- Added `bool dynamic_shape` field to `VariableMetaData` in data.proto
- Added `SetVariableShapes` streaming RPC to DisciplineService

Server:
- `add_input`/`add_output` accept `dynamic_shape` parameter
- `SetVariableShapes` handler validates and updates shapes, including
  implicit residual entries
- `preallocate_inputs` raises if a dynamic variable has no shape set

Client:
- `set_variable_shape`, `send_variable_shapes`, `get_dynamic_variables`
  helper methods

OpenMDAO bindings:
- Dynamic-shape variables map to `shape_by_conn=True` automatically
- Resolved shapes are sent to the server before partials setup

Includes FlexibleDiscipline example and 22 new tests (100% coverage).
@chrislupp chrislupp self-assigned this Apr 9, 2026
@chrislupp chrislupp added the enhancement New feature or request label Apr 9, 2026
@chrislupp chrislupp added this to the Version 0.8.0 milestone Apr 9, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@chrislupp chrislupp merged commit 2225686 into develop Apr 9, 2026
8 checks passed
@chrislupp chrislupp deleted the feature/dynamic_var_shape branch April 9, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant