develop.rst 6.72 KB
Newer Older
1 2
.. vim: set fileencoding=utf-8 :

3
.. Copyright (c) 2019 Idiap Research Institute, http://www.idiap.ch/          ..
4 5
.. Contact: beat.support@idiap.ch                                             ..
..                                                                            ..
6
.. This file is part of the beat.backend.python module of the BEAT platform.  ..
7
..                                                                            ..
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
.. Redistribution and use in source and binary forms, with or without
.. modification, are permitted provided that the following conditions are met:

.. 1. Redistributions of source code must retain the above copyright notice, this
.. list of conditions and the following disclaimer.

.. 2. Redistributions in binary form must reproduce the above copyright notice,
.. this list of conditions and the following disclaimer in the documentation
.. and/or other materials provided with the distribution.

.. 3. Neither the name of the copyright holder nor the names of its contributors
.. may be used to endorse or promote products derived from this software without
.. specific prior written permission.

.. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
.. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
.. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
.. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
.. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
.. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
.. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

33

34
.. _beat-core-local-development:
35 36 37 38 39 40 41 42 43 44

===================
 Local Development
===================

Go through the following sequence of commands:


.. code-block:: sh

45
   $ git checkout https://gitlab.idiap.ch/bob/bob.admin
46 47 48
   $ #install miniconda (version 4.4 or above required)
   $ conda activate base
   $ cd beat.backend.python #cd into this package's sources
49
   $ ../bob.admin/conda/conda-bootstrap.py --overwrite --python=3.6 beat-core-dev
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
   $ conda activate beat-core-dev
   $ #n.b.: docker must be installed on your system (see next section)
   $ buildout -c develop.cfg

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


Docker
------

This package depends on Docker_ and may use 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.

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.


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
75
virtual machine (a.k.a. the *docker machine*). Follow the instructions at `the docker website`_ before trying to
76 77 78 79 80
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::

81 82 83 84
  $ docker pull beatenv/beat.env.db.examples:1.4.1r0
  $ docker pull beatenv/beat.env.python:2.1.0r7
  $ docker pull beatenv/beat.env.cxxdev:2.0.0r4
  $ docker pull beatenv/beat.env.cxx:2.0.0r4
85

86
Optionally, you can also download other images to be able to re-run experiments
87 88 89
downloaded from the BEAT platform (not required for unit testing). These docker
images corresponds to the python environment available on the platform. Keep in
mind that at the moment you cannot use different environments to run each block
90 91
when you are using BEAT locally unless using the Docker executor. These images
can be found on the `beatenv docker hub repository`_.
92

93 94 95

Before pulling these images, you should check the registry as there might have
been new release (i.e. rX versions).
96

97 98 99 100
To run an experiment using docker you should specify the docker image when defining the experiment, then use the `--docker` flag when using `beat.cmdline`::

  $ beat experiment run --docker <experiment name>

101
You can find more information about running experiments locally using different executors in the "Experiments" section of "beat.cmdline" in `BEAT documentation`_.
102

103

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
Custom image development
------------------------

Scientific development evolving quickly, the platform provided runtime environments
may not contain everything you need for your algorithms to run. In that case, you
can prepare your own environment using the following git repository.

  $ git clone https://gitlab.idiap.ch/beat/beat.env.example

The examples provided there will allow you to build docker images suitable both
for algorithm execution and if needed database handling.

Instructions are provided in the repository.


119 120 121 122 123 124 125 126 127 128
Documentation
-------------

To build the documentation, just do:

.. code-block:: sh

   $ ./bin/sphinx-build doc sphinx


129

130 131 132 133 134 135 136 137 138 139 140 141 142
Testing
-------

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

.. code-block:: sh

   $ ./bin/nosetests -sv


.. note::

143 144 145 146 147
  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::
148

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

152
  .. warning::
153

154
    Do **NOT** run tests against a production web server.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170


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


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

171
    $ ./bin/sphinx -b doctest doc sphinx
172

173
Other Bits
174
==========
175

176
Profiling
177
---------
178 179 180 181 182 183 184 185 186 187 188 189 190 191

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.


192
.. include:: links.rst