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
WIP: Use Pooch to download sample data #915
Conversation
The CircleCI build is complaining about netcdf4 but it passes locally. Any ideas? |
CircleCI is an expected fail right now - we're trying to get this in today/over the weekend. Working on it this afternoon. |
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.
Thanks for contributing! This is a great start, just a few things I'd like to see.
MANIFEST.in
Outdated
@@ -5,6 +5,7 @@ include LICENSE | |||
include CONTRIBUTING.md | |||
include versioneer.py | |||
include metpy/_version.py | |||
include metpy/registry.txt |
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.
How about something more descriptive--maybe static-data-manifest.txt
?
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.
Yeah, that would be better. @jrleeman should I fix this or are you gonna edit this branch?
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.
Editing now 😄
environment.yml
Outdated
@@ -35,3 +35,5 @@ dependencies: | |||
- cartopy | |||
- doc8 | |||
- recommonmark | |||
- pip: |
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.
Let's vendor in pooch temporarily while things settle just a bit and we work on things like conda packages. Without conda packages for pooch, we won't even be able to update MetPy's packages.
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.
Yeah, I thought about that. I think I'll get started on the conda-forge package and we make new releases later with fixes required by metpy.
metpy/cbook.py
Outdated
|
||
def get_test_data(fname, as_file_obj=True): | ||
"""Access a file from MetPy's collection of test data.""" | ||
path = POOCH.fetch(fname) |
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.
Would be good to have a way to use our local git checkout of files directly so we can more easily bootstrap adding new files.
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.
I thought of that while implementing this. The problem is that the directory is versioned. I got around it on the CIs by copying the data to the cache folder. That bypasses the download at least. A static link would be better locally to keep the folders in sync.
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.
I think the way to do this is check "are we in a git repo?" and if so, then we'll set the environment variable to point the cache to the staticdata directory.
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.
That wouldn't work because of the versioning. The env variable only points to the base level directory.
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.
Just got a workaround going - verifying now.
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.
So I think we're actually going to put some hooks in to look into the github directory, if it exists, first. We'll also do some checking to make sure those files do get into the registry.
.travis.yml
Outdated
@@ -108,8 +109,9 @@ install: | |||
- pip install ".[$EXTRA_INSTALLS]" --upgrade --upgrade-strategy=eager --no-index $PRE -f file://$PWD/$WHEELDIR $VERSIONS; | |||
|
|||
script: | |||
# Move the data to the cache location to avoid downloading it | |||
- cp -r $TRAVIS_BUILD_DIR/staticdata/* $TEST_DATA_DIR/master |
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.
Turns out Travis doesn't like indented comments. This will keep it from downloading the data every time.
Wouldn't it be better to link |
metpy/_vendor/pooch/__init__.py
Outdated
@@ -0,0 +1,48 @@ | |||
# pylint: disable=missing-docstring | |||
# Import functions/classes to make the API | |||
from . import version |
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.
F401 '.version' imported but unused
metpy/_vendor/pooch/__init__.py
Outdated
# pylint: disable=missing-docstring | ||
# Import functions/classes to make the API | ||
from . import version | ||
from .core import Pooch, create |
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.
F401 '.core.create' imported but unused
F401 '.core.Pooch' imported but unused
metpy/_vendor/pooch/__init__.py
Outdated
# Import functions/classes to make the API | ||
from . import version | ||
from .core import Pooch, create | ||
from .utils import os_cache, file_hash, make_registry |
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.
F401 '.utils.os_cache' imported but unused
F401 '.utils.file_hash' imported but unused
F401 '.utils.make_registry' imported but unused
metpy/_vendor/pooch/_version.py
Outdated
dirname = os.path.basename(root) | ||
if dirname.startswith(parentdir_prefix): | ||
return { | ||
"version": dirname[len(parentdir_prefix) :], |
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.
E203 whitespace before ':'
metpy/_vendor/pooch/_version.py
Outdated
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of | ||
# just "foo-1.0". If we see a "tag: " prefix, prefer those. | ||
TAG = "tag: " | ||
tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)]) |
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.
E203 whitespace before ':'
metpy/_vendor/pooch/_version.py
Outdated
for ref in sorted(tags): | ||
# sorting will prefer e.g. "2.0" over "2.0rc1" | ||
if ref.startswith(tag_prefix): | ||
r = ref[len(tag_prefix) :] |
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.
E203 whitespace before ':'
metpy/_vendor/pooch/_version.py
Outdated
tag_prefix, | ||
) | ||
return pieces | ||
pieces["closest-tag"] = full_tag[len(tag_prefix) :] |
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.
E203 whitespace before ':'
metpy/_vendor/pooch/tests/utils.py
Outdated
""" | ||
registry = { | ||
"tiny-data.txt": "baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d", | ||
"subdir/tiny-data.txt": "baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d", |
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.
E501 line too long (99 > 95 characters)
metpy/_vendor/__init__.py
Outdated
# Copyright (c) 2015 MetPy Developers. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
"""Vendor packages used in MetPy.""" |
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.
W292 no newline at end of file
@dopplershift - any ideas on why codecov isn't ignoring this? Once things look better, I'll cleanup and rebase. |
Looks like globs for codecov are not recursive. They give a solution in the linked docs. |
I started conda-forge/staged-recipes#6540 so once that is done we probably don't need the vendoring, right? |
We'll probably vendor for this version of MetPy to make sure all the dust settles and then go to a conda forge install in 0.10. |
👍 just in case you want to try it out, the feedstock is ready https://github.com/conda-forge/pooch-feedstock |
metpy/_vendor/pooch/_version.py
Outdated
@@ -0,0 +1,557 @@ | |||
# pylint: skip-file |
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.
Is it possible to nuke this file and version.py
?
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.
Probably. That's not used in the rest of the package. It is used in one of the tests (https://github.com/fatiando/pooch/blob/master/pooch/tests/test_integration.py#L13) but if you're not running those you could also nuke the entire tests
folder.
metpy/_vendor/pooch/utils.py
Outdated
'dev' | ||
|
||
""" | ||
parse = Version(version) |
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.
I think this would work as:
return fallback if '+' in version else version
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.
Yeah, using packaging
is probably overkill here.
What's the advantage of vendoring vs pinning the requirement to a given version? If the concern is pooch updating and breaking things, the pinning should solve that. Plus, nothing else relies on pooch so it wouldn't block anything else from updating (like numpy would). That's an honest question, BTW. I had to look up "vendor" on wikipedia :) |
You make an interesting point about pinning... |
Add it to `metpy/cbook.py` and include the dependency on setup.py. Create the registry file using `pooch.make_registry` and stored it in the `metpy` package.
Okay, just did what should be the final history cleanup here - per review and CI this is ready to rock 🍾 |
🎉 thanks! |
Add it to
metpy/cbook.py
and include the dependency on setup.py. Create the registry file usingpooch.make_registry
and stored it in themetpy
package.Some tests fail because they use a
glob
to get all the files in thenids
folder. Will try to replace that with a lookup of the Pooch registry.I'm also not sure how to get it installed on the CIs. I added it to the
setup.py
. Is that enough?Fixes fatiando/pooch#8