Move DataModules to torchgeo.datamodules #321
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a pretty disruptive change to our API, and a lot of work to move everything, so I'll do my best to justify this. I'm hoping that this is the last time we have to move these.
Originally, all of our DataModules were defined in
torchgeo.trainers
. However, we decided to move them totorchgeo.datasets
in #220 since the filenames had so much overlap with the dataset filenames (ideally there should be a one-to-one correspondence between Datasets and DataModules). This introduced a circular import issue (#276) because our samplers import GeoDataset/BoundingBox and our DataModules import our samplers. Although there are workarounds for this, circular import issues are generally a sign of a poor design. In this case, thetorchgeo.*
components were not standalone and distinct enough.This PR solves the issue by moving all DataModules to their own
torchgeo.datamodules
namespace. Now our components have the following import dependence:As you can see, no more circular import dependencies. Aside from avoiding circular imports, the other motivation of this PR is that it allows us to remove all imports in
torchgeo/__init__.py
. Some of those imports were hacks to avoid circular import issues. I'll remove these imports in a separate PR to keep this one focused.