From cd78951677d6ee0f054be3d6515b9e49b122acc7 Mon Sep 17 00:00:00 2001 From: jtsodapop <67922677+jtsodapop@users.noreply.github.com> Date: Tue, 8 Sep 2020 16:56:23 -0700 Subject: [PATCH 1/5] adding in the test_logger file and updating the readme to include installing Docker --- README.md | 2 +- tests/test_logger.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/test_logger.py diff --git a/README.md b/README.md index 4f2cf6801..83d376660 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ client = Client() Please consult `CONTRIB.md` ## Testing -1. Update the `Makefile` with your `staging` or `prod` API key. Make sure the key is not from a free tier account. +1. Update the `Makefile` with your `staging` or `prod` API key. Ensure that docker has been installed on your system. Make sure the key is not from a free tier account. 2. To test on `staging`: ``` make test-staging diff --git a/tests/test_logger.py b/tests/test_logger.py new file mode 100644 index 000000000..eca96c90f --- /dev/null +++ b/tests/test_logger.py @@ -0,0 +1,20 @@ +from labelbox import Client +import pytest +import logging + +def test_logging_info(caplog): + """ + This test does a check on what is currently logged to the console. + + Initialization of client will not produce a log unless the logging level has been downgraded to INFO or DEBUG. + The initial level of log is defaulted to WARNING. + """ + + client = Client() + assert "Initializing Labelbox client at 'https://api.labelbox.com/graphql'" not in caplog.text + + caplog.set_level(logging.INFO) + + client = Client() + assert "Initializing Labelbox client at 'https://api.labelbox.com/graphql'" in caplog.text + From a40ac6f9333a39ce0fc852bc95cdd91ef01a60d5 Mon Sep 17 00:00:00 2001 From: jtsodapop <67922677+jtsodapop@users.noreply.github.com> Date: Tue, 8 Sep 2020 20:00:27 -0700 Subject: [PATCH 2/5] update to test_logger file, adding to integration tests also --- tests/integration/test_logger.py | 12 ++++++++++++ tests/test_logger.py | 20 -------------------- 2 files changed, 12 insertions(+), 20 deletions(-) create mode 100644 tests/integration/test_logger.py delete mode 100644 tests/test_logger.py diff --git a/tests/integration/test_logger.py b/tests/integration/test_logger.py new file mode 100644 index 000000000..e497dacd8 --- /dev/null +++ b/tests/integration/test_logger.py @@ -0,0 +1,12 @@ +from labelbox import Client +import pytest +import logging + +def test_client_log(caplog, project): + + project.export_labels() + assert '' == caplog.text + + with caplog.at_level(logging.DEBUG): + project.export_labels() + assert "label export, waiting for server..." in caplog.text diff --git a/tests/test_logger.py b/tests/test_logger.py deleted file mode 100644 index eca96c90f..000000000 --- a/tests/test_logger.py +++ /dev/null @@ -1,20 +0,0 @@ -from labelbox import Client -import pytest -import logging - -def test_logging_info(caplog): - """ - This test does a check on what is currently logged to the console. - - Initialization of client will not produce a log unless the logging level has been downgraded to INFO or DEBUG. - The initial level of log is defaulted to WARNING. - """ - - client = Client() - assert "Initializing Labelbox client at 'https://api.labelbox.com/graphql'" not in caplog.text - - caplog.set_level(logging.INFO) - - client = Client() - assert "Initializing Labelbox client at 'https://api.labelbox.com/graphql'" in caplog.text - From 477f86a5199b7478a79845078c7887d05af9fa78 Mon Sep 17 00:00:00 2001 From: jtsodapop <67922677+jtsodapop@users.noreply.github.com> Date: Wed, 9 Sep 2020 10:02:24 -0700 Subject: [PATCH 3/5] adding in docstring --- tests/integration/test_logger.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/integration/test_logger.py b/tests/integration/test_logger.py index e497dacd8..728731315 100644 --- a/tests/integration/test_logger.py +++ b/tests/integration/test_logger.py @@ -3,6 +3,13 @@ import logging def test_client_log(caplog, project): + """ + This file tests that the logger will properly output to the console after updating logging level + + The default level is set to WARNING + + There is an expected output after setting logging level to DEBUG + """ project.export_labels() assert '' == caplog.text From 4b3c5657725bb3a1ba8253c7f84819a1b280d679 Mon Sep 17 00:00:00 2001 From: jtsodapop <67922677+jtsodapop@users.noreply.github.com> Date: Wed, 9 Sep 2020 10:40:12 -0700 Subject: [PATCH 4/5] ran yapf for style comformity --- tests/integration/test_logger.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_logger.py b/tests/integration/test_logger.py index 728731315..c8b9dcf8b 100644 --- a/tests/integration/test_logger.py +++ b/tests/integration/test_logger.py @@ -2,7 +2,8 @@ import pytest import logging -def test_client_log(caplog, project): + +def test_client_log(caplog, project): """ This file tests that the logger will properly output to the console after updating logging level From a8bcdb6414dd5a6fa18e12fdec770ffdbadeda84 Mon Sep 17 00:00:00 2001 From: jtsodapop <67922677+jtsodapop@users.noreply.github.com> Date: Wed, 9 Sep 2020 17:29:14 -0700 Subject: [PATCH 5/5] updating docstring of client.py to show how to increase verbosity of output --- labelbox/client.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/labelbox/client.py b/labelbox/client.py index d81ad22b4..02d11669f 100644 --- a/labelbox/client.py +++ b/labelbox/client.py @@ -44,6 +44,18 @@ def __init__(self, labelbox.exceptions.AuthenticationError: If no `api_key` is provided as an argument or via the environment variable. + + Logging: + Logging is defaulted to level WARNING. To receive more verbose + output to console, update logging.level to the + appropriate level. + + Example: + #get updated on console when client is instantiated + import logger + + logging.basicConfig(level = logging.INFO) + client = Client("") """ if api_key is None: if _LABELBOX_API_KEY not in os.environ: