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

Deprecate execute() #7892

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions qiskit/execute_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ def execute(

job = execute(qc, backend, shots=4321)
"""
warnings.warn('The execute() function in Qiskit is deprecated as of Qiskit Terra 0.21.0, '
'and will be removed in a future release. '
'Instead, please use transpile() followed by backend.run(). '
'Alternatively, to achieve a similar high-level functionality, please '
'use qiskit primitives.',
DeprecationWarning, stacklevel=2)
if isinstance(experiments, (Schedule, ScheduleBlock)) or (
isinstance(experiments, list) and isinstance(experiments[0], (Schedule, ScheduleBlock))
):
Expand Down
20 changes: 20 additions & 0 deletions releasenotes/notes/deprecate-execute-67a5c68b93722057.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
deprecations:
- |
Qiskit's :func:`~.execute_function.execute` function is deprecated.
This function served as a high-level wrapper around transpiling
a circuit with some transpile options and running it on a backend
with some run options. To do the same thing, you can explicitly
use the :func:`~.transpile` function (with appropriate transpile
options) followed by `backend.run()` (with appropriate run options).

For example, instead of running::

from qiskit import execute
job = execute(circuit, backend)

you can run::

from qiskit import transpile
new_circuit = transpile(circuit)
job = backend.run(new_circuit)
Comment on lines +18 to +20
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from qiskit import transpile
new_circuit = transpile(circuit)
job = backend.run(new_circuit)
from qiskit import transpile
new_circuit = transpile(circuit, backend)
job = backend.run(new_circuit)