DeltaRCM / pyDeltaRCM

Delta model with a reduced-complexity approach
https://deltarcm.org/pyDeltaRCM/
MIT License
18 stars 10 forks source link

Add a helpful error message when subclassing and having netcdf conflict issues #240

Open amoodie opened 2 years ago

amoodie commented 2 years ago

Creating a custom subclass and using the preprocessor is complicated. Mostly, because creating the netcdf file has to be delayed until the job is assigned to a different thread (connection to netcdf is not pickle-able).

So, when you get the error

 Existing NetCDF4 output file in target output location: /.../job_000/pyDeltaRCM_output.nc

which is raised from here but actually called during the run command for the parallel job, and delivered to the user here on error, it can be pretty confusing.

I was tripped up because I forgot to pass **kwargs input to the subclass model, on to __init__ for the DeltaModel.

Two ways to help this:

amoodie commented 2 years ago

on the try-except for run() on the ParallelJob, could add something like

if isinstance(e, FileExistsError):
    raise FileExistsError(
        'File already exists in trying to run parallel '
        'jobs. Did you mean to set `defer_output=True` '
        'in your job configuration? '
        f'Original error is: {e}')