-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from qiboteam/raise_warning_on_version_mismatch
Raise warning instead of error when qibo version mismatch
- Loading branch information
Showing
8 changed files
with
97 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,8 @@ | ||
import logging | ||
import os | ||
|
||
# configure logger | ||
logging.basicConfig(format="[%(asctime)s] %(levelname)s: %(message)s") | ||
logger = logging.getLogger(__name__) | ||
logging_level = os.environ.get("QIBO_CLIENT_LOGGER_LEVEL", logging.INFO) | ||
logger.setLevel(logging_level) |
This file contains 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,9 @@ | ||
import os | ||
from pathlib import Path | ||
|
||
MINIMUM_QIBO_VERSION_ALLOWED = "0.2.4" | ||
|
||
RESULTS_BASE_FOLDER = Path(os.environ.get("RESULTS_BASE_FOLDER", "/tmp/qibo_client")) | ||
SECONDS_BETWEEN_CHECKS = os.environ.get("SECONDS_BETWEEN_CHECKS", 2) | ||
|
||
TIMEOUT = 10 |
This file contains 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 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,30 @@ | ||
from unittest import TestCase | ||
from unittest.mock import patch | ||
|
||
MOD = "qibo_client.config_logging" | ||
|
||
|
||
def logging_wrap_function(logger_object): | ||
logger_object.info("A debug log") | ||
logger_object.error("An error log") | ||
|
||
|
||
class TestLogger(TestCase): | ||
@patch(f"{MOD}.os.environ", {"QIBO_CLIENT_LOGGER_LEVEL": "info"}) | ||
def test_logging_with_info_level(self, mock_os): | ||
from qibo_client.config_logging import logger | ||
|
||
with self.assertLogs() as captured: | ||
logging_wrap_function(logger) | ||
self.assertEqual(len(captured.records), 1) | ||
self.assertEqual(captured.records[0].getMessage(), "An error log") | ||
|
||
@patch(f"{MOD}.os.environ", {"QIBO_CLIENT_LOGGER_LEVEL": "notset"}) | ||
def test_logging_with_info_level(self): | ||
from qibo_client.config_logging import logger | ||
|
||
with self.assertLogs() as captured: | ||
logging_wrap_function(logger) | ||
self.assertEqual(len(captured.records), 2) | ||
self.assertEqual(captured.records[0].getMessage(), "A debug log") | ||
self.assertEqual(captured.records[1].getMessage(), "An error log") |
This file contains 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