-
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
plugin convenience function for getting the entry point object #9275
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2475338
plugin convenience function for getting the entry point object
1ucian0 0e1ac16
Merge branch 'main' of github.com:Qiskit/qiskit-terra into entry_poin…
1ucian0 b21c622
simpler code, thanks to Jake
1ucian0 8e8eb11
typehint and docstring
1ucian0 524c886
reno update
1ucian0 1d8c2ef
Merge branch 'main' into entry_point_obj/1
1ucian0 668dab9
Merge branch 'main' of github.com:Qiskit/qiskit-terra into entry_poin…
1ucian0 6135d9f
thanks Jake
1ucian0 2aa840e
Merge branch 'main' into entry_point_obj/1
jakelishman 216a9b6
Fix docs build
jakelishman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,10 +161,11 @@ def pass_manager(self, pass_manager_config, optimization_level): | |
PassManagerStagePlugin | ||
PassManagerStagePluginManager | ||
list_stage_plugins | ||
entry_point_obj | ||
""" | ||
|
||
import abc | ||
from typing import List, Optional | ||
from typing import List, Optional, Dict | ||
|
||
import stevedore | ||
|
||
|
@@ -301,3 +302,36 @@ def list_stage_plugins(stage_name: str) -> List[str]: | |
return plugin_mgr.scheduling_plugins.names() | ||
else: | ||
raise TranspilerError(f"Invalid stage name: {stage_name}") | ||
|
||
|
||
def passmanager_stage_plugins(stage: str) -> Dict[str, PassManagerStagePlugin]: | ||
"""Return a dict with, for each stage name, the class type of the plugin. | ||
|
||
This function is useful for getting more information about a plugin: | ||
|
||
from qiskit.transpiler.preset_passmanagers.plugin import passmanager_stage_plugins | ||
routing_plugins = passmanager_stage_plugins('routing') | ||
basic_plugin = routing_plugins['basic'] | ||
?basic_plugin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in 6135d9f |
||
|
||
Type: BasicSwapPassManager | ||
String form: <...builtin_plugins.BasicSwapPassManager object at 0xdeadbeef> | ||
File: .../qiskit/transpiler/preset_passmanagers/builtin_plugins.py | ||
Docstring: Plugin class for routing stage with :class:`~.BasicSwap` | ||
|
||
Args: | ||
stage: The stage name to get | ||
|
||
Returns: | ||
dict: the key is the name of the plugin and the value is the class type for each. | ||
|
||
Raises: | ||
TranspilerError: If an invalid stage name is specified. | ||
""" | ||
plugin_mgr = PassManagerStagePluginManager() | ||
try: | ||
manager = getattr(plugin_mgr, f"{stage}_plugins") | ||
except AttributeError as exc: | ||
raise TranspilerError(f"Passmanager stage {stage} not found") from exc | ||
|
||
return {name: manager[name].obj for name in manager.names()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
features: | ||
- | | ||
The function ``passmanager_stage_plugins`` in the module | ||
``qiskit.transpiler.preset_passmanagers.plugin`` was added to obtain a map between | ||
plugin names and their class type. | ||
This allows to identify and query passmanager plugin documentation. For example:: | ||
|
||
>>> from qiskit.transpiler.preset_passmanagers.plugin import passmanager_stage_plugins | ||
>>> passmanager_stage_plugins('routing')['lookahead'].__class__ | ||
qiskit.transpiler.preset_passmanagers.builtin_plugins.LookaheadSwapPassManager | ||
|
||
>>> help(passmanager_stage_plugins('routing')['lookahead']) | ||
Help on BasicSwapPassManager in module qiskit.transpiler.preset_passmanagers.builtin_plugins object: | ||
|
||
class BasicSwapPassManager(qiskit.transpiler.preset_passmanagers.plugin.PassManagerStagePlugin) | ||
| Plugin class for routing stage with :class:`~.BasicSwap` | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think the docs failure is just because this line needs updating with the new name.
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.
yeap.. forgot that. Fixed in 6135d9f