From f2e0a984293ceffdce99f3ee1937a8327e6af421 Mon Sep 17 00:00:00 2001 From: Peter Hessey <45258028+peterhessey@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:21:59 +0100 Subject: [PATCH] ENH: Improve `rtconvert` log visibility (#814) Closes #813 --- score.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/score.py b/score.py index d4f6d6dd..fdc1876d 100644 --- a/score.py +++ b/score.py @@ -213,6 +213,7 @@ def convert_nifti_to_zipped_dicom_rt(nifti_file: Path, reference_series: Path, s :param config: Model config. :param dicom_rt_zip_file_name: Target DICOM-RT zip file name, ending in .dcm.zip. :param model_id: The AzureML model ID : + :raises: RunTimeError if rtconvert fails. :return: Path to DICOM-RT file. """ dicom_rt_file_path = scratch_folder / Path(dicom_rt_zip_file_name).with_suffix("") @@ -229,8 +230,10 @@ def convert_nifti_to_zipped_dicom_rt(nifti_file: Path, reference_series: Path, s modelId=model_id ) # Log stdout, stderr from DICOM-RT conversion. - logging.debug("stdout: %s", stdout) - logging.debug("stderr: %s", stderr) + logging.info("DICOM-RT conversion stdout: %s", stdout) + if stderr != "": + logging.error("Errors detected during DICOM conversion: %s", stderr) + raise RuntimeError("Converting model output to DICOM failed. See stack trace for more details.") dicom_rt_zip_file_path = scratch_folder / dicom_rt_zip_file_name with zipfile.ZipFile(dicom_rt_zip_file_path, 'w') as dicom_rt_zip: dicom_rt_zip.write(dicom_rt_file_path, dicom_rt_file_path.name)