Skip to content

Files

Latest commit

4342172 · May 15, 2020

History

History
71 lines (42 loc) · 3.2 KB

development-conventions.md

File metadata and controls

71 lines (42 loc) · 3.2 KB
description
How to work with the existing cellfinder developers

Development conventions

Pull requests

In all cases, please submit code to the main repository via a pull request. Upon approval, please merge via "Squash and Merge" on GitHub to maintain a clean commit history.

Please submit pull requests as early as possible (you can still push to the branch once submitted) to allow discussion.

Formatting

cellfinder uses Black to ensure a consistent code style. Please run black ./ -l 79 --target-version py37 before making any commits. To prevent any errors, it is easier to add a formatting check as a pre-commit hook. E.g. on linux by adding this to your .git/hooks/pre-commit:

black ./ -l 79 --target-version py37 --check || exit 1

Testing

cellfinder uses pytest for testing. Please try to ensure that all functions are tested in tests/tests/test_unit and all workflows/command-line tools are tested in tests/tests/test_integration.

Some tests may take a long time (e.g. those requiring tensorflow if you don't have a GPU). These tests should be marked with @pytest.mark.slow, e.g.:

import pytest
@pytest.mark.slow
def test_something_slow():
    slow_result = run_slow_processes()
    assert slow_result == expected_slow_thing

During development, these "slow" tests can be skipped by running pytest -m "not slow".

Travis

All commits & pull requests will be build by Travis. To ensure there are no issues, please check that it builds: pip install . and run all of the tests: pytest before committing changes.

Releases

Travis will automatically release any tagged commit on the master branch. Hence to release a new version of cellfinder, use either GitHub, or the git command-line tool to tag the relevant commit and push to master.

Dependencies

The code in the cellfinder repository should be primarily for cell detection. Other changes should be added to the relevant repository:

  • Regstration: amap
  • Brain imaging data IO: brainio
  • Visualisation & general utilities: neuro
  • General imaging processing (and other) tools: imlib.

File paths

All file paths should be defined in cellfinder.tools.prep.Paths. Any intermediate file paths, (i.e. those which are not of interest to the typical end user) should be prefixed with tmp__. These should then be cleaned up as soon as possible after generation.

Conventions

Cellfinder has recently (2019-08-02) dropped support for Python 3.5. Following this, a number of new python features will be adopted throughout.

  • pathlib conventions

    (rather then os.path).

  • f-strings

    (rather than .format() or using the old % operator).

In all cases, please aim to replace old calls to os.path or .format() with pathlib object methods and f-strings.