Skip to content

Document that update_instruction_property should be the only way of updating the Target #14269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
raynelfss opened this issue Apr 29, 2025 · 2 comments · May be fixed by #14379
Open

Document that update_instruction_property should be the only way of updating the Target #14269

raynelfss opened this issue Apr 29, 2025 · 2 comments · May be fixed by #14379
Assignees
Labels
documentation Something is not clear or an error documentation type: feature request New feature or request
Milestone

Comments

@raynelfss
Copy link
Contributor

What should we add?

As of now, Python technically allows us to use indexing to access the Target's gate_map and perform in place replacement of certain properties, which worked well while the interface lived entirely in Python, but was never explicitly supported. However, now that the Target has moved its data model to Rust, doing this desynchronizes the python side gate map from the rust one, which can result in incorrect assumptions.

It is recommended that we explicitly document that in place mutation of the Target using indexing should not be supported in Python, at least until we figure out a way of synchronizing both mappings to the point where mutation via indexing is once again possible.

@raynelfss raynelfss added documentation Something is not clear or an error documentation type: feature request New feature or request labels Apr 29, 2025
@mtreinish mtreinish added this to the 2.1.0 milestone Apr 29, 2025
@mtreinish
Copy link
Member

Just to be very explicit here, direct mutation using the mapping protocol was never supported, even before data was stored in Rust. This is because there is internal caching and if you update the properties outside of the provided method the caches get out of sync. If you were only changing an error rate or duration for a single instruction you'd probably get by without any issue, but the API was not designed to be mutable like this. We need to close the documentation gap to make this explicitly clear.

@jakelishman
Copy link
Member

Fwiw, we could potentially have protected against this in Python space with some judicious use of types.MappingProxyType, which we can wrap round dict cheaply to make it (shallowly) immutable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Something is not clear or an error documentation type: feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants