From 699ecd26f936e91f935fac7478753ddab015b2f9 Mon Sep 17 00:00:00 2001 From: bloodearnest Date: Wed, 8 Nov 2023 11:03:07 +0000 Subject: [PATCH] improve excluded outputs log formatting --- jobrunner/executors/local.py | 7 ++++--- tests/test_local_executor.py | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/jobrunner/executors/local.py b/jobrunner/executors/local.py index a15063ec..71158ec5 100644 --- a/jobrunner/executors/local.py +++ b/jobrunner/executors/local.py @@ -662,9 +662,10 @@ def write_log_file(job_definition, job_metadata, filename, excluded): f.write("\noutputs:\n") f.write(tabulate(outputs, separator=" - ", indent=2, empty="(no outputs)")) if excluded: - f.write("\nexcluded files:\n") - for excluded_file, msg in excluded.items(): - f.write(f"{excluded_file}: {msg}") + f.write("\n") + f.write("\nInvalid moderately_sensitive outputs:\n") + f.write(tabulate(excluded.items(), separator=" - ", indent=2)) + f.write("\n") # Keys of fields to log in manifest.json and log file diff --git a/tests/test_local_executor.py b/tests/test_local_executor.py index 07ce6b83..f1713c0e 100644 --- a/tests/test_local_executor.py +++ b/tests/test_local_executor.py @@ -506,8 +506,10 @@ def test_finalize_large_level4_outputs( assert "0.5Mb" in txt log_file = level4_dir / "metadata/action.log" log = log_file.read_text() - assert "excluded files:" in log - assert "output/output.txt: File size of 1.0Mb is larger that limit of 0.5Mb." in log + assert "Invalid moderately_sensitive outputs:" in log + assert ( + "output/output.txt - File size of 1.0Mb is larger that limit of 0.5Mb." in log + ) @pytest.mark.needs_docker @@ -544,8 +546,8 @@ def test_finalize_invalid_file_type(docker_cleanup, job_definition, tmp_work_dir log_file = level4_dir / "metadata/action.log" log = log_file.read_text() - assert "excluded files:" in log - assert "output/output.rds: File type of .rds is not valid level 4 file" in log + assert "Invalid moderately_sensitive outputs:" in log + assert "output/output.rds - File type of .rds is not valid level 4 file" in log @pytest.mark.needs_docker @@ -587,8 +589,8 @@ def test_finalize_patient_id_header(docker_cleanup, job_definition, tmp_work_dir log_file = level4_dir / "metadata/action.log" log = log_file.read_text() - assert "excluded files:" in log - assert "output/output.csv: File has patient_id column" in log + assert "Invalid moderately_sensitive outputs:" in log + assert "output/output.csv - File has patient_id column" in log @pytest.mark.needs_docker