Skip to content

feat(provider): wire system options with mixing_kernels#56

Merged
jc-macdonald merged 6 commits intomainfrom
feat/provider-options
Apr 8, 2026
Merged

feat(provider): wire system options with mixing_kernels#56
jc-macdonald merged 6 commits intomainfrom
feat/provider-options

Conversation

@jc-macdonald
Copy link
Copy Markdown
Collaborator

Summary

Wires self.options in the op_system provider so that system.option("mixing_kernels") works as expected by op_engine.

Changes

Commit 1: feat(provider): wire self.options with mixing_kernels

  • Add self.options = {"mixing_kernels": mixing_kernels} in model_post_init() after kernel construction

Commit 2: refactor(provider): remove hasattr guards for compiled.meta

  • Remove hasattr(compiled, "meta") introspection guards — CompiledRhs.meta is now guaranteed (PR feat(compile): thread meta from NormalizedRhs through CompiledRhs #53)
  • Fix meta key: "mixing""kernels" (bug found and fixed)
  • Fix string coord crash: np.asarray(["a","b"], dtype=float64) raises ValueError — added try/except fallback to np.arange(size) (bug found and fixed)

Commit 3: test(provider): verify options expose mixing_kernels

  • test_option_mixing_kernels_bare_spec — bare spec produces empty kernel list
  • test_option_mixing_kernels_with_kernel — spec with gaussian kernel populates correctly

Testing

All 5 provider tests pass. Lint clean.

Related

Add a Mapping[str, Any] meta field to CompiledRhs with an empty
MappingProxyType default. Existing callers are unaffected — the
field is optional and backward-compatible.

Part of #11.
Pass rhs.meta to CompiledRhs in compile_rhs(), preserving axes,
kernels, and operators metadata through the compile pipeline.

Part of #11.
Verify that:
- compile_rhs preserves axes and kernels metadata
- bare specs produce empty meta collections
- compile_spec facade round-trips meta end-to-end

Refs: #11
Populate self.options = {"mixing_kernels": ...} in model_post_init()
so that op_engine can retrieve kernels via system.option("mixing_kernels").

Refs: #42
CompiledRhs.meta is now guaranteed to exist (added in feat/11-compile-meta-threading).
Replace defensive hasattr checks with direct attribute access.
Add tests for:
- bare SIR spec exposes empty mixing_kernels dict
- spec with gaussian kernel exposes it via system.option()

Refs: #42
@jc-macdonald jc-macdonald added this to the Provider Integration milestone Apr 8, 2026
@jc-macdonald jc-macdonald added enhancement New feature or request provider flepimop2 provider/connector package testing Test infrastructure and coverage labels Apr 8, 2026
Base automatically changed from feat/11-compile-meta-threading to main April 8, 2026 15:05
Copy link
Copy Markdown
Collaborator

@TimothyWillard TimothyWillard left a comment

Choose a reason for hiding this comment

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

Minor comment, take it or leave it.

I am a bit confused, does this need to be caught back up with main? I think some of the changes here were merged via #53.

Comment on lines -104 to +111
coords = np.asarray(ax.get("coords", np.arange(size)), dtype=np.float64)
raw_coords = ax.get("coords", None)
try:
coords = (
np.asarray(raw_coords, dtype=np.float64)
if raw_coords is not None
else np.arange(size, dtype=np.float64)
)
except (ValueError, TypeError):
coords = np.arange(size, dtype=np.float64)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the current version could also be simplified with:

coords = np.arange(size, dtype=np.float64)
try:
    coords = np.asarray(raw_coords, dtype=np.float64)
except (TypeError, ValueError):
    pass

But what ValueError/TypeError are you expecting here? Something along the lines of raw_coords being a list of strings? In that case maybe something like:

coords = np.asarray(raw_coords)
if not np.can_cast(coords, np.float64):
    coords = np.arange(size, dtype=np.float64)
coords = coords.astype(np.float64, copy=False)

@jc-macdonald jc-macdonald merged commit 061e576 into main Apr 8, 2026
@jc-macdonald jc-macdonald deleted the feat/provider-options branch April 8, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider flepimop2 provider/connector package testing Test infrastructure and coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants