-
Notifications
You must be signed in to change notification settings - Fork 84
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
Replace pkg_resources with importlib_resources #497
Conversation
These doc fixes are so helpful, thank you for including them! |
Woops, didn't notice workflows waiting for approval. 🐌 🚀 |
@chuckwondo we're just about to start a hack day, hope you'll be joining us again :) |
Just linking this to the other PR that this supersedes: #452, which I think should be closed after this one is merged. |
I tried putting |
@mfisher87, I made a change that should fix the broken python 3.8 build. It also happens to simplify things a bit. |
@danielfromearth, thanks for making note of this. It totally slipped my mind that I had previously commented on your issue there! This should close the loop on that. |
And thank you @danielfromearth for your work on this problem! |
Ugh! Updated |
Unfortunately, the environment-* YAMLs are conda environments and dependencies, while the deps in pyproject.toml are Poetry ones that get pulled from PyPI. There's no real way to avoid the duplication due to different package repositories and managers. And really, even if we went to just poetry environments, there's no way to specify "build an environment from the minimum dependencies" in Poetry, but we could with It's good to have conda env test coverage as well though as many of our users will be using conda. |
pyproject.toml
Outdated
@@ -44,6 +44,7 @@ multimethod = ">=1.8" | |||
python-dateutil = ">=2.8.2" | |||
kerchunk = { version = ">=0.1.2", optional = true } | |||
dask = { version = ">=2022.1.0", optional = true } | |||
importlib-resources = "^6.3.2" |
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.
Do we need to pin down to the patch version here?
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.
Not necessarily, but I simply used poetry add importlib-resources
to add it. There are other deps pinned similarly, but there is certainly no consistency.
This seems to point to a gap in the contributing guide regarding adding dependencies; not only how to add them, but also where to add them (other than pyproject.toml
).
I'm happy to add a note in the contributing guide, if you can provide guidance.
Also, happy to adjust the version pin here accordingly, if there's a preference.
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.
Also, a brief explanation of the why (in addition to the how and where) might be good to add to the contributing guide.
Again, happy to add all such details to the contributing guide as part of this PR, if someone can provide a few sentences.
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.
There's been a bit of lively discussion around dependencies in #468, but generally, a restrictive top-pin (down to the patch version) like this will force this package to break quickly for users. So we should remove the upper bound if we don't need it.
importlib-resources = "^6.3.2" | |
importlib-resources = ">=6.3.2" |
Similarly, is there a reason for this version being the lower bound?
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 seems to point to a gap in the contributing guide regarding adding dependencies; not only how to add them, but also where to add them (other than pyproject.toml).
Yes, agreed, we should add that. Especially since poetry add
adds upper bounds to dependencies with ^
, which is bad for libraries (and will not change python-poetry/poetry#3427)
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.
Those steps sound right to me. For (1) I'd be inclined to have the users just manually add it to the
pyproject.toml
instead of having to tell them to effectively manually do it again in (2), but (1) does update the lockfile too.For 2 we could tell them to use poetry-relax but that should probably be done in isolation with its own PR later.
Cool. Can you provide the "why" in the 2 spots I mentioned? Just a sentence or 2 in each spot to provide context for contributors.
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.
What's "a few versions behind the latest"? If you're referring to importlib-resources, that version is the latest as of earlier today.
Bah, I thought I looked earlier and latest was 7.0.2; no idea what I looked at 😫
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.
@chuckwondo this is getting large -- perhaps we should move the contributing guide discussion to its own issue and subsequent PR?
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.
As for the version, since we're still a poetry project, let's just go with:
importlib-resources = ">=6.3.2"
for now since that's what it decided and the rest were likely added that way.
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.
As for the why:
On the line added to pyproject.toml by poetry, change ^ to >= (perhaps add a "why" bit here)
because upper bounds can easily result in unsolvable user environments for Python libraries like Earthaccess. For more information, see the poetry-relax README, especially the references.
Add the same dependency to ci/environment-mindeps.yaml. For a required dep, pin the exact version, but for a testing dep, leave unpinned (again, a "why" comment here might also prove helpful)
I don't actually know the reasoning here... looks like it's because we pip install with --no-deps
and only use the dependencies in the conda environment, so we need all dependencies reflected here.
https://github.com/nsidc/earthaccess/blob/main/.github/workflows/test-mindeps.yml
@mfisher87 @betolink got a sentence for this?
a5bae16
to
c72e18e
Compare
Fix "DeprecationWarning: pkg_resources is deprecated as an API." seen when running tests. In addition: - increase test coverage for `formatters.py` - replace deprecated `set-output` in `test.yml` workflow - remove redundant lines in `Makefile` - make minor grammatical and formatting fixes to `CONTRIBUTING.md` - remove old, redundant "Code of Conduct" section from `CONTRIBUTING.md` and insert link to `CODE_OF_CONDUCT.md` - fix bare links in `CODE_OF_CONDUCT.md`
c72e18e
to
741f5e7
Compare
@jhkennedy and @mfisher87, I believe I addressed the dependency pinning issue. I also added a small "Managing Dependencies" section to the contributing guide. Please let me know if I missed anything. |
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.
looks good to me. @mfisher87 did you want to tak another look?
@mfisher87, does this look good? |
@jhkennedy can you take a look at how/why one of the checks was cancelled and rerun? I see, "Canceling since a higher priority waiting request for 'refs/pull/497/merge' exists," but can't tell exactly what caused it. |
I'm confused by that as well. I believe it's related to the concurrency setting: But not sure why. I don't have time to dig in right now (it works in some PRs but not others), but I'll open an issue. For now, I think it's safe to ignore it as the test ran fine in your fork: |
Hey, so sorry all for missing your mentions! 👀 |
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.
LGTM! I have lost some context in my delay to respond to this issue and I apologize for that 😿
Can somebody merge this PR? |
@chuckwondo done! |
Thanks @jhkennedy . @chuckwondo do you want merge permissions? We don't have any expectations of time commitment for maintainers. |
@mfisher87, thanks for the offer for merge permissions. I don't yet feel comfortable being granted such permissions, but perhaps after a few more PRs and "hack days" I'll take you up on the offer. |
I'll be sure to ask again later, then! ;) |
Fix "DeprecationWarning: pkg_resources is deprecated as an API." seen when running tests.
In addition:
formatters.py
set-output
intest.yml
workflowMakefile
CONTRIBUTING.md
CONTRIBUTING.md
and insert link toCODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
📚 Documentation preview 📚: https://earthaccess--497.org.readthedocs.build/en/497/