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

Functional IO package #694

Merged
merged 11 commits into from May 26, 2016

Conversation

Projects
None yet
2 participants
@patricksnape
Contributor

patricksnape commented May 15, 2016

Now the IO package is much more functional and importers and exporters are just expected to be defined as functions/callables that take either a path (input) or a file handle (output) and do the appropriate job. This makes it much easier for users to leverage the menpo smart globbing etc but actually import whatever they want.

TODO

  • mio.register_*_importer('.jpg', custom_jpg_importer)

patricksnape added some commits May 15, 2016

Change to functional IO for importing/input
Make it simpler to create an importer by removing inheritance
from the importer classes. Also, make some of the menpo methods
more generic so they can be used by menpo3d.

Finally, improve behaviour for importing file types with compound
extensions such as .pkl.gz -> Now try all subsequences of
extensions rather than just .pkl.gz and .pkl.
Update exporting to be more functional
Rename functions to function style names and use some of the new
logic or looking up compound file types.

Fix the tests appropriately.

patricksnape added some commits May 19, 2016

Add new partial_doc method
Creates a partial and copies the __doc__ and optionally allows setting a
name.
Add the register_ methods to input io
You can now register custom image, video, landmark and pickle importers.
Change argument for python 2 mangling
dunderscore arguments are mangled in Python2 - so we shouldn't
use them.
@patricksnape

This comment has been minimized.

Contributor

patricksnape commented May 25, 2016

@jabooth Please review me

@patricksnape patricksnape changed the title from WIP: Functional IO package to Functional IO package May 26, 2016

from menpo.visualize import print_progress
from ..utils import _norm_path, _possible_extensions_from_filepath, \

This comment has been minimized.

@jabooth

jabooth May 26, 2016

Member

can we do

from foo import (lots, of,
                 items)

not a fan of \ + newline

r"""
Menpo's default image landmark resolver. Returns all landmarks found to have
Register a new importer for the given extension. This makes it much
simpler to add custom importers to the IO package.

This comment has been minimized.

@jabooth

jabooth May 26, 2016

Member

This docstring might read weird in a year (future menpo users won't know it was ever harder ;)

I'd drop the second sentence, and add an Example section if poss?

reader = imageio.get_reader(str(filepath), format='ffmpeg', mode='I')
def imageio_to_menpo(imio_reader, index):

This comment has been minimized.

@jabooth

jabooth May 26, 2016

Member

@patricksnape as discussed in person, either pull out of enclosing body (so it isn't a closure) or just used the closed over reader and don't take a parameter for clarity either way. Can be done after @JeanKossaifi adds his video reader though.

@jabooth

This comment has been minimized.

Member

jabooth commented May 26, 2016

@patricksnape really minor comments, but other than those looks really good. +1.

patricksnape added some commits May 26, 2016

@patricksnape

This comment has been minimized.

Contributor

patricksnape commented May 26, 2016

Go home Appveyor you're drunk. Merging.

@patricksnape patricksnape merged commit 4d8116e into menpo:master May 26, 2016

3 of 4 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
OS X MenpoBot Jenkins build passed
Details
clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@patricksnape patricksnape deleted the patricksnape:functional_io branch May 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment