Repository for collecting analytics and scripts related to the NWB project.
The NWB project maintains and contributes to a large number of codes
related to NWB. The goal of this effort is to help developers to get a
quick overview of the state of NWB code repositories. See, e.g., the code health page <https://github.com/NeurodataWithoutBorders/nwb-project-analytics/blob/main/docs/source/code_health.rst>
_
Status: This project is under active development. The code is in the alpha development phase.
All main NWB analytics are compiled automatically when building the docs
.. code-block:: bash:
conda create --name nwb_analytics_env python=3.8
conda activate nwb_analytics_env
Install cloc
(see here <https://github.com/AlDanial/cloc#install-via-package-manager>
_)
(only needed when you want to update the cloc code statistics in data/
)
Install the tools via
.. code-block:: bash
git clone https://github.com/NeurodataWithoutBorders/nwb-project-analytics.git
cd nwb-project-analytics
pip install -r requirements.txt -r requirements-doc.txt
pip install -e .
.. code-block:: bash
cd docs
make html
open build/html/index.html
.. code-block:: bash
cd docs
make allclean
Using the make allclean
command removes all auto-generated figures and rst files in the docs/source
directory (specifically docs/source/code_stat_pages
and docs/source/nwb_project_analytics.*rst
) as well as all builds from docs/builds
. When rebuilding the docs (e.g., via make html
) the files will be regenerated (using the data cached in data/
).
data/
On this repo, the information cached in data/
is automatically updated nighlty by the build_analytics_data.yml <https://github.com/NeurodataWithoutBorders/nwb-project-analytics/blob/main/.github/workflows/build_analytics_data.yml>
_ GitHub Action. To manually update the statistics cached in data/
, simply remove the cached results and build the docs:
.. code-block:: bash
rm data/cloc_stats.yaml
rm data/commit_stats.yaml
rm data/git_paths.yaml
rm data/release_timelines.yaml
rm data/contributors.tsv
cd docs
make html
After completing the update, commit the updated data to the repo
.. code-block:: bash
git commit -m "Updated code statistics data" ./data/*.yaml
To add a new entry to the NWBGitInfo.GIT_REPOS
dictionary in src/nwb_project_analytics/gitstats.py
. The dictionary is used to track all main NWB repositories and stores for each repo a GitRepo
object with basic metadata about the code (e.g., the location of the repo, name of the main branch, etc.). When adding a new code, all statistics need to be updated following the instructions above on How to update the data/
.
The code uses the cloc
tool to calculate line-of-code statistics. Computing cloc
statistics for all codes is time-consuming as we need to compute them over time. This is accomplished by running cloc
for all commits (or more accurately the last commit on each day) on the main branch of each code. The cloc results are saved in the data/
folder to avoid unnecessary updates and safe time.
The nwb_project_analytics
library includes a number of tools to help
with collecting and plotting data related to NWB code repositories. This includes for example:
nwb_project_analytics.codecovstats
: Module for getting data from Codecov.ionwb_project_analytics.codestats
: Module for computing code statistics using CLOCnwb_project_analytics.gitstats
: Module to help query GitHub reposnwb_project_analytics.renderstats module
: Module for creating plots for code statisticsnwb_project_analytics.create_codestat_pages
: Module used to generate Sphinx documentation with code statistics