`NativeQuilMetadata` exposes no attribute getters in Python
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 84/100
Direzione di ricerca
Inizia in crates/lib/src/compiler/quilc.rs, alla dichiarazione della pyclass NativeQuilMetadata, e confrontala con le classi affini che usano get_all. Verifica che il qcs_sdk/compiler/quilc.pyi generato esponga getter per tutti e otto i campi e che il codice Python possa leggere final_rewiring e gli altri valori dei metadati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
CompilationResult.native_quil_metadata is readable, but nothing on the object it returns is:
>>> from qcs_sdk.compiler.quilc import NativeQuilMetadata
>>> m = NativeQuilMetadata([9, 0, 1, 2], 3, 4, 1, 0.5, 0.99, 2, 1.5)
>>> [a for a in dir(m) if not a.startswith("_")]
[]
>>> m.final_rewiring
AttributeError: 'qcs_sdk.compiler.quilc.NativeQuilMetadata' object has no attribute 'final_rewiring'
Verified on qcs-sdk-python 0.26.3 (latest) and 0.26.1, and still the case on main: quilc.pyi declares only __eq__, __getnewargs__, __new__ and __repr__ for the class.
It looks like an omission
In crates/lib/src/compiler/quilc.rs#L302, NativeQuilMetadata is the only pyclass in the module that has pub fields and does not pass get_all:
| pyclass | get_all |
field visibility |
|---|---|---|
CompilationResult, PauliTerm, and 5 others |
yes | pub |
CompilerOpts |
no | pub(crate) |
TargetDevice |
no | private |
NativeQuilMetadata |
no | pub |
So the two classes that legitimately hide their fields do so by keeping them non-public, while this one declares all eight fields pub and then exposes none of them.
Why it's worth fixing
final_rewiring is the only record of how quilc relabelled logical qubits onto physical ones. Anything expressed in physical qubits has to be interpreted against it — Quil-T especially, since DELAY 0 0.0005 and frame references address physical qubits, and reasoning about a compiled program without the mapping silently targets the wrong qubit rather than failing.
The only route today is __getnewargs__()[0]. It does return a typed list[int], so this isn't blocking, but it's the pickle protocol rather than an accessor: positional, undocumented, free to change, and it yields None instead of [] for an empty rewiring. __repr__ is the alternative, which means parsing Rust Debug output.
Suggested fix
#[cfg_attr(
feature = "python",
- pyo3::pyclass(module = "qcs_sdk.compiler.quilc", eq)
+ pyo3::pyclass(module = "qcs_sdk.compiler.quilc", eq, get_all)
)]
pub struct NativeQuilMetadata {
Sibling classes also pass frozen; I've left it out here since it's a semantic change beyond adding getters, but it would match the module if you want it.
Happy to open a PR.
- Lingua principale
- Rust
- Stelle
- 15
- Fork
- 4
- Merge medio
- 10h 36m
- PR unite (30g)
- 2
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rigetti/qcs-sdk-rust
-
PyPI size limit is a frequent blocker for releases, with no notification that release has failedAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
rigetti/qcs-sdk-rust#607 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
rigetti/qcs-sdk-rust#604 ·
-
Type-check Python code in CIAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
rigetti/qcs-sdk-rust#595 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
rigetti/qcs-sdk-rust#591 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
rigetti/qcs-sdk-rust#586 ·
Tutte le issue di rigetti/qcs-sdk-rust
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 1-3 ore Idoneità per principianti 95/100
ClickHouse/clickhouse-rs#589 ·
I maintainer di solito rispondono entro 2 giorni
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pbakaus/impeccable#1887 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
bruits/satteri#400 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni