Skip to content

Commit

Permalink
Added tons of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Guenther committed Jun 22, 2015
1 parent 9928bdc commit a0d2125
Show file tree
Hide file tree
Showing 17 changed files with 831 additions and 36 deletions.
3 changes: 3 additions & 0 deletions bob/bio/base/algorithm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
from .LDA import LDA
from .PLDA import PLDA
from .BIC import BIC

# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
9 changes: 3 additions & 6 deletions bob/bio/base/extractor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Laurent El Shafey <Laurent.El-Shafey@idiap.ch>

"""Basic features for biometric recognition"""

from .Extractor import Extractor
from .Linearize import Linearize

# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
3 changes: 3 additions & 0 deletions bob/bio/base/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ def queue(self, params):
def is_local(self):
"""Returns whether this grid setup should use the local submission or the SGE grid."""
return self.grid_type == 'local'

# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
3 changes: 3 additions & 0 deletions bob/bio/base/preprocessor/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from .Preprocessor import Preprocessor

# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
2 changes: 1 addition & 1 deletion bob/bio/base/script/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def resources():

def databases():
import argparse
database_replacement = "/idiap/home/%s/.bob_bio_databases.txt" % os.environ["USER"] if os.path.isdir("/idiap") else "/home/%s/.bob_bio_databases.txt" % os.environ["USER"]
database_replacement = "%s/.bob_bio_databases.txt" % os.environ["HOME"]

parser = argparse.ArgumentParser(description="Prints a list of directories for registered databases", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-D', '--database-directories-file', metavar = 'FILE', default = database_replacement, help = 'The file, where database directories are stored (to avoid changing the database configurations)')
Expand Down
3 changes: 3 additions & 0 deletions bob/bio/base/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
from .scoring import *
from .command_line import *
from .grid import *

# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
26 changes: 13 additions & 13 deletions bob/bio/base/tools/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import bob.core
logger = bob.core.log.setup("bob.bio.base")

from ..utils import load_resource, resource_keys
from .. import utils
from . import FileSelector

"""Execute biometric recognition algorithms on a certain biometric database.
Expand All @@ -23,13 +23,13 @@ def command_line_parser(description=__doc__, exclude_resources_from=[]):
############## options that are required to be specified #######################
config_group = parser.add_argument_group('\nParameters defining the experiment. Most of these parameters can be a registered resource, a configuration file, or even a string that defines a newly created object')
config_group.add_argument('-d', '--database', metavar = 'x', nargs = '+', required = True,
help = 'Database and the protocol; registered databases are: %s' % resource_keys('database', exclude_resources_from))
help = 'Database and the protocol; registered databases are: %s' % utils.resource_keys('database', exclude_resources_from))
config_group.add_argument('-p', '--preprocessor', metavar = 'x', nargs = '+', required = True,
help = 'Data preprocessing; registered preprocessors are: %s' % resource_keys('preprocessor', exclude_resources_from))
help = 'Data preprocessing; registered preprocessors are: %s' % utils.resource_keys('preprocessor', exclude_resources_from))
config_group.add_argument('-e', '--extractor', metavar = 'x', nargs = '+', required = True,
help = 'Feature extraction; registered feature extractors are: %s' % resource_keys('extractor', exclude_resources_from))
help = 'Feature extraction; registered feature extractors are: %s' % utils.resource_keys('extractor', exclude_resources_from))
config_group.add_argument('-a', '--algorithm', metavar = 'x', nargs = '+', required = True,
help = 'Biometric recognition; registered algorithms are: %s' % resource_keys('algorithm', exclude_resources_from))
help = 'Biometric recognition; registered algorithms are: %s' % utils.resource_keys('algorithm', exclude_resources_from))
config_group.add_argument('-g', '--grid', metavar = 'x', nargs = '+',
help = 'Configuration for the grid setup; if not specified, the commands are executed sequentially on the local machine.')
config_group.add_argument('--imports', metavar = 'LIB', nargs = '+', default = ['bob.bio.base'],
Expand All @@ -48,7 +48,7 @@ def command_line_parser(description=__doc__, exclude_resources_from=[]):
is_idiap = os.path.isdir("/idiap")
temp = "/idiap/temp/%s/database-name/sub-directory" % os.environ["USER"] if is_idiap else "temp"
results = "/idiap/user/%s/database-name/sub-directory" % os.environ["USER"] if is_idiap else "results"
database_replacement = "/idiap/home/%s/.bob_bio_databases.txt" % os.environ["USER"] if is_idiap else "/home/%s/.bob_bio_databases.txt" % os.environ["USER"]
database_replacement = "%s/.bob_bio_databases.txt" % os.environ["HOME"]

dir_group = parser.add_argument_group('\nDirectories that can be changed according to your requirements')
dir_group.add_argument('-T', '--temp-directory', metavar = 'DIR',
Expand Down Expand Up @@ -150,12 +150,12 @@ def initialize(parsers, command_line_parameters = None, skips = []):
args.timer = ('real', 'system', 'user')

# load configuration resources
args.database = load_resource(' '.join(args.database), 'database', imports = args.imports)
args.preprocessor = load_resource(' '.join(args.preprocessor), 'preprocessor', imports = args.imports)
args.extractor = load_resource(' '.join(args.extractor), 'extractor', imports = args.imports)
args.algorithm = load_resource(' '.join(args.algorithm), 'algorithm', imports = args.imports)
args.database = utils.load_resource(' '.join(args.database), 'database', imports = args.imports)
args.preprocessor = utils.load_resource(' '.join(args.preprocessor), 'preprocessor', imports = args.imports)
args.extractor = utils.load_resource(' '.join(args.extractor), 'extractor', imports = args.imports)
args.algorithm = utils.load_resource(' '.join(args.algorithm), 'algorithm', imports = args.imports)
if args.grid is not None:
args.grid = load_resource(' '.join(args.grid), 'grid', imports = args.imports)
args.grid = utils.load_resource(' '.join(args.grid), 'grid', imports = args.imports)

# set base directories
is_idiap = os.path.isdir("/idiap")
Expand Down Expand Up @@ -237,8 +237,8 @@ def write_info(args, command_line_parameters, executable):
f.write(command_line([executable] + command_line_parameters) + "\n\n")
f.write("Configuration:\n")
f.write("Database:\n%s\n\n" % args.database)
f.write("Preprocessing:\n%s\n\n" % args.preprocessor)
f.write("Feature Extraction:\n%s\n\n" % args.extractor)
f.write("Preprocessor:\n%s\n\n" % args.preprocessor)
f.write("Extractor:\n%s\n\n" % args.extractor)
f.write("Algorithm:\n%s\n\n" % args.algorithm)
except IOError:
logger.error("Could not write the experimental setup into file '%s'", args.info_file)
4 changes: 2 additions & 2 deletions bob/bio/base/tools/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import os
import math
from ..grid import Grid
from .. import grid
from .command_line import command_line

import bob.core
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(self, args, command_line_parameters, executable = 'verify.py', firs
self.executable = executable

if args.grid is not None:
assert isinstance(args.grid, Grid)
assert isinstance(args.grid, grid.Grid)

# find, where jman is installed
jmans = bob.extension.find_executable('jman', prefixes = ['bin'])
Expand Down
3 changes: 1 addition & 2 deletions bob/bio/base/utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def list_resources(keyword, strip=['dummy']):
entry_points = _get_entry_points(keyword, strip)
last_dist = None
retval = ""
length = max(len(entry_point.name) for entry_point in entry_points)
length = max(len(entry_point.name) for entry_point in entry_points) if entry_points else 1

for entry_point in sorted(entry_points):
if last_dist != str(entry_point.dist):
Expand All @@ -198,7 +198,6 @@ def database_directories(strip=['dummy'], replacements = None):
db = load_resource(entry_point.name, 'database')
db.replace_directories(replacements)
dirs[entry_point.name] = [db.original_directory]
# import ipdb; ipdb.set_trace()
if db.annotation_directory is not None:
dirs[entry_point.name].append(db.annotation_directory)
except (AttributeError, ValueError):
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
#exclude_patterns = ['**/links.rst']
exclude_patterns = ['links.rst']

# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
Expand Down
Loading

0 comments on commit a0d2125

Please sign in to comment.