Added ParameterSet for data-driven design parameterization#204
Open
ad-cqc wants to merge 13 commits intoaws-cqc:mainfrom
Open
Added ParameterSet for data-driven design parameterization#204ad-cqc wants to merge 13 commits intoaws-cqc:mainfrom
ad-cqc wants to merge 13 commits intoaws-cqc:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
gpeairs
reviewed
Apr 16, 2026
Member
gpeairs
left a comment
There was a problem hiding this comment.
Thanks, this is much needed. My major question is about precedence of the ParameterSet versus _build_subcomponent overrides -- right now it's ambiguous and up to the designer to follow the feature's intent. I have some ideas below about enforcing one way or the other, but I'm still undecided on what's best.
ad-cqc
added a commit
to ad-cqc/DeviceLayout.jl
that referenced
this pull request
Apr 21, 2026
- Relocate parameter_set.jl under src/schematics/ and include it from the
SchematicDrivenLayout submodule; export ParameterSet, MissingNamespace,
ParameterKeyError, resolve, leaf_params, and save_parameter_set from there.
- Guarantee required "global"/"components" namespaces via an inner
constructor; scoped views (from ps.x.y dot access) bypass via a
Val{:scoped} tag to avoid polluting child subtrees.
- Add create_component(T, sub::ParameterSet) for chained-dot access:
e.g. create_component(T, ps.components.foo.bar).
- Add set_parameters(c, value => :name, ...) for forwarding values into
component parameters under a different name.
- Split the ParameterSet doc page into a tutorial
(docs/src/tutorials/parameter_set.md) and an API reference
(docs/src/reference/parameter_set_api.md); wire up docs/make.jl.
- Update ext/ParameterSetYAMLExt.jl and tests to the new module path.
Addresses PR aws-cqc#204 review comments aws-cqc#3 and aws-cqc#5.
ad-cqc
added a commit
to ad-cqc/DeviceLayout.jl
that referenced
this pull request
Apr 21, 2026
Add a `prefix::String` field to `ParameterSet` and `MissingNamespace` so scoped views carry their namespace path. Leaf reads via dot-chain access and via `create_component(T, ps.foo.bar)` now record qualified paths like `"components.qubit.cap_width"` in `ps.accessed`, matching the behavior of the address-string form of `create_component`. Error messages from missing keys on scoped views also include the scope prefix — `ps.components.qubit.missing_param` now reports path `"components.qubit.missing_param"` instead of just `"missing_param"`. Addresses PR aws-cqc#204 review comment aws-cqc#4.
Introduce `ParameterSet`, a mutable nested dictionary wrapper that provides dot-access syntax for reading and writing design parameters. Supports `global` and `components` namespaces, programmatic construction, and optional YAML serialization via a package extension. Key changes: - Add `ParameterSet` type with `resolve` and `leaf_params` utilities - Add `ParameterSetYAMLExt` weak dep extension for YAML load/save - Integrate `parameter_set` into SchematicDrivenLayout and `@component` - Add comprehensive API reference documentation - Register YAML as optional dependency in Project.toml
Replace Pair syntax with dot-access for setting initial parameters, rewrite composite component section to show cleaner pattern where subcomponent parameters live in the ParameterSet rather than the composite struct, remove fallback dual-path (if/else isnothing) code, and update YAML examples to match the simplified structure.
Replace silent auto-vivification of missing keys with a MissingNamespace sentinel that supports chained dot-writes but throws a descriptive ParameterKeyError when used as a value. Add tree-style pretty printing, a validate() function to detect unaccessed parameters, and comprehensive tests for the new error handling and display behavior. Update docs to use explicit parameter set paths for shared parameter forwarding.
Support parsing unit-suffixed values (e.g., "150μm") in YAML files loaded into ParameterSet. Values with recognized Unitful suffixes are automatically converted to proper quantities. Update documentation examples to use unitful parameters and add comprehensive tests for YAML round-tripping with units.
- Relocate parameter_set.jl under src/schematics/ and include it from the
SchematicDrivenLayout submodule; export ParameterSet, MissingNamespace,
ParameterKeyError, resolve, leaf_params, and save_parameter_set from there.
- Guarantee required "global"/"components" namespaces via an inner
constructor; scoped views (from ps.x.y dot access) bypass via a
Val{:scoped} tag to avoid polluting child subtrees.
- Add create_component(T, sub::ParameterSet) for chained-dot access:
e.g. create_component(T, ps.components.foo.bar).
- Add set_parameters(c, value => :name, ...) for forwarding values into
component parameters under a different name.
- Split the ParameterSet doc page into a tutorial
(docs/src/tutorials/parameter_set.md) and an API reference
(docs/src/reference/parameter_set_api.md); wire up docs/make.jl.
- Update ext/ParameterSetYAMLExt.jl and tests to the new module path.
Addresses PR aws-cqc#204 review comments aws-cqc#3 and aws-cqc#5.
Add a `prefix::String` field to `ParameterSet` and `MissingNamespace` so scoped views carry their namespace path. Leaf reads via dot-chain access and via `create_component(T, ps.foo.bar)` now record qualified paths like `"components.qubit.cap_width"` in `ps.accessed`, matching the behavior of the address-string form of `create_component`. Error messages from missing keys on scoped views also include the scope prefix — `ps.components.qubit.missing_param` now reports path `"components.qubit.missing_param"` instead of just `"missing_param"`. Addresses PR aws-cqc#204 review comment aws-cqc#4.
- Collapse ParameterSet inner constructors into one; the empty-prefix
invariant replaces the Val{:scoped} dispatch.
- Guard MissingNamespace against being used as a value via
create_component and set_parameters — throw ParameterKeyError with the
qualified path instead of silently storing the wrapper.
- Surface ArgumentError when auto-vivification collides with an existing
leaf in _materialize!.
- Make resolve(ps, \"\") a no-op by skipping empty split segments.
- Leave bare unit strings (\"s\", \"m\", \"cm\") as strings when parsing
YAML; only substitute when uparse returns a Unitful.Quantity.
- Remove the dubious Base.ismissing(::MissingNamespace) override and the
setfield! branch on MissingNamespace internal fields.
- Add tests covering each guard and the YAML bare-unit behavior.
…add set_parameters - Fix setproperty! on ParameterSet and MissingNamespace to return the original RHS value per Julia convention (not the internally stored Dict) - Shallow-copy data in ParameterSet constructor before injecting required namespaces to avoid mutating the caller's dict - Add create_component(T, ps) overload for address-free construction and set_parameters helper for updating component fields from named pairs - Expand documentation with component construction API section - Add comprehensive tests for parameter access tracking, shallow-copy safety, set_parameters, and setproperty! return values
Add `create_component` specialization for `AbstractCompositeComponent` that injects the root `ParameterSet` into the composite's private `_graph`, enabling `_build_subcomponents` to resolve parameters. - Require scoped (non-root) `ParameterSet` in the generic overload, raising `ArgumentError` for ambiguous root-level usage - Forward `kwargs...` through `create_component` to allow injecting private fields like `_graph` from the composite path - Simplify accessed-path tracking now that prefix is guaranteed non-empty
Remove `Base.convert(::Type{T}, ::MissingNamespace) where {T <: Number}`
to avoid potential method ambiguities while retaining other error-throwing
methods (iterate, length) for MissingNamespace.
Replace parameter set path forwarding syntax with direct keyword argument access on the component struct, avoiding redundant parameter access counting during subcomponent construction.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce
ParameterSet, a mutable nested dictionary wrapper that provides dot-access syntax for reading and writing design parameters. Supportsglobalandcomponentsnamespaces, programmatic construction, and optional YAML serialization via a package extension.Key changes:
ParameterSettype withresolveandleaf_paramsutilitiesParameterSetYAMLExtweak dep extension for YAML load/saveparameter_setinto SchematicDrivenLayout and@component