Skip to content

Commit

Permalink
improve excluded outputs log formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodearnest committed Nov 10, 2023
1 parent 43df8f3 commit 699ecd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions jobrunner/executors/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions tests/test_local_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 699ecd2

Please sign in to comment.