-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataModule: common base class to reduce code duplication #1260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels kind of like premature optimization (is premature abstracting a thing?) as it only saves a net few lines (just repeated twice), and "DataModule" doesn't seem like the correct name. It is good because I can't think of a case why we would want to go back and make different plot
, on_after_batch_transfer
or prepare_data
methods for the Geo and NonGeo data modules.
torchgeo/datamodules/geo.py
Outdated
@@ -23,15 +23,76 @@ | |||
from .utils import MisconfigurationException | |||
|
|||
|
|||
class GeoDataModule(LightningDataModule): # type: ignore[misc] | |||
"""Base class for data modules containing geospatial information. | |||
class DataModule(LightningDataModule): # type: ignore[misc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call this a TorchgeoDataModule or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could, I don't think it matters too much. The user should never use this class.
For context, the reason I made this change was because I wanted to improve the datamodule error messages. The current error message just says:
but the actual error could be any of:
Since this is a bit of code and requires access to self, I figured it would make sense to add this check to a base class. When I started working on a base class, that's when I realized how much duplicated code there was. So I figured it would be easiest to add the base class in one PR and improve error messages in a second PR. |
75298e2
to
a2c01a4
Compare
Totally fine! I just think the name "DataModule" might be confusing, maybe "BaseDataModule"? Else, I'm cool with it. |
A lot of the code in our base classes was shared, so I aggregated it.
Originally I was just planning on adding better error messages, but figured I would do this first.