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

Optional dependency checker doesn't trigger on BooleanExpression.from_dimacs_file #10079

Closed
mtreinish opened this issue May 4, 2023 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@mtreinish
Copy link
Member

Environment

  • Qiskit Terra version: 0.24.0
  • Python version: 3.10
  • Operating system: Linux

What is happening?

When trying to use BooleanExpression.from_dimacs_file the optional dependency checker isn't correctly detecting that tweedledum isn't installed. This causes the wrong exception to be raised when the constructor tries to import tweedledum.

How can we reproduce the issue?

from qiskit.circuit.classicalfunction.boolean_expression import BooleanExpression

BooleanExpression.from_dimacs_file('/dev/null')

What should happen?

This should raise a MissingOptionalLibraryError instead of a ModuleNotFoundError

Any suggestions?

This seems to be coming from #9754 which changed the optional library check from a module level thing to using the decorator form with require_in_instance. I think the require_in_instance decorator doesn't know how to wrap classmethod constructors and is only work with __init__. The easiest way to fix this is probably to just add an explicit call to check before we import in the class method constructor.

@jakelishman
Copy link
Member

Fixed by #10132.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants