Extractor failure because file does not exist

Issue #993 resolved
David Platten created an issue

I have the following entry in the tasks list of my OpenREM 1.0.0 beta installation (I’ve manually reformatted it here to make it more readable:

UUID:       853512a7-0e66-482c-9804-ac063b1988c7
Task type:  import_rdsr
Info:       None
Error:      Traceback (most recent call last):
            File "e:\openrem-src\openrem\remapp\tools\background.py", line 148, in run_as_task func(*args, **kwargs)
            File "e:\openrem-src\openrem\remapp\extractors\rdsr.py", line 605, in rdsr dataset = pydicom.dcmread(rdsr_file)
            File "E:\venv311\Lib\site-packages\pydicom\filereader.py", line 993, in dcmread fp = open(fp, 'rb')
            FileNotFoundError: [Errno 2] No such file or directory: 'E:\\orthanc\\dicom\\39e3416e-d8a8dbee-ead64288-11840341-de16482f.dcm'
Started:    23 May 2023, 10 a.m.
State:      Failure

I would like to add a try accept around the dataset = pydicom.dcmread(rdsr_file) line in rdsr.py so that the FileNotFoundError is caught and logged, along the lines of:

try:
    dataset = pydicom.dcmread(rdsr_file)
except FileNotFoundError:
    logger.warning(
        "rdsr.py not attempting to extract from {0}, the file does not exist".format(
            rdsr_file
        )
    )
    record_task_error_exit(
        f"Not attempting to extract from {rdsr_file}, the file does not exist"
    )
    return 1

I also think we should do this for the other extractors.

Comments (8)

  1. David Platten reporter

    I can’t think of a way to do that. Have you seen the same error on your test system?

  2. David Platten reporter

    Added check that file exists in extractors and updated changes file. The ct_toshiba extractor already has try except around file reading. Refs issue #993

    → <<cset 53f3fad004e7>>

  3. David Platten reporter

    Merged in issue993extractorFailureFileDoesNotExist (pull request #590)

    Added check that file exists in extractors and updated changes file. The ct_toshiba extractor already has try except around file reading. Refs issue #993

    Approved-by: Ed McDonagh

    Fixes issue #993

    → <<cset 0371d8370f66>>

  4. David Platten reporter

    Merged in issue993extractorFailureFileDoesNotExist (pull request #590)

    Added check that file exists in extractors and updated changes file. The ct_toshiba extractor already has try except around file reading. Refs issue #993

    Approved-by: Ed McDonagh

    Fixes issue #993

    → <<cset 0371d8370f66>>

  5. Log in to comment