Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ updates:
# See https://docs.github.com/en/code-security/dependabot/dependabot-security-updates/configuring-dependabot-security-updates#overriding-the-default-behavior-with-a-configuration-file
# Note: this configuration only has an effect in repositories that have
# a requirements.txt file / use python / pip.
- package-ecosystem: "pip"
# Temporary uv override
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "weekly"
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ jobs:

- uses: actions/checkout@v6

- name: Set up Python 3.10
uses: actions/setup-python@v6
- name: Set up Python 3.10 with uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
uv sync --group dev

- name: Test with pytest
run: |
coverage run -m pytest
coverage lcov -o ./coverage/lcov.info
uv run coverage run -m pytest
uv run coverage lcov -o ./coverage/lcov.info

- name: Upload results to Codecov
uses: codecov/codecov-action@v5
Expand Down
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ repos:
rev: 26.3.0
hooks:
- id: black
args:
- --line-length=79
- --safe

- repo: https://github.com/PyCQA/flake8
rev: 7.3.0
Expand All @@ -29,7 +26,6 @@ repos:
rev: 8.0.1
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
Expand Down
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# We are using a two-stage build here because we use uv for dependency management
# But decide to keep it out of the production image.
# The Pre-build stage generates a pip compatible lockfile and then installs with pip
FROM ghcr.io/astral-sh/uv:latest AS prebuild

WORKDIR /build

COPY pyproject.toml uv.lock ./
RUN uv export --frozen --no-dev --no-hashes -o requirements.txt

# Build stage
FROM python:3.10

WORKDIR /usr/src/

COPY ./requirements.txt /usr/src/app/requirements.txt
COPY --from=prebuild /build/requirements.txt /usr/src/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /usr/src/app/requirements.txt

Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,28 @@ docker run -d -v ${PWD}/local_nb_nodes.json:/usr/src/local_nb_nodes.json:ro \
--name=federation -p 8080:8000 neurobagel/federation_api
```
NOTE: You can replace the port number `8080` for the `-p` flag with any port on the host you wish to use for the API.

### 3. Create a local development environment

We [use `uv`](https://docs.astral.sh/uv/getting-started/installation/)
for our local dev environment.

Once installed, just run

```bash
uv sync --group dev
```

to set up things in editable mode.

And then launch the API with

```bash
uv run uvicorn app.main:app
```

Also don't forget to set up precommit with

```bash
uv run pre-commit install
```
64 changes: 64 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[build-system]
requires = ["hatch-vcs", "hatchling"]
build-backend = "hatchling.build"

[project]
name = "federation-api"
description = "Neurobagel federation API for aggregating queries across multiple Neurobagel nodes."
readme = "README.md"
license = { file = "LICENSE" }
authors = [{ name = "Neurobagel Developers" }]
maintainers = [
{ name = "Alyssa Dai", email = "alyssa.dai@mcgill.ca" },
{ name = "Arman Jahanpour", email = "arman.jahanpour@mcgill.ca" },
{ name = "Sebastian Urchs", email = "sebastian.urchs@mcgill.ca" }
]
dynamic = ["version"]
requires-python = ">=3.10,<3.14"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: MIT License",
"Framework :: FastAPI",
"Framework :: Pydantic :: 2",
"Typing :: Typed",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]

dependencies = [
"fastapi[standard]",
"pydantic>=2.10,<3",
"PyJWT",
"typing-extensions",
"jsonschema",
"orjson"
]

[dependency-groups]
dev = [
"coverage",
"pytest",
"pytest-asyncio",
"pre-commit"
]

[tool.hatch.version]
source = "vcs" # use git tags to automatically determine the project version using hatch-vcs

[tool.hatch.build.hooks.vcs]
version-file = "app/_version.py" # useful for accessing dynamically calculated version inside the app (e.g., to support a --version option)

[tool.hatch.version.raw-options]
local_scheme = "no-local-version" # do not append local version info to the version string to avoid PyPI upload errors

[tool.black]
line-length = 79

[tool.isort]
profile = "black"
filter_files = true
line_length = 79
80 changes: 0 additions & 80 deletions requirements.txt

This file was deleted.

Loading
Loading