-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Unify OpenQASM 2 exceptions #9956
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 5548013092
💛 - Coveralls |
The problems in the QPY backwards compatibility tests are likely because it uses a slightly unusual ordering and import structure for its objects, and there are nasty circular dependencies between See #9959 for the fix on that. |
0712575
to
b8d7469
Compare
Since Qiskitgh-9784 added a new `qiskit.qasm2` package and suitable exceptions for both import and export of OpenQASM 2 programs, this commit now unifies the exception handling through the rest of the library to use these exceptions. To avoid breaks in compatibility, the old `qiskit.qasm.QasmError` is now a re-export of `qiskit.qasm2.QASM2Error`. This is the base error of both the exporter and importers, despite the old documentation of `QasmError` claiming to be specifically for parser errors. In practice, the exporter also emitted `QasmError`, so having that be `QASM2Error` allows people catching that error to get the same behaviour in these new forms. The actual exporter and importer are updated to emit the precise subclasses.
b8d7469
to
7f33cd8
Compare
7f33cd8
to
58d2dd5
Compare
Arg. I made every effort to ensure no conflicts... Anyway, a blank line and an unwanted import |
John: what are you trying to do to this PR? It was already up-to-date and rebased completely on top of |
I convinced myself that it was not correct (because it was rebased on most recent main, and things disappeared). But, I agree that your rebase on main was already correct. I also think that what I force pushed was also the same as what you did. |
I fixed or avoided the two errors above here: jakelishman#14 |
The slight change in import order means that two new `Gate` class bodies got executed during the imports for this particular part of the test suite. These gates were internal to the `qasm2.load` functionality and should be exempt from the automated definition-equivalence testing.
76e7e95
to
f827bb0
Compare
Ok, I've reverted it back to the previous state and put in the correct test fix - the issue is that a change in some of the imports caused |
I was just comparing your last branch to mine. I think I rebased on top of main that was less up to date than yours. So I agree reverting was correct.
I assumed it was intended. I may have tried harder with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks ready
Summary
Since gh-9784 added a new
qiskit.qasm2
package and suitable exceptions for both import and export of OpenQASM 2 programs, this commit now unifies the exception handling through the rest of the library to use these exceptions.To avoid breaks in compatibility, the old
qiskit.qasm.QasmError
is now a re-export ofqiskit.qasm2.QASM2Error
. This is the base error of both the exporter and importers, despite the old documentation ofQasmError
claiming to be specifically for parser errors. In practice, the exporter also emittedQasmError
, so having that beQASM2Error
allows people catching that error to get the same behaviour in these new forms. The actual exporter and importer are updated to emit the precise subclasses.Details and comments
Probably this will clash a little with #9955 (and this PR technically probably wants to merge before that one) and potentially #9953. I'll fix any merge conflicts as they arise.
This PR is preparing for a later total deprecation and removal of the
qiskit.qasm
namespace, likely starting in Terra 0.26, since we've begun the process of moving toqiskit.qasm2
andqiskit.qasm3
as explicitly versioned packages, to avoid confusion in the future.