Skip to content

Latest commit

 

History

History
106 lines (76 loc) · 3.83 KB

CONTRIBUTING.md

File metadata and controls

106 lines (76 loc) · 3.83 KB

Contributing to Empress

Setting up an Empress development environment

You should be able to install Empress as described in the README. However, instead of running pip install ., please run pip install -e .[all]. This will install some various dependencies needed to test Empress' python code. In addition, make sure to periodically update to the latest development version of Emperor using pip install git+https://github.com/biocore/emperor.git.

You will also need to install a few Node.js packages in order to test Empress' JavaScript code.

npm install -g qunit-puppeteer jshint [email protected]

If you don't have npm installed, you will need to install that first.

Note: if you can't install puppeteer, the (JavaScript) test suite can be run using a web browser by opening the page in tests/index.html.

Running tests

The Makefile contained in the root of the Empress repository is the easiest way to run Empress' tests.

You can run both the Python and JavaScript tests by running

make test

If you just want to run the Python or JavaScript tests, you can run make pytest or make jstest respectively.

Notes about JavaScript tests

If you add HTML elements to EMPress' HTML code that the JavaScript code relies on, you will also need to add these elements to the tests/index.html file. Ideally this would not be necessary, but for now it is. (Failing to do this can cause obscure error messages from the JS tests.)

Also, loading the test index.html fails on Firefox for some of the Legend tests: see #435. To circumvent this, if you need to load the tests in the browser (rather than using puppeteer), we recommend using a different browser for the time being.

Front-end development

For convenience, a utility script ./tests/python/make-dev-page.py is bundled in the test suite. This script works best if you install the package in "editable mode" i.e. by running pip install -e . from the base directory.

After installing the package, the script can be run without any arguments. This will load the moving pictures dataset and create a page development-page.html. Using this page developers can modify CSS and JS files and simply reload the page on the browser to see their changes take effect. Alternatively, you can set the input data for development using the various options and arguments in the script. For a full list of options and arguments, you can run ./tests/python/make-dev-page.py --help.

Note, modifications to the Python code, or the template code require that you re-generate development-page.html.

Linting and style-checking

Empress' python code is linted/style-checked using flake8. Empress' JavaScript code is linted using jshint and style-checked using prettier.

Assuming you have these dependencies installed (see above for instructions), you can just run

make stylecheck

to see if your code passes these checks.

make stylecheck will be run on GitHub Actions, so it's useful to run this periodically while developing to make sure that your code looks good (and so you can address any issues as they come up, rather than all at once when trying to submit a pull request).

Running make stylecheck automatically before every commit

If you'd like to ensure that make stylecheck is run automatically before you can commit something locally -- thus ensuring that the stuff you do commit is well-formatted -- then you can run

make githook

to add on a pre-commit hook to your Empress git repository that just runs make stylecheck.

Auto-formatting the JavaScript code

Although some code issues (e.g. many things identified by jshint) will require manual resolution, you can use prettier to automatically format your JavaScript code. This can be done by just running

make jsstyle