From aeb79ad78cbe006116d537e4a99a4d19afdd97ba Mon Sep 17 00:00:00 2001 From: Avi Date: Sun, 26 Jul 2020 12:02:51 +0300 Subject: [PATCH 1/5] added timestamp to log lines by default --- distributed/distributed.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributed/distributed.yaml b/distributed/distributed.yaml index f815fadf830..2998119fd51 100644 --- a/distributed/distributed.yaml +++ b/distributed/distributed.yaml @@ -168,7 +168,7 @@ distributed: max-error-length: 10000 # Maximum size traceback after error to return log-length: 10000 # default length of logs to keep in memory - log-format: '%(name)s - %(levelname)s - %(message)s' + log-format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' pdb-on-err: False # enter debug mode on scheduling error rmm: pool-size: null From b265e80b7ffaf152d02f05c16510d503024caf4e Mon Sep 17 00:00:00 2001 From: Avi Date: Fri, 6 Nov 2020 11:38:57 +0200 Subject: [PATCH 2/5] fixed tests relying on log format --- distributed/cli/tests/test_dask_scheduler.py | 8 +++++--- distributed/tests/test_config.py | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/distributed/cli/tests/test_dask_scheduler.py b/distributed/cli/tests/test_dask_scheduler.py index 543d4300ff3..239673d2e4d 100644 --- a/distributed/cli/tests/test_dask_scheduler.py +++ b/distributed/cli/tests/test_dask_scheduler.py @@ -237,11 +237,13 @@ def test_dashboard_port_zero(loop): with popen(["dask-scheduler", "--dashboard-address", ":0"]) as proc: count = 0 while count < 1: - line = proc.stderr.readline() - if b"dashboard" in line.lower(): + line = proc.stderr.readline().decode('utf8') + if "dashboard" in line.lower(): sleep(0.01) count += 1 - assert b":0" not in line + # Remove timestamp from logging line which may contain ":0" + line = " - ".join(line.split(" - ")[1:]) + assert ":0" not in line PRELOAD_TEXT = """ diff --git a/distributed/tests/test_config.py b/distributed/tests/test_config.py index 74b57b1f011..a4efa3ca451 100644 --- a/distributed/tests/test_config.py +++ b/distributed/tests/test_config.py @@ -91,10 +91,12 @@ def test_logging_default(): foreign_log = foreign_log.getvalue().splitlines() # distributed log is configured at INFO level by default - assert distributed_log == [ + expected_log_suffix = [ "distributed - INFO - 2: info", "distributed.foo.bar - INFO - 3: info", ] + for result, expected_suffix in zip(distributed_log, expected_log_suffix): + assert result.endswith(expected_suffix) # foreign logs should be unaffected by distributed's logging # configuration. They get the default ERROR level from logging. @@ -139,10 +141,13 @@ def test_logging_simple_under_distributed(): distributed_log = distributed_log.getvalue().splitlines() - assert distributed_log == [ + expected_log_suffix = [ "distributed.foo - INFO - 1: info", "distributed.foo.bar - ERROR - 3: error", - ], (dask.config.config, distributed_log) + ] + + for result, expected_suffix in zip(distributed_log, expected_log_suffix): + assert result.endswith(expected_suffix), (dask.config.config, distributed_log) """ subprocess.check_call([sys.executable, "-c", code]) @@ -174,10 +179,13 @@ def test_logging_simple(): distributed_log = distributed_log.getvalue().splitlines() - assert distributed_log == [ + expected_log_suffix = [ "distributed.foo - INFO - 1: info", "distributed.foo.bar - ERROR - 3: error", - ], (dask.config.config, distributed_log) + ] + + for result, expected_suffix in zip(distributed_log, expected_log_suffix): + assert result.endswith(expected_suffix), (dask.config.config, distributed_log) """ subprocess.check_call([sys.executable, "-c", code]) From bdb460c5ef1d7fa3066206c4ae965e8c414b8663 Mon Sep 17 00:00:00 2001 From: Avi Date: Fri, 6 Nov 2020 13:40:16 +0200 Subject: [PATCH 3/5] flake8 fix --- distributed/cli/tests/test_dask_scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distributed/cli/tests/test_dask_scheduler.py b/distributed/cli/tests/test_dask_scheduler.py index 239673d2e4d..695c76c6d77 100644 --- a/distributed/cli/tests/test_dask_scheduler.py +++ b/distributed/cli/tests/test_dask_scheduler.py @@ -237,7 +237,7 @@ def test_dashboard_port_zero(loop): with popen(["dask-scheduler", "--dashboard-address", ":0"]) as proc: count = 0 while count < 1: - line = proc.stderr.readline().decode('utf8') + line = proc.stderr.readline().decode("utf8") if "dashboard" in line.lower(): sleep(0.01) count += 1 From c20fc612cbbf9e47e5fa401a6cc351e97c77ef4a Mon Sep 17 00:00:00 2001 From: Avi Date: Fri, 6 Nov 2020 13:55:20 +0200 Subject: [PATCH 4/5] add `asyncio` marker to suppress pytest warnings --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 764ac7ad02c..9aad96a2488 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,6 +42,7 @@ markers = slow: marks tests as slow (deselect with '-m "not slow"') avoid_travis: marks tests as flaky on TravisCI. ipython: mark a test as exercising IPython + asyncio: marks tests that test async functionality # filterwarnings = # error From b4d5789165d5982dd34c04fb64db9d6ebb0b9a8b Mon Sep 17 00:00:00 2001 From: Avi Date: Fri, 6 Nov 2020 14:07:31 +0200 Subject: [PATCH 5/5] flake8 stuff --- distributed/tests/test_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/distributed/tests/test_config.py b/distributed/tests/test_config.py index a4efa3ca451..8c5ed01d582 100644 --- a/distributed/tests/test_config.py +++ b/distributed/tests/test_config.py @@ -145,7 +145,7 @@ def test_logging_simple_under_distributed(): "distributed.foo - INFO - 1: info", "distributed.foo.bar - ERROR - 3: error", ] - + for result, expected_suffix in zip(distributed_log, expected_log_suffix): assert result.endswith(expected_suffix), (dask.config.config, distributed_log) """ @@ -183,7 +183,7 @@ def test_logging_simple(): "distributed.foo - INFO - 1: info", "distributed.foo.bar - ERROR - 3: error", ] - + for result, expected_suffix in zip(distributed_log, expected_log_suffix): assert result.endswith(expected_suffix), (dask.config.config, distributed_log) """