Commit 71165308 authored by Pedro TOME's avatar Pedro TOME
Browse files

updated to Bob v2.0.0

parent 45c22cf8
*~
*.swp
*.pyc
*.so
*.dylib
bin
eggs
parts
.installed.cfg
.mr.developer.cfg
*.egg-info
src
develop-eggs
built-docs
dist
sphinx
dist
.nfs*
.gdb_history
build
*.egg
src/
db.sql3
================
UTFVP Database
================
.. vim: set fileencoding=utf-8 :
.. Pedro Tome <pedro.tome@idiap.ch>
.. Tus Jan 13 19:35:05 CEST 2015
.. image:: http://img.shields.io/badge/docs-stable-yellow.png
:target: http://pythonhosted.org/bob.db.utfvp/index.html
.. image:: http://img.shields.io/badge/docs-latest-orange.png
:target: https://www.idiap.ch/software/bob/docs/latest/bioidiap/bob.db.utfvp/master/index.html
.. image:: https://travis-ci.org/bioidiap/bob.db.utfvp.svg?branch=master
:target: https://travis-ci.org/bioidiap/bob.db.utfvp
.. image:: https://coveralls.io/repos/bioidiap/bob.db.utfvp/badge.png
:target: https://coveralls.io/r/bioidiap/bob.db.utfvp
.. image:: https://img.shields.io/badge/github-master-0000c0.png
:target: https://github.com/bioidiap/bob.db.utfvp/tree/master
.. image:: http://img.shields.io/pypi/v/bob.db.utfvp.png
:target: https://pypi.python.org/pypi/bob.db.utfvp
.. image:: http://img.shields.io/pypi/dm/bob.db.utfvp.png
:target: https://pypi.python.org/pypi/bob.db.utfvp
.. image:: https://img.shields.io/badge/raw-data--files-a000a0.png
:target: http://www.sas.ewi.utwente.nl
This package contains the access API and descriptions for the `UTFVP
Database`_. The actual raw data for the database should be downloaded from the original URL. This API is only
compatible with the images from the UTFVP English database. This package only
contains the `Bob <http://www.idiap.ch/software/bob/>`_ accessor methods to use
the DB directly from python, with our certified protocols.
You would normally not install this package unless you are maintaining it. What
you would do instead is to tie it in at the package you need to **use** it.
There are a few ways to achieve this:
==============================================================================
UTFVP Fingervein Database Interface for Bob
==============================================================================
1. You can add this package as a requirement at the ``setup.py`` for your own
`satellite package
<https://github.com/idiap/bob/wiki/Virtual-Work-Environments-with-Buildout>`_
or to your Buildout ``.cfg`` file, if you prefer it that way. With this
method, this package gets automatically downloaded and installed on your
working environment, or
This package contains an interface for the evaluation protocol of the `UTFVP Fingervein Database <http://www.sas.ewi.utwente.nl>`_.
This package does not contain the original `UTFVP Fingervein <http://www.sas.ewi.utwente.nl>`_ data files, which need to be obtained through the links above.
2. You can manually download and install this package using commands like
``easy_install`` or ``pip``.
The package is available in two different distribution formats:
Installation
------------
To install this package -- alone or together with other `Packages of Bob <https://github.com/idiap/bob/wiki/Packages>`_ -- please read the `Installation Instructions <https://github.com/idiap/bob/wiki/Installation>`_.
For Bob_ to be able to work properly, some dependent packages are required to be installed.
Please make sure that you have read the `Dependencies <https://github.com/idiap/bob/wiki/Dependencies>`_ for your operating system.
1. You can download it from `PyPI <http://pypi.python.org/pypi>`_, or
Documentation
-------------
For further documentation on this package, please read the `Stable Version <http://pythonhosted.org/bob.db.utfvp/index.html>`_ or the `Latest Version <https://www.idiap.ch/software/bob/docs/latest/bioidiap/bob.db.utfvp/master/index.html>`_ of the documentation.
For a list of tutorials on this or the other packages ob Bob_, or information on submitting issues, asking questions and starting discussions, please visit its website.
2. You can download it in its source form from `its git repository
<https://github.com/bioidiap/xbob.db.utfvp>`_. When you download the
version at the git repository, you will need to run a command to recreate
the backend SQLite file required for its operation. This means that the
database raw files must be installed somewhere in this case. With option
``a`` you can run in `dummy` mode and only download the raw data files for
the database once you are happy with your setup.
.. _bob: https://www.idiap.ch/software/bob
You can mix and match points 1/2 and a/b above based on your requirements. Here
are some examples:
Modify your setup.py and download from PyPI
===========================================
That is the easiest. Edit your ``setup.py`` in your satellite package and add
the following entry in the ``install_requires`` section (note: ``...`` means
`whatever extra stuff you may have in-between`, don't put that on your
script)::
install_requires=[
...
"bob==1.2.2", # base signal proc./machine learning library
"xbob.db.utfvp",
],
Proceed normally with your ``boostrap/buildout`` steps and you should be all
set. That means you can now import the ``xbob.db.utfvp`` namespace into your scripts.
Modify your buildout.cfg and download from git
==============================================
You will need to add a dependence to `mr.developer
<http://pypi.python.org/pypi/mr.developer/>`_ to be able to install from our
git repositories. Your ``buildout.cfg`` file should contain the following
lines::
[buildout]
...
extensions = mr.developer
auto-checkout = *
eggs = bob
...
xbob.db.utfvp
[sources]
xbob.db.utfvp = git https://github.com/bioidiap/xbob.db.utfvp.git
...
......@@ -23,4 +23,21 @@
from .query import Database
from .models import Client, File, Protocol, Model
__all__ = dir()
def get_config():
"""Returns a string containing the configuration information.
"""
import pkg_resources
packages = pkg_resources.require(__name__)
this = packages[0]
deps = packages[1:]
retval = "%s: %s (%s)\n" % (this.key, this.version, this.location)
retval += " - python dependencies:\n"
for d in deps: retval += " - %s: %s (%s)\n" % (d.key, d.version, d.location)
return retval.strip()
# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
......@@ -476,7 +476,7 @@ def add_protocols(session, file_list, verbose):
def create_tables(args):
"""Creates all necessary tables (only to be used at the first time)"""
from bob.db.utils import create_engine_try_nolock
from bob.db.base.utils import create_engine_try_nolock
engine = create_engine_try_nolock(args.type, args.files[0], echo=(args.verbose > 2))
Base.metadata.create_all(engine)
......@@ -487,7 +487,7 @@ def create_tables(args):
def create(args):
"""Creates or re-creates this database"""
from bob.db.utils import session_try_nolock
from bob.db.base.utils import session_try_nolock
dbfile = args.files[0]
......
......@@ -22,7 +22,7 @@
import os
import sys
from bob.db.driver import Interface as BaseInterface
from bob.db.base.driver import Interface as BaseInterface
def dumplist(args):
......@@ -45,7 +45,7 @@ def dumplist(args):
output = sys.stdout
if args.selftest:
from bob.db.utils import null
from bob.db.base.utils import null
output = null()
for f in r:
......@@ -74,7 +74,7 @@ def checkfiles(args):
# report
output = sys.stdout
if args.selftest:
from bob.db.utils import null
from bob.db.base.utils import null
output = null()
if bad:
......@@ -94,7 +94,7 @@ def reverse(args):
output = sys.stdout
if args.selftest:
from bob.db.utils import null
from bob.db.base.utils import null
output = null()
r = db.reverse(args.path)
......@@ -113,7 +113,7 @@ def path(args):
output = sys.stdout
if args.selftest:
from bob.db.utils import null
from bob.db.base.utils import null
output = null()
r = db.paths(args.id, prefix=args.directory, suffix=args.extension)
......@@ -131,7 +131,7 @@ class Interface(BaseInterface):
def version(self):
import pkg_resources # part of setuptools
return pkg_resources.require('xbob.db.%s' % self.name())[0].version
return pkg_resources.require('bob.db.%s' % self.name())[0].version
def files(self):
......
......@@ -21,13 +21,13 @@
"""
import os, numpy
import bob.db.utils
import bob.db.base.utils
from sqlalchemy import Table, Column, Integer, String, ForeignKey, or_, and_, not_
from bob.db.sqlalchemy_migration import Enum, relationship
from bob.db.base.sqlalchemy_migration import Enum, relationship
from sqlalchemy.orm import backref
from sqlalchemy.ext.declarative import declarative_base
import xbob.db.verification.utils
import bob.db.verification.utils
Base = declarative_base()
......@@ -95,7 +95,7 @@ class Model(Base):
def __repr__(self):
return "Model(%s, %s)" % (self.name, self.sgroup)
class File(Base, xbob.db.verification.utils.File):
class File(Base, bob.db.verification.utils.File):
"""Generic file container"""
__tablename__ = 'file'
......@@ -116,7 +116,7 @@ class File(Base, xbob.db.verification.utils.File):
def __init__(self, client_id, path, finger_id, session_id):
# call base class constructor
xbob.db.verification.utils.File.__init__(self, client_id = client_id, path = path)
bob.db.verification.utils.File.__init__(self, client_id = client_id, path = path)
#self.sgroup = sgroup
self.finger_id = finger_id
self.session_id = session_id
......
......@@ -23,15 +23,15 @@ UTFVP database in the most obvious ways.
import os
import six
from bob.db import utils
from bob.db.base import utils
from .models import *
from .driver import Interface
import xbob.db.verification.utils
import bob.db.verification.utils
SQLITE_FILE = Interface().files()[0]
class Database(xbob.db.verification.utils.SQLiteDatabase):
class Database(bob.db.verification.utils.SQLiteDatabase):
"""The dataset class opens and maintains a connection opened to the Database.
It provides many different ways to probe for the characteristics of the data
......@@ -40,7 +40,7 @@ class Database(xbob.db.verification.utils.SQLiteDatabase):
def __init__(self, original_directory = None, original_extension = None):
# call base class constructors
xbob.db.verification.utils.SQLiteDatabase.__init__(self, SQLITE_FILE, File)
bob.db.verification.utils.SQLiteDatabase.__init__(self, SQLITE_FILE, File)
def groups(self, protocol=None):
"""Returns the names of all registered groups"""
......
......@@ -22,14 +22,15 @@
import os, sys
import unittest
import xbob.db.utfvp
import bob.db.base
import bob.db.utfvp
class UTFVPDatabaseTest(unittest.TestCase):
"""Performs various tests on the UTFVP database."""
def test01_clients(self):
# test whether the correct number of clients is returned
db = xbob.db.utfvp.Database()
db = bob.db.utfvp.Database()
self.assertEqual(len(db.groups()), 3)
self.assertEqual(len(db.protocols()), 8)
......@@ -99,7 +100,7 @@ class UTFVPDatabaseTest(unittest.TestCase):
def test02_objects(self):
# tests if the right number of File objects is returned
db = xbob.db.utfvp.Database()
db = bob.db.utfvp.Database()
# Protocol '1vsall'
self.assertEqual(len(db.objects(protocol='1vsall')), 1440) #1440 - 60 users * 6 fingers * 4 acq
......@@ -311,7 +312,7 @@ class UTFVPDatabaseTest(unittest.TestCase):
def test03_driver_api(self):
from bob.db.script.dbmanage import main
from bob.db.base.script.dbmanage import main
self.assertEqual(main('utfvp dumplist --self-test'.split()), 0)
self.assertEqual(main('utfvp dumplist --protocol=1vsall --class=client --group=dev --purpose=enrol --model=1_2_3 --self-test'.split()), 0)
self.assertEqual(main('utfvp checkfiles --self-test'.split()), 0)
......
......@@ -56,6 +56,11 @@ parser.add_option("-c", "--config-file",
"file to be used."))
parser.add_option("-f", "--find-links",
help=("Specify a URL to search for buildout releases"))
parser.add_option("--allow-site-packages",
action="store_true", default=False,
help=("Let bootstrap.py use existing site packages"))
parser.add_option("--setuptools-version",
help="use a specific setuptools version")
options, args = parser.parse_args()
......@@ -63,45 +68,42 @@ options, args = parser.parse_args()
######################################################################
# load/install setuptools
to_reload = False
try:
import pkg_resources
import setuptools
if options.allow_site_packages:
import setuptools
import pkg_resources
from urllib.request import urlopen
except ImportError:
ez = {}
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
# XXX use a more permanent ez_setup.py URL when available.
exec(urlopen('https://bitbucket.org/pypa/setuptools/raw/0.7.2/ez_setup.py'
).read(), ez)
setup_args = dict(to_dir=tmpeggs, download_delay=0)
ez['use_setuptools'](**setup_args)
if to_reload:
reload(pkg_resources)
import pkg_resources
# This does not (always?) update the default working set. We will
# do it.
for path in sys.path:
if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path)
from urllib2 import urlopen
######################################################################
# Try to best guess the version of buildout given setuptools
if options.version is None:
try:
from distutils.version import LooseVersion
package = pkg_resources.require('setuptools')[0]
v = LooseVersion(package.version)
if v < LooseVersion('0.7'):
options.version = '2.1.1'
except:
pass
ez = {}
exec(urlopen('https://bootstrap.pypa.io/ez_setup.py').read(), ez)
if not options.allow_site_packages:
# ez_setup imports site, which adds site packages
# this will remove them from the path to ensure that incompatible versions
# of setuptools are not in the path
import site
# inside a virtualenv, there is no 'getsitepackages'.
# We can't remove these reliably
if hasattr(site, 'getsitepackages'):
for sitepackage_path in site.getsitepackages():
sys.path[:] = [x for x in sys.path if sitepackage_path not in x]
setup_args = dict(to_dir=tmpeggs, download_delay=0)
if options.setuptools_version is not None:
setup_args['version'] = options.setuptools_version
ez['use_setuptools'](**setup_args)
import setuptools
import pkg_resources
# This does not (always?) update the default working set. We will
# do it.
for path in sys.path:
if path not in pkg_resources.working_set.entries:
pkg_resources.working_set.add_entry(path)
######################################################################
# Install buildout
......@@ -132,10 +134,15 @@ if version is None and not options.accept_buildout_test_releases:
_final_parts = '*final-', '*final'
def _final_version(parsed_version):
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
try:
return not parsed_version.is_prerelease
except AttributeError:
# Older setuptools
for part in parsed_version:
if (part[:1] == '*') and (part not in _final_parts):
return False
return True
index = setuptools.package_index.PackageIndex(
search_path=[setuptools_path])
if find_links:
......@@ -162,8 +169,7 @@ cmd.append(requirement)
import subprocess
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
raise Exception(
"Failed to execute command:\n%s",
repr(cmd)[1:-1])
"Failed to execute command:\n%s" % repr(cmd)[1:-1])
######################################################################
# Import and run buildout
......
; vim: set fileencoding=utf-8 :
; Pedro Tome <pedro.tome@idiap.ch>
; Tus Jan 16 19:35:15 CEST 2015
[buildout]
parts = scripts
develop = .
eggs = xbob.db.utfvp
eggs = bob.db.utfvp
extensions = bob.buildout
mr.developer
auto-checkout = *
develop = src/bob.extension
src/bob.blitz
src/bob.core
src/bob.io.base
src/bob.db.base
src/bob.db.verification.utils
.
; options for bob.buildout extension
debug = true
verbose = true
newest = false
[sources]
bob.extension = git https://github.com/bioidiap/bob.extension
bob.blitz = git https://github.com/bioidiap/bob.blitz
bob.core = git https://github.com/bioidiap/bob.core
bob.io.base = git https://github.com/bioidiap/bob.io.base
bob.db.base = git https://github.com/bioidiap/bob.db.base
bob.db.verification.utils = git https://github.com/bioidiap/bob.db.verification.utils
[scripts]
recipe = xbob.buildout:scripts
dependent-scripts = true
recipe = bob.buildout:scripts
dependent-scripts=true
#!/usr/bin/env python
# vim: set fileencoding=utf-8 :
# Andre Anjos <andre.anjos@idiap.ch>
# Mon 13 Aug 2012 12:38:15 CEST
#
# Copyright (C) 2011-2015 Idiap Research Institute, Martigny, Switzerland
import os
import sys
import glob
import pkg_resources
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.pngmath',
'sphinx.ext.ifconfig',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
]
# The viewcode extension appeared only on Sphinx >= 1.0.0
import sphinx
if sphinx.__version__ >= "1.0":
extensions.append('sphinx.ext.viewcode')
# Always includes todos
todo_include_todos = True
# If we are on OSX, the 'dvipng' path maybe different
dvipng_osx = '/opt/local/libexec/texlive/binaries/dvipng'
if os.path.exists(dvipng_osx): pngmath_dvipng = dvipng_osx
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'UTFVP Fingervein Database (Bob API)'
import time
copyright = u'%s, Idiap Research Institute' % time.strftime('%Y')
# Grab the setup entry
distribution = pkg_resources.require('bob.db.utfvp')[0]
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = distribution.version
# The full version, including alpha/beta/rc tags.
release = distribution.version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['**/links.rst']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
if sphinx.__version__ >= "1.0":
html_theme = 'nature'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = 'bob'
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = 'img/logo.png'
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = 'img/favicon.ico'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,