This repository was archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 144
Allow users to set a logging level for runtime jobs (#99) #1117
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,64 @@ | ||
| # This code is part of Qiskit. | ||
| # | ||
| # (C) Copyright IBM 2022. | ||
| # | ||
| # This code is licensed under the Apache License, Version 2.0. You may | ||
| # obtain a copy of this license in the LICENSE.txt file in the root directory | ||
| # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
| # | ||
| # Any modifications or derivative works of this code must retain this | ||
| # copyright notice, and modified files need to carry a notice indicating | ||
| # that they have been altered from the originals. | ||
|
|
||
| """Runtime options that control the execution environment.""" | ||
|
|
||
| import re | ||
| import logging | ||
| from dataclasses import dataclass | ||
| from typing import Optional | ||
|
|
||
| from ..exceptions import IBMQInputValueError | ||
|
|
||
|
|
||
| @dataclass | ||
| class RuntimeOptions: | ||
| """Class for representing runtime execution options. | ||
|
|
||
| Args: | ||
| backend_name: target backend to run on. This is required. | ||
| image: the runtime image used to execute the program, specified in | ||
| the form of ``image_name:tag``. Not all accounts are | ||
| authorized to select a different image. | ||
| log_level: logging level to set in the execution environment. The valid | ||
| log levels are: ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR``, and ``CRITICAL``. | ||
| The default level is ``WARNING``. | ||
| """ | ||
|
|
||
| backend_name: str = None | ||
| image: Optional[str] = None | ||
| log_level: Optional[str] = None | ||
|
|
||
| def validate(self) -> None: | ||
| """Validate options. | ||
|
|
||
| Raises: | ||
| IBMQInputValueError: If one or more option is invalid. | ||
| """ | ||
| if self.image and not re.match( | ||
| "[a-zA-Z0-9]+([/.\\-_][a-zA-Z0-9]+)*:[a-zA-Z0-9]+([.\\-_][a-zA-Z0-9]+)*$", | ||
| self.image, | ||
| ): | ||
| raise IBMQInputValueError('"image" needs to be in form of image_name:tag') | ||
|
|
||
| if not self.backend_name: | ||
| raise IBMQInputValueError( | ||
| '"backend_name" is required field in "options".' | ||
| ) | ||
|
|
||
| if self.log_level and not isinstance( | ||
| logging.getLevelName(self.log_level.upper()), int | ||
| ): | ||
| raise IBMQInputValueError( | ||
| f"{self.log_level} is not a valid log level. The valid log levels are: `DEBUG`, " | ||
| f"`INFO`, `WARNING`, `ERROR`, and `CRITICAL`." | ||
| ) | ||
This file contains hidden or 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,12 @@ | ||
| --- | ||
| features: | ||
| - | | ||
| You can now specify a different logging level in the ``options`` keyword | ||
| when submitting a Qiskit Runtime job with the | ||
| :meth:`qiskit.providers.ibmq.runtime.IBMRuntimeService.run` method. | ||
| deprecations: | ||
| - | | ||
| The ``image`` keyword in the | ||
| :meth:`qiskit.providers.ibmq.runtime.IBMRuntimeService.run` method is | ||
| deprecated. You should instead specify the image to use in the ``options`` | ||
| keyword. |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.
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 see dataclass is a Python 3.7+ feature. We still support Python 3.6 for the upcoming provider release since terra 0.19.x still supports it and then it will be dropped after the 0.19.0 provider release. Would this work with Python 3.6?
Uh oh!
There was an error while loading. Please reload this page.
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.
But Python 3.6 end of life was more than a month ago, and the latest qiskit-terra no longer supports 3.6.
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.
Just add
dataclasses>=0.8;python_version<'3.7'to the requirements list. Being in the metapackage puts extra requirements and for the metapackage we've got more conservative support versions and we've previously advertised that terra 0.19.x (and aer 0.10.x) supports python 3.6. So we can't add anything to the metapackage that requires >3.6 until we release terra 0.20.0