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

Make python-constraint optional #7733

Merged
merged 9 commits into from
May 26, 2022
Merged

Conversation

mtreinish
Copy link
Member

Summary

Since #7213 we no longer have been using the CSPLayout pass by default
in the preset passmanagers or transpile(). This is because it has been
superseded by the VF2Layout pass which is now used everywhere. While we
will keep the CSPLayout pass around for the forseeable future there is
no need to install python-constraint by default anymore since it's only
user is the CSPLayout pass, which isn't going to be commonly used
anymore now that it's not used in the default compilation path anymore.
This commit removes the python-constraint library from the requirements
list and makes it an optional dependency.

Details and comments

Fixes #7726

@mtreinish mtreinish added the Changelog: API Change Include in the "Changed" section of the changelog label Mar 3, 2022
@mtreinish mtreinish added this to the 0.20 milestone Mar 3, 2022
@coveralls
Copy link

coveralls commented Mar 3, 2022

Pull Request Test Coverage Report for Build 2392360390

  • 38 of 38 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 84.391%

Totals Coverage Status
Change from base Build 2391592163: 0.002%
Covered Lines: 54559
Relevant Lines: 64650

💛 - Coveralls

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

The benchmark suite in Qiskit/qiskit directly imports CSPLayout from Terra, so that's one case where we going to need to handle this issue of defining a new extra and immediately moving previously required functionality into it. For the benchmark suite in particular, we don't need to synchronise CI because it doesn't matter if the benchmark run fails, but it's more indicative of the potential issue.

qiskit/utils/optionals.py Outdated Show resolved Hide resolved
setup.py Show resolved Hide resolved
@kdk kdk modified the milestones: 0.20, 0.21 Mar 29, 2022
Since Qiskit#7213 we no longer have been using the CSPLayout pass by default
in the preset passmanagers or transpile(). This is because it has been
superseded by the VF2Layout pass which is now used everywhere. While we
will keep the CSPLayout pass around for the forseeable future there is
no need to install python-constraint by default anymore since it's only
user is the CSPLayout pass, which isn't going to be commonly used
anymore now that it's not used in the default compilation path anymore.
This commit removes the python-constraint library from the requirements
list and makes it an optional dependency.

Fixes Qiskit#7726
This commit splits the custom solver class definition out into a
separate private module that is not imported until runtime. This enables
us to avoid a module level import for python-constraint meaning we only
try to import if something is actually using CSPLayout.
mtreinish and others added 2 commits May 26, 2022 11:02
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

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

Nitpicky documentation comment aside, this looks good to me.

qiskit/utils/optionals.py Outdated Show resolved Hide resolved
@mergify mergify bot merged commit e508729 into Qiskit:main May 26, 2022
@mtreinish mtreinish deleted the constraint-optional branch May 26, 2022 20:59
ElePT pushed a commit to ElePT/qiskit-algorithms that referenced this pull request Jul 27, 2023
* Make python-constraint optional

Since Qiskit/qiskit#7213 we no longer have been using the CSPLayout pass by default
in the preset passmanagers or transpile(). This is because it has been
superseded by the VF2Layout pass which is now used everywhere. While we
will keep the CSPLayout pass around for the forseeable future there is
no need to install python-constraint by default anymore since it's only
user is the CSPLayout pass, which isn't going to be commonly used
anymore now that it's not used in the default compilation path anymore.
This commit removes the python-constraint library from the requirements
list and makes it an optional dependency.

Fixes Qiskit/qiskit#7726

* Add docstring for HAS_CONSTRAINT

* Add private module to avoid module level optional import

This commit splits the custom solver class definition out into a
separate private module that is not imported until runtime. This enables
us to avoid a module level import for python-constraint meaning we only
try to import if something is actually using CSPLayout.

* Fix rebase issue

* Fix lint

* Fix typo in release note

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>

* Alphabetize optionals list

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: API Change Include in the "Changed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make python-constraint requirement optional
5 participants