PsiQ / qref

Quantum Resource Estimate Format
https://psiq.github.io/qref/
Apache License 2.0
34 stars 3 forks source link

feat: Implement accessing ports/children/resources by name #114

Closed dexter2206 closed 3 months ago

dexter2206 commented 3 months ago

Description

When talking with @mstechly we identified several possible improvements to interacting with QREF's pydantic models, namely:

This PR implements both of the improvements described above.

Caveat Only top level assignments are validated. I.e. this is validated:

routine.resources = [{...}, {...}]

and this is not validated:

routine.resources[0] = {...}

Pydantic can only do the first one, and for good reason - if routine.resources is a list, it cannot override how its items are accessed. We could do this ourselves by using e.g. RootModel to wrap lists, but it seems like a lot of code which wouldn't add that much value IMO.

Please verify that you have completed the following steps