Skip to content

JaneliaSciComp/neuronbridge-python

Repository files navigation

NeuronBridge Python API

DOI

A Python API for the NeuronBridge neuron similarity search service.

Data Model Diagram

Installation

This library is available on PyPI, so you can install it like this:

pip install neuronbridge-python

Usage

The client will automatically select the latest version of the data and fetch it from S3. Here's a simple example of how to get an EM image by id:

from neuronbridge import client
client = client.Client()
em_image = client.get_em_image(636798093) 

See this notebook for complete usage examples.

Development Notes

Create a new virtual environment and install the dependencies:

uv venv --python 3.11
source .venv/bin/activate
uv pip sync requirements-universal.txt
uv pip install -e .

Running data validation using Ray

You can run validation multithreaded on a single machine like this:

./neuronbridge/validate_ray.py --dashboard --cores 60

To run the validation script in a distributed manner on the Janelia cluster, you must first install ray-janelia in a sister directory to where this code base is cloned. Then run a script to bsub the Ray cluster:

./scripts/launch_validation.sh

Updating requirements

After updating the requirements.txt file, you can sync the requirements-universal.txt file like this:

uv pip compile requirements.txt --universal --output-file  requirements-universal.txt

Regenerate the JSON schemas:

python neuronbridge/generate_schemas.py

Run the unit tests:

pytest tests

Publishing a new release

  1. Update the version in setup.py
  2. Push all changes and tag a release in GitHub
  3. Build PyPI distribution:
python setup.py sdist bdist_wheel
  1. Upload to PyPI:
twine upload dist/*