Skip to content
Merged
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JUPYTER_PLATFORM_DIRS=1
64 changes: 63 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,74 @@ jobs:
with:
path: bsmschema
attest-build-provenance-github: ${{ github.event_name != 'pull_request' }}
- name: Upload uv.lock
uses: actions/upload-artifact@v4
with:
name: Lockfile
path: |
uv.lock
pyproject.toml

test:
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
matrix:
os: ['ubuntu-latest']
source: ['repo', 'sdist']
fail-fast: false

env:
DEPENDS: ${{ matrix.dependencies }}

steps:
- uses: actions/checkout@v4
if: matrix.source == 'repo'
with:
submodules: recursive
fetch-depth: 0
- name: Download packages built by build-and-inspect-python-package
if: matrix.source == 'sdist'
uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Download lockfile
if: matrix.source == 'sdist'
uses: actions/download-artifact@v4
with:
name: Lockfile
- name: Extract sdist
if: matrix.source == 'sdist'
run: |
ls -lR
mkdir -p bsmschema
tar --strip-components=1 -C bsmschema -xzf dist/*.tar.gz
ls -lR
- name: Set up uv
uses: astral-sh/setup-uv@v6
- name: Install tox and coverage
run: |
uv tool install tox --with=tox-uv
uv tool install coverage[toml]
- name: Run tox
run: tox run-parallel -c bsmschema/tox.ini --exit-and-dump-after 60
- name: Combine coverage
run: |
coverage combine
coverage xml
working-directory: bsmschema
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
working-directory: bsmschema

publish:
name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
needs: [build]
needs: [build, test]
permissions:
attestations: write
id-token: write
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.*.swp
.vscode

dist/
5 changes: 5 additions & 0 deletions bsmschema/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ build/

.mypy_cache/
.pytest_cache/

.tox/

.coverage
htmlcov
3 changes: 1 addition & 2 deletions bsmschema/bsmschema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

# Hack to avoid unnecessary verbosity when generating documentation
# Has no impact on emitted JSON, only on whether Python will attempt to cast instead of error
if not TYPE_CHECKING and 'sphinxcontrib.autodoc_pydantic' in sys.modules:
if not TYPE_CHECKING and 'sphinxcontrib.autodoc_pydantic' in sys.modules: # pragma: no cover
StrictStr = str # noqa: F811
StrictInt = int # noqa: F811
StrictFloat = float # noqa: F811
Expand Down Expand Up @@ -126,7 +126,6 @@ class Edge(_BSMBase):
Destination: StrictStr
"""Name of :py:class:`Node`. The outputs of :py:attr:`Source` are passed to this node.

If :py:attr:`Filter` is defined,
The outputs of the Source node are the inputs of the Destination node, after filtering (if any)."""
Filter: OptionalFilter = None
"""Maps a grouping variable to a list of values to pass to Destination.
Expand Down
21 changes: 19 additions & 2 deletions bsmschema/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ dependencies = [
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
]
dynamic = ["version"]
Expand All @@ -29,6 +30,18 @@ dynamic = ["version"]
Homepage = "https://bids-standard.github.io/stats-models/"
"Source code" = "https://github.com/bids-standard/stats-models"

[dependency-groups]
test = [
"pytest >=8",
"acres >=0.2",
"coverage[toml] >=7",
"pytest-cov >=6",
]
types = [
"mypy",
"pyright",
]

[tool.hatch.build.targets.wheel]
packages = ["bsmschema"]

Expand All @@ -47,3 +60,7 @@ quote-style = "single"

[tool.mypy]
strict = true

[tool.coverage.run]
parallel = true
branch = true
Empty file added bsmschema/tests/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions bsmschema/tests/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import acres

load = acres.Loader(__spec__.name)
1 change: 1 addition & 0 deletions bsmschema/tests/data/examples
12 changes: 12 additions & 0 deletions bsmschema/tests/test_load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from bsmschema.models import BIDSStatsModel

from . import data


def test_load():
example = data.load.readable('examples', 'model-example_smdl.json')
model = BIDSStatsModel.model_validate_json(example.read_text())

assert model.Name == 'my_first_model'
assert len(model.Nodes) == 3
assert len(model.Edges) == 2
48 changes: 48 additions & 0 deletions bsmschema/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[tox]
requires =
tox>=4
tox-uv
envlist =
py3{9,10,11,12,13}-latest
py3{11,12,13}-pre
py39-min
skip_missing_interpreters = true

[gh-actions]
python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313

[gh-actions:env]
DEPENDS =
min: min
latest: latest
pre: pre

[testenv]
description = Pytest with coverage
pip_pre =
pre: true
pass_env =
# Pass user color preferences through
PY_COLORS
FORCE_COLOR
NO_COLOR
CLICOLOR
CLICOLOR_FORCE
set_env =
# Allows us to use tox run-parallel with pytest-cov
COVERAGE_FILE = .coverage.{envname}
dependency_groups =
test
uv_resolution =
min: lowest-direct

commands =
python -m pytest --doctest-modules --cov --cov-report term

[testenv:py{39,310,311,312,313}-latest]
runner = uv-venv-lock-runner
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "stats-models"
version = "0.1.0"
requires-python = ">=3.13"
requires-python = ">=3.9"
dependencies = [
"bsmschema",
"jupyter-book>=0.13",
Expand Down
Loading