Skip to content

Commit

Permalink
Add deprecation warnings for everything related to custom programs (#…
Browse files Browse the repository at this point in the history
…1153)

* add deprecation warnings for custom programs

* add msg in run()

* fix lint

* remove test_programs.py

* update deprecation message

* add reno
  • Loading branch information
kt474 authored Nov 2, 2023
1 parent f9b4c2c commit c15763a
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 249 deletions.
97 changes: 97 additions & 0 deletions qiskit_ibm_runtime/qiskit_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,18 @@ def pprint_programs(
value of 20.
skip: The number of programs to skip.
"""
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
programs = self.programs(refresh, limit, skip)
for prog in programs:
print("=" * 50)
Expand Down Expand Up @@ -840,6 +852,18 @@ def programs(
Returns:
A list of runtime programs.
"""
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
if skip is None:
skip = 0
if not self._programs or refresh:
Expand Down Expand Up @@ -884,6 +908,18 @@ def program(self, program_id: str, refresh: bool = False) -> RuntimeProgram:
RuntimeProgramNotFound: If the program does not exist.
IBMRuntimeError: If the request failed.
"""
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
if program_id not in self._programs or refresh:
try:
response = self._api_client.program_get(program_id)
Expand Down Expand Up @@ -971,6 +1007,19 @@ def run(
RuntimeProgramNotFound: If the program cannot be found.
IBMRuntimeError: An error occurred running the program.
"""
if program_id not in ["sampler", "estimator", "circuit-runner", "qasm3-runner"]:
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
qrt_options: RuntimeOptions = options
if options is None:
qrt_options = RuntimeOptions()
Expand Down Expand Up @@ -1093,6 +1142,18 @@ def upload_program(self, data: str, metadata: Optional[Union[Dict, str]] = None)
IBMNotAuthorizedError: If you are not authorized to upload programs.
IBMRuntimeError: If the upload failed.
"""
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
program_metadata = self._read_metadata(metadata=metadata)

for req in ["name", "max_execution_time"]:
Expand Down Expand Up @@ -1176,6 +1237,18 @@ def update_program(
RuntimeProgramNotFound: If the program doesn't exist.
IBMRuntimeError: If the request failed.
"""
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
if not any([data, metadata, name, description, max_execution_time, spec]):
warnings.warn(
"None of the 'data', 'metadata', 'name', 'description', "
Expand Down Expand Up @@ -1240,6 +1313,18 @@ def delete_program(self, program_id: str) -> None:
RuntimeProgramNotFound: If the program doesn't exist.
IBMRuntimeError: If the request failed.
"""
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
try:
self._api_client.program_delete(program_id=program_id)
except RequestsApiError as ex:
Expand All @@ -1262,6 +1347,18 @@ def set_program_visibility(self, program_id: str, public: bool) -> None:
RuntimeProgramNotFound: if program not found (404)
IBMRuntimeError: if update failed (401, 403)
"""
warnings.warn(
(
"Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will "
"be removed on November 27, 2023. You can instead convert your custom programs "
"to use Qiskit Runtime primitives with Quantum Serverless. Refer to the migration "
"guide for instructions: "
"https://qiskit-extensions.github.io/quantum-serverless/migration"
"/migration_from_qiskit_runtime_programs.html"
),
DeprecationWarning,
stacklevel=2,
)
try:
self._api_client.set_program_visibility(program_id, public)
except RequestsApiError as ex:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
deprecations:
- |
Custom programs are being deprecated as of qiskit-ibm-runtime 0.14.0 and will be
removed on November 27, 2023. Users can instead convert their custom programs to use
Qiskit Runtime primitives with Quantum Serverless. Refer to the migration guide for
instructions:
https://qiskit-extensions.github.io/quantum-serverless/migration/migration_from_qiskit_runtime_programs.html
Loading

0 comments on commit c15763a

Please sign in to comment.