README.rst 6.23 KB
Newer Older
André Anjos's avatar
André Anjos committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.. vim: set fileencoding=utf-8 :

.. Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/          ..
.. Contact: beat.support@idiap.ch                                             ..
..                                                                            ..
.. This file is part of the beat.core module of the BEAT platform.            ..
..                                                                            ..
.. Commercial License Usage                                                   ..
.. Licensees holding valid commercial BEAT licenses may use this file in      ..
.. accordance with the terms contained in a written agreement between you     ..
.. and Idiap. For further information contact tto@idiap.ch                    ..
..                                                                            ..
.. Alternatively, this file may be used under the terms of the GNU Affero     ..
.. Public License version 3 as published by the Free Software and appearing   ..
.. in the file LICENSE.AGPL included in the packaging of this file.           ..
.. The BEAT platform is distributed in the hope that it will be useful, but   ..
.. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ..
.. or FITNESS FOR A PARTICULAR PURPOSE.                                       ..
..                                                                            ..
.. You should have received a copy of the GNU Affero Public License along     ..
.. with the BEAT platform. If not, see http://www.gnu.org/licenses/.          ..


============================================
 Biometrics Evaluation and Testing Platform
============================================

This package contains the source code for the core components of the BEAT
platform.

André Anjos's avatar
André Anjos committed
31

André Anjos's avatar
André Anjos committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Installation
------------

Really easy, with ``zc.buildout``::

  $ python bootstrap-buildout.py
  $ ./bin/buildout

These 2 commands should download and install all non-installed dependencies and
get you a fully operational test and development environment.

.. note::

  The python shell used in the first line of the previous command set
  determines the python interpreter that will be used for all scripts developed
  inside this package.

  If you are on the Idiap filesystem, you may use
  ``/idiap/project/beat/beat.env.deploy/usr/bin/python`` to bootstrap this
  package instead. It contains the same setup deployed at the final BEAT
  machinery.


André Anjos's avatar
André Anjos committed
55
56
Docker
======
André Anjos's avatar
André Anjos committed
57

André Anjos's avatar
André Anjos committed
58
59
60
This package depends on Docker_ and uses it to run user algorithms in a
container with the required software stack. You must install the Docker_ engine
and make sure the user running tests has access to it.
André Anjos's avatar
André Anjos committed
61

André Anjos's avatar
André Anjos committed
62
63
64
In particular, this package controls memory and CPU utilisation of the
containers it launches. You must make sure to enable those functionalities on
your installation.
André Anjos's avatar
André Anjos committed
65

Philip ABBET's avatar
Philip ABBET committed
66

André Anjos's avatar
André Anjos committed
67
68
69
70
71
72
73
74
75
76
77
78
Docker Setup
============

Make sure you have the ``docker`` command available on your system. For certain
operating systems, it is necessary to install ``docker`` via an external
virtual machine (a.k.a. the *docker machine*). Follow the instructions at `the
docker website <https://docs.docker.com/engine/installation/>` before trying to
execute algorithms or experiments.

We use specific docker images to run user algorithms. Download the following
base images before you try to run tests or experiments on your computer::

Philip ABBET's avatar
Philip ABBET committed
79
80
81
82
  $ docker pull docker.idiap.ch/beat/beat.env.system.python:1.1.2
  $ docker pull docker.idiap.ch/beat/beat.env.db.examples:1.1.1
  $ docker pull docker.idiap.ch/beat/beat.env.client:1.2.0
  $ docker pull docker.idiap.ch/beat/beat.env.cxx:1.0.2
André Anjos's avatar
André Anjos committed
83
84
85
86

Optionally, also download the following images to be able to re-run experiments
downloaded from the BEAT platform (not required for unit testing)::

Philip ABBET's avatar
Philip ABBET committed
87
  $ docker pull docker.idiap.ch/beat/beat.env.python:0.0.4
Philip ABBET's avatar
Philip ABBET committed
88
89
  $ docker pull docker.idiap.ch/beat/beat.env.python:1.0.0
  $ docker pull docker.idiap.ch/beat/beat.env.db:1.2.2
André Anjos's avatar
André Anjos committed
90

André Anjos's avatar
André Anjos committed
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

Documentation
-------------

To build the documentation, just do::

  $ ./bin/sphinx-apidoc --separate -d 2 --output=doc/api beat beat/core/test beat/core/scripts
  $ ./bin/sphinx-build doc sphinx


Testing
-------

After installation, it is possible to run our suite of unit tests. To do so,
use ``nose``::

  $ ./bin/nosetests -sv


.. note::

   Some of the tests for our command-line toolkit require a running BEAT
   platform web-server, with a compatible ``beat.core`` installed (preferably
   the same).  By default, these tests will be skipped. If you want to run
   them, you must setup a development web server and set the environment
   variable ``BEAT_CORE_TEST_PLATFORM`` to point to that address. For example::

     $ export BEAT_CORE_TEST_PLATFORM="http://example.com/platform/"
     $ ./bin/nosetests -sv

   It is **not** adviseable to run tests against a production web server.

If you want to skip slow tests (at least those pulling stuff from our servers)
or executing lengthy operations, just do::

  $ ./bin/nosetests -sv -a '!slow'

To measure the test coverage, do the following::

  $ ./bin/nosetests -sv --with-coverage --cover-package=beat.core

To produce an HTML test coverage report, at the directory `./htmlcov`, do the
following::

  $ ./bin/nosetests -sv --with-coverage --cover-package=beat.core --cover-html --cover-html-dir=htmlcov

Our documentation is also interspersed with test units. You can run them using
sphinx::

  $ ./bin/sphinx -b doctest doc sphinx


Development
-----------

Indentation
===========

André Anjos's avatar
André Anjos committed
149
150
You can enforce PEP8_ compliance using the application ``autopep8``. For
example, to enforce compliance on a single file and edit it in place, do::
André Anjos's avatar
André Anjos committed
151
152
153

  $ ./bin/autopep8 --indent-size=2 --in-place beat/core/utils.py

Philip ABBET's avatar
Philip ABBET committed
154
155
We normally use 2-space indentation. If ever, you can easily change the
indentation to 4 spaces like this::
André Anjos's avatar
André Anjos committed
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173

  $ ./bin/autopep8 --indent-size=4 --in-place beat/core/utils.py


Profiling
=========

In order to profile the test code, try the following::

  $ ./bin/python -mcProfile -oprof.data ./bin/nosetests -sv ...

This will dump the profiling data at ``prof.data``. You can dump its contents
in different ways using another command::

  $ ./bin/python -mpstats prof.data

This will allow you to dump and print the profiling statistics as you may find
fit.
André Anjos's avatar
André Anjos committed
174
175
176
177
178


.. References go here
.. _pep8: https://www.python.org/dev/peps/pep-0008/
.. _docker: https://www.docker.com/