From 298f5614411e84fdc99cc73a50493c7bb65e5f09 Mon Sep 17 00:00:00 2001 From: merav-aharoni Date: Wed, 15 Nov 2023 11:02:28 +0000 Subject: [PATCH 1/5] Added deprecation warning when using qiskitrc file --- qiskit_ibm_runtime/accounts/management.py | 6 ++++++ test/unit/test_account.py | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/qiskit_ibm_runtime/accounts/management.py b/qiskit_ibm_runtime/accounts/management.py index 34eab1dd8..6d0242a8d 100644 --- a/qiskit_ibm_runtime/accounts/management.py +++ b/qiskit_ibm_runtime/accounts/management.py @@ -15,6 +15,8 @@ import os import ast from typing import Optional, Dict +import warnings + from qiskit_ibm_provider.proxies import ProxyConfiguration from .exceptions import AccountNotFoundError @@ -195,6 +197,10 @@ def get( return Account.from_saved_format(all_config[account_name]) if os.path.isfile(_QISKITRC_CONFIG_FILE): + warnings.warn( + "Use of the ~/.qiskit/qiskitrc.json file is deprecated." + "Please use the ~/.qiskit/qiskit-ibm.json file instead." + ) return cls._from_qiskitrc_file() raise AccountNotFoundError("Unable to find account.") diff --git a/test/unit/test_account.py b/test/unit/test_account.py index 409166714..90605a88f 100644 --- a/test/unit/test_account.py +++ b/test/unit/test_account.py @@ -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 ( @@ -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) From 3c038d142333b6b8e4824122bcff124d3bcae71a Mon Sep 17 00:00:00 2001 From: merav-aharoni Date: Thu, 16 Nov 2023 11:01:41 +0000 Subject: [PATCH 2/5] Fixed bug whereby deprecation warnings cause failure for all 'qiskit*' modules. Changed warning to deprecation warning. --- qiskit_ibm_runtime/accounts/management.py | 10 ++++++---- test/ibm_test_case.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/qiskit_ibm_runtime/accounts/management.py b/qiskit_ibm_runtime/accounts/management.py index 6d0242a8d..38060923d 100644 --- a/qiskit_ibm_runtime/accounts/management.py +++ b/qiskit_ibm_runtime/accounts/management.py @@ -15,10 +15,10 @@ import os import ast from typing import Optional, Dict -import warnings 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 @@ -197,9 +197,11 @@ def get( return Account.from_saved_format(all_config[account_name]) if os.path.isfile(_QISKITRC_CONFIG_FILE): - warnings.warn( - "Use of the ~/.qiskit/qiskitrc.json file is deprecated." - "Please use the ~/.qiskit/qiskit-ibm.json file instead." + 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() diff --git a/test/ibm_test_case.py b/test/ibm_test_case.py index 5c4e642ab..f58158a22 100644 --- a/test/ibm_test_case.py +++ b/test/ibm_test_case.py @@ -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: From 2b242f61b734dc7b3b9132b408ab57e406906fc9 Mon Sep 17 00:00:00 2001 From: merav-aharoni Date: Thu, 16 Nov 2023 11:05:01 +0000 Subject: [PATCH 3/5] Release note --- releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml diff --git a/releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml b/releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml new file mode 100644 index 000000000..06afea404 --- /dev/null +++ b/releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + Usage of ``~/.qiskit/qiskitrc.json`` file for account information has been + deprecated. Use ``~/.qiskit/qiskit-ibm.json`` instead. From 65522bd6c73cb502bac0c872ed5688df3233b322 Mon Sep 17 00:00:00 2001 From: merav-aharoni Date: Thu, 16 Nov 2023 11:07:15 +0000 Subject: [PATCH 4/5] Small grammer fix --- releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml b/releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml index 06afea404..12d59babd 100644 --- a/releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml +++ b/releasenotes/notes/deprecate_qiskitrc-1fd8afc6d599fc0e.yaml @@ -1,5 +1,5 @@ --- deprecations: - | - Usage of ``~/.qiskit/qiskitrc.json`` file for account information has been + Usage of the ``~/.qiskit/qiskitrc.json`` file for account information has been deprecated. Use ``~/.qiskit/qiskit-ibm.json`` instead. From 3c636ea7ffcf5965e3d5220dbd35926898a836d6 Mon Sep 17 00:00:00 2001 From: merav-aharoni Date: Thu, 16 Nov 2023 11:11:36 +0000 Subject: [PATCH 5/5] black --- qiskit_ibm_runtime/accounts/management.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_ibm_runtime/accounts/management.py b/qiskit_ibm_runtime/accounts/management.py index 38060923d..f230e40a5 100644 --- a/qiskit_ibm_runtime/accounts/management.py +++ b/qiskit_ibm_runtime/accounts/management.py @@ -201,7 +201,7 @@ def get( 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" + period="1 month", ) return cls._from_qiskitrc_file()