Skip to content

Commit

Permalink
Merge pull request #4 from AllenNeuralDynamics/cdci-add-uv-support
Browse files Browse the repository at this point in the history
Add support of uv package manager
  • Loading branch information
bruno-f-cruz authored Nov 18, 2024
2 parents 6d71e79 + b533519 commit fbef21e
Show file tree
Hide file tree
Showing 7 changed files with 1,833 additions and 29 deletions.
51 changes: 31 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
name: CI

on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
linters:
runs-on: windows-latest
name: Lint ${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
python-version: ['3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v3
with:
python-version: "3.11"
enable-cache: true

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -e .[linters] --no-cache-dir
run: uv sync --extra dev
- name: Run ruff format
run: ruff format .
run: uv run ruff format .
- name: Run ruff check
run: ruff check .
run: uv run ruff check .
- name: Run codespell
run : codespell .
run : uv run codespell .

tests:
runs-on: windows-latest
Expand All @@ -33,26 +42,28 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: 7.x
dotnet-version: 8.x
- name: Restore dotnet tools
run: dotnet tool restore
- name: Setup Bonsai
working-directory: bonsai
run: .\Setup.ps1

- name: Set up Python
uses: actions/setup-python@v3
- uses: astral-sh/setup-uv@v3
with:
python-version: '3.11'
enable-cache: true

- name: Set up Python
run: uv python install


- name: Install dependencies
run: |
python -m pip install -e . --no-cache-dir
run: uv sync --extra dev
- name: Run tests
run: python -m unittest
run: uv run -m unittest
- name: Regenerate schemas
run: regenerate
run: uv run regenerate
- name: Check for uncommitted changes
run: |
git config --global core.safecrlf false
git diff --exit-code || (echo "Untracked changes found" && exit 1)
git diff --exit-code || (echo "Untracked changes found" && exit 1)
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Deploy Sphinx documentation to Pages

on:
workflow_dispatch:
#push:
# branches: [main] # branch to trigger deployment
push:
branches: main

jobs:
pages:
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/tag_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Tag and Publish

on:
workflow_dispatch: {}

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pull latest changes
run: git pull origin ${{ env.DEFAULT_BRANCH }}
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true
- name: Set up Python
run: uv python install

- name: Extract version from __init__.py and package name from pyproject.toml
id: get_version_and_name
run: |
package_name=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")
package_name=${package_name//-/_}
version=$(python -c "import re;
with open(f'./src/${package_name}/__init__.py', 'r') as f:
content = f.read();
match = re.search(r'__version__\s*=\s*[\'\"]([^\'\"]+)[\'\"]', content);
print(match.group(1)) if match else exit(1)")
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV
shell: bash

- name: Create Git tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a v${{ env.PACKAGE_VERSION }} -m "v${{ env.PACKAGE_VERSION }}"
git push origin v${{ env.PACKAGE_VERSION }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.SERVICE_TOKEN }}
tag_name: v${{ env.PACKAGE_VERSION }}
name: Release v${{ env.PACKAGE_VERSION }}
generate_release_notes: true

publish:
needs: tag
if: always() # Enable publishing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pull latest changes
run: git pull origin ${{ env.DEFAULT_BRANCH }}
- uses: astral-sh/setup-uv@v3
with:
enable-cache: true

- name: Set up Python
run: uv python install

- name: Build
run: uv build

- name: Publish
run: uv publish --token ${{ secrets.AIND_PYPI_TOKEN }}
3 changes: 3 additions & 0 deletions .python-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
3.11
3.12
3.13
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# aind-behavior-telekinesis

![CI](https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/actions/workflows/ci.yml/badge.svg)
[![PyPI - Version](https://img.shields.io/pypi/v/aind-behavior-telekinesis)](https://pypi.org/project/aind-behavior-telekinesis/)
[![License](https://img.shields.io/badge/license-MIT-brightgreen)](LICENSE)
[![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)

Task implementation of brain-computer interface experiments.

## General instructions
Expand Down
24 changes: 17 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ build-backend = "setuptools.build_meta"
[project]
name = "aind-behavior-telekinesis"
description = "A library that defines AIND data schema for the brain-computer interface experiments."
authors = [ {name = "Bruno Cruz", email = "[email protected]"}]
license = {text = "MIT"}
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3"
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
]
readme = "README.md"
dynamic = ["version"]
Expand All @@ -17,15 +20,22 @@ dependencies = [
"aind_behavior_services>=0.8, <0.9",
]

[project.optional-dependencies]
[project.urls]
Documentation = "https://allenneuraldynamics.github.io/Aind.Behavior.Telekinesis/"
Repository = "https://github.com/AllenNeuralDynamics/Aind.Behavior.Telekinesis/"
Issues = "https://github.com/AllenNeuralDynamics/Aind.Behavior.Telekinesis/issues"
Changelog = "https://github.com/AllenNeuralDynamics/Aind.Behavior.Telekinesis/releases"

linters = [
'ruff',
'codespell'
]
[project.optional-dependencies]

launcher = ["aind_behavior_experiment_launcher[aind-services]>=0.2"]

dev = [
"aind_behavior_telekinesis[launcher]",
"ruff",
"codespell",
]

docs = [
'Sphinx<7.3',
'furo',
Expand Down Expand Up @@ -57,5 +67,5 @@ mccabe = { max-complexity = 14 }
pydocstyle = { convention = 'google' }

[tool.codespell]
skip = '.git,*.pdf,*.svg,./bonsai,*.bonsai,./docs/_build'
skip = '.git,*.pdf,*.svg,./bonsai,*.bonsai,./docs/_build,uv.lock'
ignore-words-list = 'nd'
Loading

0 comments on commit fbef21e

Please sign in to comment.