Added example annotation files in a crowsetta.data package in #90 but because of the way importlib.resources works, when a user calls crowsetta.data.get('format-name') it returns a context manager -- this is required since packages may be installed as a compressed file, e.g. a zip, and so there's no real path on the file system to a file that's still compressed inside that .zip.
The downside of this is that it can give the impression that a user always has to use a context manager.
It also makes all of the examples in the docstrings very verbose.
Here's a different approach:
when crowsetta.data.get is called, it checks if there is an existing place on filesystem with all of the example files unpacked there
it uses a default argument but if a user really wants to they can change this argument; the trade-off is they will need to pass in an alternate location every time they call
if files do not exist, and user consents, then they will be unpacked there using importlib.resources
then / otherwise the requested sample annotation file is returned
I think I can copy some code from pooch to do this -- they have a notion of "default download location"
this would additionally require making it so examples assume that data is already unpacked locally as described ... some sort of setup code for doctest?
Added example annotation files in a
crowsetta.data
package in #90 but because of the wayimportlib.resources
works, when a user callscrowsetta.data.get('format-name')
it returns a context manager -- this is required since packages may be installed as a compressed file, e.g. a zip, and so there's no real path on the file system to a file that's still compressed inside that .zip.The downside of this is that it can give the impression that a user always has to use a context manager.
It also makes all of the examples in the docstrings very verbose.
Here's a different approach:
crowsetta.data.get
is called, it checks if there is an existing place on filesystem with all of the example files unpacked thereI think I can copy some code from
pooch
to do this -- they have a notion of "default download location"