lightning/tests/tests_app/utilities/test_log_helpers.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
1016 B
Python
Raw Normal View History

[CLI] Adding opportunity to see basic cluster logs (#14334) * pinning starsessions * pinning starsessions * adding strict back to requirements.txt * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Duplicated * Basic implementation * Basic implementation * Basic implementation * Basic implementation * Common things moved to log helpers file * Decomposing logs reader classes for reusing * Setting colors for log levels * Manifest trimming * Changes added to CHANGELOG * Prettifications * Prettifications * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Logs function name change * Logs function name change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix the pydanitc import * Tests + command name fixes * Extending tests * Adding limit argument * Unmerging CI fix * Unmerging CI fix * Adding fields for errors * Adding log level fixed field width * Adding absent typing + exeptions raising * Adding socket error logging * Addressing comments on cluster list function return value * Addressing comments on adding e2e tests * Adding version range for arrow package in reqs * New unit tests * arrow time parsing callback modified + unit tests * helpers updated * helpers updated * helpers updated * One more test * CMD test fix * CMD test fix * CMD test fix * CMD test fix * CMD test fix * LightningClient mocking * Flaky test removed Co-authored-by: hhsecond <sherin@grid.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-08-23 19:48:22 +00:00
from unittest import mock, TestCase
from lightning.app.utilities.log_helpers import _error_callback
[CLI] Adding opportunity to see basic cluster logs (#14334) * pinning starsessions * pinning starsessions * adding strict back to requirements.txt * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Duplicated * Basic implementation * Basic implementation * Basic implementation * Basic implementation * Common things moved to log helpers file * Decomposing logs reader classes for reusing * Setting colors for log levels * Manifest trimming * Changes added to CHANGELOG * Prettifications * Prettifications * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Logs function name change * Logs function name change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix the pydanitc import * Tests + command name fixes * Extending tests * Adding limit argument * Unmerging CI fix * Unmerging CI fix * Adding fields for errors * Adding log level fixed field width * Adding absent typing + exeptions raising * Adding socket error logging * Addressing comments on cluster list function return value * Addressing comments on adding e2e tests * Adding version range for arrow package in reqs * New unit tests * arrow time parsing callback modified + unit tests * helpers updated * helpers updated * helpers updated * One more test * CMD test fix * CMD test fix * CMD test fix * CMD test fix * CMD test fix * LightningClient mocking * Flaky test removed Co-authored-by: hhsecond <sherin@grid.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-08-23 19:48:22 +00:00
class TestErrorCallback(TestCase):
def test_known_error(self):
websocket = mock.Mock()
with self.assertLogs("lightning.app.utilities.log_helpers") as captured:
[CLI] Adding opportunity to see basic cluster logs (#14334) * pinning starsessions * pinning starsessions * adding strict back to requirements.txt * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Duplicated * Basic implementation * Basic implementation * Basic implementation * Basic implementation * Common things moved to log helpers file * Decomposing logs reader classes for reusing * Setting colors for log levels * Manifest trimming * Changes added to CHANGELOG * Prettifications * Prettifications * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Logs function name change * Logs function name change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix the pydanitc import * Tests + command name fixes * Extending tests * Adding limit argument * Unmerging CI fix * Unmerging CI fix * Adding fields for errors * Adding log level fixed field width * Adding absent typing + exeptions raising * Adding socket error logging * Addressing comments on cluster list function return value * Addressing comments on adding e2e tests * Adding version range for arrow package in reqs * New unit tests * arrow time parsing callback modified + unit tests * helpers updated * helpers updated * helpers updated * One more test * CMD test fix * CMD test fix * CMD test fix * CMD test fix * CMD test fix * LightningClient mocking * Flaky test removed Co-authored-by: hhsecond <sherin@grid.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-08-23 19:48:22 +00:00
_error_callback(websocket, ValueError())
# check that there is only one log message
assert len(captured.records) == 1
[CLI] Adding opportunity to see basic cluster logs (#14334) * pinning starsessions * pinning starsessions * adding strict back to requirements.txt * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Duplicated * Basic implementation * Basic implementation * Basic implementation * Basic implementation * Common things moved to log helpers file * Decomposing logs reader classes for reusing * Setting colors for log levels * Manifest trimming * Changes added to CHANGELOG * Prettifications * Prettifications * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Logs function name change * Logs function name change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix the pydanitc import * Tests + command name fixes * Extending tests * Adding limit argument * Unmerging CI fix * Unmerging CI fix * Adding fields for errors * Adding log level fixed field width * Adding absent typing + exeptions raising * Adding socket error logging * Addressing comments on cluster list function return value * Addressing comments on adding e2e tests * Adding version range for arrow package in reqs * New unit tests * arrow time parsing callback modified + unit tests * helpers updated * helpers updated * helpers updated * One more test * CMD test fix * CMD test fix * CMD test fix * CMD test fix * CMD test fix * LightningClient mocking * Flaky test removed Co-authored-by: hhsecond <sherin@grid.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-08-23 19:48:22 +00:00
# and it contains the error message expected
assert "Error while reading logs (Malformed date format)" in captured.records[0].getMessage()
[CLI] Adding opportunity to see basic cluster logs (#14334) * pinning starsessions * pinning starsessions * adding strict back to requirements.txt * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Duplicated * Basic implementation * Basic implementation * Basic implementation * Basic implementation * Common things moved to log helpers file * Decomposing logs reader classes for reusing * Setting colors for log levels * Manifest trimming * Changes added to CHANGELOG * Prettifications * Prettifications * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Logs function name change * Logs function name change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix the pydanitc import * Tests + command name fixes * Extending tests * Adding limit argument * Unmerging CI fix * Unmerging CI fix * Adding fields for errors * Adding log level fixed field width * Adding absent typing + exeptions raising * Adding socket error logging * Addressing comments on cluster list function return value * Addressing comments on adding e2e tests * Adding version range for arrow package in reqs * New unit tests * arrow time parsing callback modified + unit tests * helpers updated * helpers updated * helpers updated * One more test * CMD test fix * CMD test fix * CMD test fix * CMD test fix * CMD test fix * LightningClient mocking * Flaky test removed Co-authored-by: hhsecond <sherin@grid.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-08-23 19:48:22 +00:00
def test_unknown_error(self):
websocket = mock.Mock()
with self.assertLogs("lightning.app.utilities.log_helpers") as captured:
[CLI] Adding opportunity to see basic cluster logs (#14334) * pinning starsessions * pinning starsessions * adding strict back to requirements.txt * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Duplicated * Basic implementation * Basic implementation * Basic implementation * Basic implementation * Common things moved to log helpers file * Decomposing logs reader classes for reusing * Setting colors for log levels * Manifest trimming * Changes added to CHANGELOG * Prettifications * Prettifications * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Logs function name change * Logs function name change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix the pydanitc import * Tests + command name fixes * Extending tests * Adding limit argument * Unmerging CI fix * Unmerging CI fix * Adding fields for errors * Adding log level fixed field width * Adding absent typing + exeptions raising * Adding socket error logging * Addressing comments on cluster list function return value * Addressing comments on adding e2e tests * Adding version range for arrow package in reqs * New unit tests * arrow time parsing callback modified + unit tests * helpers updated * helpers updated * helpers updated * One more test * CMD test fix * CMD test fix * CMD test fix * CMD test fix * CMD test fix * LightningClient mocking * Flaky test removed Co-authored-by: hhsecond <sherin@grid.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-08-23 19:48:22 +00:00
_error_callback(websocket, IOError())
# check that there is only one log message
assert len(captured.records) == 1
[CLI] Adding opportunity to see basic cluster logs (#14334) * pinning starsessions * pinning starsessions * adding strict back to requirements.txt * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Duplicated * Basic implementation * Basic implementation * Basic implementation * Basic implementation * Common things moved to log helpers file * Decomposing logs reader classes for reusing * Setting colors for log levels * Manifest trimming * Changes added to CHANGELOG * Prettifications * Prettifications * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Logs function name change * Logs function name change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * attempt to fix the pydanitc import * Tests + command name fixes * Extending tests * Adding limit argument * Unmerging CI fix * Unmerging CI fix * Adding fields for errors * Adding log level fixed field width * Adding absent typing + exeptions raising * Adding socket error logging * Addressing comments on cluster list function return value * Addressing comments on adding e2e tests * Adding version range for arrow package in reqs * New unit tests * arrow time parsing callback modified + unit tests * helpers updated * helpers updated * helpers updated * One more test * CMD test fix * CMD test fix * CMD test fix * CMD test fix * CMD test fix * LightningClient mocking * Flaky test removed Co-authored-by: hhsecond <sherin@grid.ai> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
2022-08-23 19:48:22 +00:00
# and it contains the error message expected
assert "Error while reading logs (Unknown)" in captured.records[0].getMessage()