You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should add a torchgeo.datasets.utils.DatasetNotFoundError class for consistent error messages when datasets aren't found.
Rationale
There is currently very little consistency between the errors reported by different datasets. Some raise RuntimeError, others raise FileNotFoundError. There are dozens of different messages raised by each dataset with little commonality between the text. Some mention using download=True, others mention changing the root directory. Some print the root directory, others leave users guessing.
Implementation
We should subclass FileNotFoundError and except the dataset instance as input. With this, we can check for download and checksum attributes to determine the appropriate message. Some possible formats include:
# Has a `self.download` attributef"Dataset not found in `root={self.root}` and `download=False`, either specify a different `root` directory or use `download=True` to automatically download the dataset."# Doesn't have a `self.download` attributef"Dataset not found in `root={self.root}`, either specify a different `root` directory or manually download the dataset."
This will also require consistent documentation in docstrings. Maybe something like:
# Has a ``self.download`` attribute
Raises:
FileNotFoundError: if ``download=False`` but dataset is not found
or checksums don't match
# Doesn't have a ``self.download`` attribute
Raises:
FileNotFoundError: if dataset is not found
Of course, we'll also need to update the tests as well.
Alternatives
We could simply update everything to have common text, but things would rapidly become out of sync without a centralized class to standardize the error message. This also avoids code duplication.
Additional information
No response
The text was updated successfully, but these errors were encountered:
Summary
We should add a
torchgeo.datasets.utils.DatasetNotFoundError
class for consistent error messages when datasets aren't found.Rationale
There is currently very little consistency between the errors reported by different datasets. Some raise
RuntimeError
, others raiseFileNotFoundError
. There are dozens of different messages raised by each dataset with little commonality between the text. Some mention usingdownload=True
, others mention changing the root directory. Some print the root directory, others leave users guessing.Implementation
We should subclass
FileNotFoundError
and except the dataset instance as input. With this, we can check fordownload
andchecksum
attributes to determine the appropriate message. Some possible formats include:This will also require consistent documentation in docstrings. Maybe something like:
Of course, we'll also need to update the tests as well.
Alternatives
We could simply update everything to have common text, but things would rapidly become out of sync without a centralized class to standardize the error message. This also avoids code duplication.
Additional information
No response
The text was updated successfully, but these errors were encountered: