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

Added deprecation warning when using qiskitrc file #1219

Merged
merged 10 commits into from
Nov 17, 2023
8 changes: 8 additions & 0 deletions qiskit_ibm_runtime/accounts/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import os
import ast
from typing import Optional, Dict

from qiskit_ibm_provider.proxies import ProxyConfiguration

from qiskit_ibm_runtime.utils.deprecation import issue_deprecation_msg
from .exceptions import AccountNotFoundError
from .account import Account, ChannelType
from .storage import save_config, read_config, delete_config, read_qiskitrc
Expand Down Expand Up @@ -195,6 +197,12 @@ def get(
return Account.from_saved_format(all_config[account_name])

if os.path.isfile(_QISKITRC_CONFIG_FILE):
issue_deprecation_msg(
msg="Use of the ~/.qiskit/qiskitrc.json file is deprecated.",
version="0.15.0",
remedy="Please use the ~/.qiskit/qiskit-ibm.json file instead.",
period="1 month",
)
return cls._from_qiskitrc_file()

raise AccountNotFoundError("Unable to find account.")
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
deprecations:
- |
Usage of the ``~/.qiskit/qiskitrc.json`` file for account information has been
deprecated. Use ``~/.qiskit/qiskit-ibm.json`` instead.
2 changes: 1 addition & 1 deletion test/ibm_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def setUpClass(cls):
setup_test_logging(cls.log, filename)
cls._set_logging_level(logging.getLogger(QISKIT_IBM_RUNTIME_LOGGER_NAME))
# fail test on deprecation warnings from qiskit
warnings.filterwarnings("error", category=DeprecationWarning, module="qiskit")
warnings.filterwarnings("error", category=DeprecationWarning, module=r"^qiskit$")

@classmethod
def _set_logging_level(cls, logger: logging.Logger) -> None:
Expand Down
5 changes: 4 additions & 1 deletion test/unit/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import uuid
from typing import Any
from unittest import skipIf
import warnings

from qiskit_ibm_provider.proxies import ProxyConfiguration
from qiskit_ibm_runtime.accounts import (
Expand Down Expand Up @@ -859,7 +860,9 @@ def test_enable_account_by_qiskitrc(self):
"""
with custom_qiskitrc(contents=str.encode(str_contents)):
with temporary_account_config_file(contents={}):
service = FakeRuntimeService()
with warnings.catch_warnings(record=True) as warn:
service = FakeRuntimeService()
self.assertIn("Use of the ~/.qiskit/qiskitrc.json file is deprecated", str(warn[0].message))
self.assertTrue(service._account)
self.assertEqual(service._account.token, token)

Expand Down
Loading