Skip to content
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

The unused parameter dag in DAGNode constructor is deprecated #13862

Merged
merged 7 commits into from
Feb 20, 2025

Conversation

1ucian0
Copy link
Member

@1ucian0 1ucian0 commented Feb 17, 2025

Summary

Fixes #13022

Details and comments

Because qiskit._accelerate.circuit.DAGNode (and family) are rust implementations, I had to write a custom decorator wrapper for them.

@1ucian0 1ucian0 added this to the 1.4.0 milestone Feb 17, 2025
@1ucian0 1ucian0 requested a review from a team as a code owner February 17, 2025 16:54
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

I'm pretty sure this approach won't work. It changes the semantics around the DAG node types and will break a lot of the usage around the classes. It should be pretty easy to emit the deprecation warning from rust though, here is an example of calling python's warning from rust:

fn get_duration(&self, py: Python) -> PyResult<Option<Py<PyAny>>> {
imports::WARNINGS_WARN.get_bound(py).call1((
intern!(
py,
concat!(
"The property ``qiskit.dagcircuit.dagcircuit.DAGCircuit.duration`` is ",
"deprecated as of Qiskit 1.3.0. It will be removed in Qiskit 2.0.0.",
)
),
py.get_type::<PyDeprecationWarning>(),
2,
))?;
Ok(self.duration.as_ref().map(|x| x.clone_ref(py)))

We can just wrap that in an if dag.is_some() for the dag node constructor and that should cover it.

@1ucian0
Copy link
Member Author

1ucian0 commented Feb 17, 2025

I saw your message about raising from rust too late and I implemented in python overwriting __init__ in e51cf2c. Not very elegant. What do you think?

@1ucian0 1ucian0 marked this pull request as ready for review February 17, 2025 18:22
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@1ucian0 1ucian0 linked an issue Feb 17, 2025 that may be closed by this pull request
@mtreinish
Copy link
Member

I saw your message about raising from rust too late and I implemented in python overwriting __init__ in e51cf2c. Not very elegant. What do you think?

I think we should probably add it in rust. It's a lot simpler and less error prone..

@1ucian0 1ucian0 marked this pull request as draft February 17, 2025 23:22
@1ucian0
Copy link
Member Author

1ucian0 commented Feb 20, 2025

done in b6426fc . Easier than expected and much more correct. Thanks for the rusty push :)

@1ucian0 1ucian0 marked this pull request as ready for review February 20, 2025 10:37
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

LGTM!

@ElePT ElePT added this pull request to the merge queue Feb 20, 2025
Merged via the queue into Qiskit:stable/1.4 with commit d31c6aa Feb 20, 2025
16 checks passed
@ElePT ElePT added the Changelog: Deprecation Include in "Deprecated" section of changelog label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Deprecation Include in "Deprecated" section of changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider deprecating use of dag keyword in DAGNode constructors
4 participants