Skip to content
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

Test minimum version of deps #574

Merged
merged 83 commits into from Jun 18, 2022
Merged

Test minimum version of deps #574

merged 83 commits into from Jun 18, 2022

Conversation

adamjstewart
Copy link
Collaborator

@adamjstewart adamjstewart commented Jun 12, 2022

This is the fourth PR in a series of attempts to improve the stability and robustness of TorchGeo's CI (#567, #557, #551).

With this PR, we now have a minimum supported version listed for all of our dependencies, and we actively test to ensure that this stays up-to-date with each commit.

In the past, I tried not to overly restrict our dependencies if I didn't know the oldest supported version. With this PR, I'm taking the policy of "the oldest supported version is the oldest we can test". For example, many of our dependencies are pinned to versions due to Python 3.7 support or because another dependency requires a newer version, even if an older version would work with our code.

Closes #32

@adamjstewart adamjstewart added the testing Continuous integration testing label Jun 12, 2022
@github-actions github-actions bot removed the testing Continuous integration testing label Jun 12, 2022
@adamjstewart adamjstewart added the testing Continuous integration testing label Jun 13, 2022
@github-actions github-actions bot removed the testing Continuous integration testing label Jun 13, 2022
@adamjstewart adamjstewart added this to the 0.3.0 milestone Jun 13, 2022
setup.cfg Show resolved Hide resolved
Comment on lines +34 to +35
# matplotlib 3.3+ required for (H, W, 1) image support in plt.imshow
matplotlib>=3.3,<4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of our datasets (idtrees?) are plotting (H, W, 1) images, can we just squash these so we can support older matplotlib?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep track of these types of questions somewhere? Or resolve them here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either. If I get bored I'll try to fix these and support older versions. If I get busy I'll just merge this as is and deal with it another day.

rasterio>=1.0.16,<2
# pytorch-lightning 1.5.1+ required for apply_to_collection bugfix
pytorch-lightning>=1.5.1,<2
# rasterio 1.0.20+ required for out_dtype parameter of DatasetReaderBase.read
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear if this is really needed, could just cast to different dtype after reading

@adamjstewart adamjstewart marked this pull request as ready for review June 13, 2022 04:21
calebrob6
calebrob6 previously approved these changes Jun 13, 2022
@calebrob6
Copy link
Member

Kk I'm happy with this regardless

@adamjstewart
Copy link
Collaborator Author

TODO: update environment.yml

@adamjstewart adamjstewart marked this pull request as draft June 13, 2022 17:37
@github-actions github-actions bot added the testing Continuous integration testing label Jun 13, 2022
@adamjstewart adamjstewart marked this pull request as ready for review June 13, 2022 17:55
@adamjstewart adamjstewart marked this pull request as draft June 13, 2022 23:08
@github-actions github-actions bot added the datasets Geospatial or benchmark datasets label Jun 15, 2022
- open3d>=0.11.2
- pip
- protobuf<4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to pin this here, it isn't used by CI so it won't cause us issues. If someone encounters an issue they can manually install an older protobuf.

Comment on lines -39 to -40
# Required to address protocolbuffers/protobuf#10051
protobuf<4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to pin this here, it isn't used by CI so it won't cause us issues. If someone encounters an issue they can manually install an older protobuf.

@@ -47,7 +47,6 @@ scipy==1.7.3;python_version=='3.7'
zipfile-deflate64==0.2.0

# docs
ipywidgets==7.7.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this once upon a time because I ran into issues locally, but the doc tests seem to pass without it and it isn't a direct dep, so I removed it

@@ -199,7 +199,7 @@ def _load_target(self, path: str) -> Tensor:
"scipy is not installed and is required to use this dataset"
)

array = wavfile.read(path)[1]
array = wavfile.read(path, mmap=True)[1]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this I was seeing an issue with older scipy/torch:

tests/datasets/test_advance.py::TestADVANCE::test_getitem
  /home/adam/torchgeo/torchgeo/datasets/advance.py:203: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  /pytorch/torch/csrc/utils/tensor_numpy.cpp:180.)
    tensor = torch.from_numpy(array)

It doesn't seem to be needed for newer scipy/torch, but as long as the tests pass I don't see any harm in always using this.

except AttributeError: # pragma: no cover
except AttributeError:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can finally properly test these lines!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finallllly!!!!!!

# https://github.com/rwightman/pytorch-image-models/pull/1256
"ignore:.*is deprecated and will be removed in Pillow 10:DeprecationWarning",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't specify a module, this will ignore the test for all files, including our own. By specifying a model, we can ignore things with more fine-grained precision. We should probably do this for all warnings raised by deps of deps.

pyproject.toml Outdated
"ignore:Named tensors and all their associated APIs are an experimental feature and subject to change.:UserWarning:torch.nn.functional",
# https://github.com/numpy/numpy/issues/14920
# https://github.com/numpy/numpy/issues/15748
"ignore:numpy.ufunc size changed, may indicate binary incompatibility:RuntimeWarning",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only occurs for the minimum version tests, but basically, at least one of our deps was built with a different version of numpy than we are using to run the tests. Doesn't seem to cause any harm other than the warning.

@adamjstewart adamjstewart marked this pull request as ready for review June 15, 2022 07:08
@adamjstewart
Copy link
Collaborator Author

@calebrob6 this should be ready to merge now assuming the tests pass!

@calebrob6
Copy link
Member

Sick, nice work!!

@calebrob6
Copy link
Member

Just to make sure I'm understanding at the high level:

  • requirements/requirements.txt is now managed by dependabot, who bumps our pinned versions every time some upstream package has a release. This way, if something breaks, then we know in the dependabot PR, instead of all of our other CI breaking all of the sudden.
  • requirements/requirements-min.txt is now managed by us. This is just nice to have? We update this whenever we add a new dependency (which we don't like doing), when we drop a dependency, or when we do something like drop support for a Python version.
  • We're now explicitely ignoring warnings that are generated by our dependencies (that we don't have control over), mainly to stop cluttering up the tests. We're responsible for checking to see if these have changed every once in a while, but its not a huge deal.

Is this correct?

@adamjstewart adamjstewart merged commit 8c5e4d2 into main Jun 18, 2022
@adamjstewart adamjstewart deleted the tests/min branch June 18, 2022 15:00
@adamjstewart adamjstewart mentioned this pull request Jul 11, 2022
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets testing Continuous integration testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Determine minimum supported dependency versions
2 participants