ENH: Improve `rtconvert` log visibility (#814)

Closes #813
This commit is contained in:
Peter Hessey 2022-10-28 09:21:59 +01:00 коммит произвёл GitHub
Родитель 02e7d9a91d
Коммит f2e0a98429
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 5 добавлений и 2 удалений

Просмотреть файл

@ -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 <model_name>:<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)