Skip to content

Added ParameterSet for data-driven design parameterization#204

Open
ad-cqc wants to merge 13 commits intoaws-cqc:mainfrom
ad-cqc:ad/param-set
Open

Added ParameterSet for data-driven design parameterization#204
ad-cqc wants to merge 13 commits intoaws-cqc:mainfrom
ad-cqc:ad/param-set

Conversation

@ad-cqc
Copy link
Copy Markdown
Contributor

@ad-cqc ad-cqc commented Apr 15, 2026

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ad-cqc ad-cqc requested a review from gpeairs April 15, 2026 21:08
@ad-cqc ad-cqc self-assigned this Apr 15, 2026
Copy link
Copy Markdown
Member

@gpeairs gpeairs left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/schematics/parameter_set.jl Outdated
Comment thread docs/src/reference/parameter_set.md Outdated
Comment thread docs/src/reference/parameter_set.md Outdated
Comment thread src/parameter_set.jl Outdated
Comment thread src/parameter_set.jl Outdated
Comment thread src/schematics/parameter_set.jl Outdated
Comment thread src/schematics/parameter_set.jl
Comment thread docs/src/reference/parameter_set.md Outdated
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.
ad-cqc added 13 commits April 23, 2026 14:03
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.
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