Skip to content

Commit

Permalink
Merge branch 'liezl/add-camera-group' of https://github.com/talmolab/…
Browse files Browse the repository at this point in the history
…sleap into liezl/acg-add-recording-session
  • Loading branch information
roomrys committed Sep 26, 2023
2 parents 8ff9364 + 587331f commit 348a656
Show file tree
Hide file tree
Showing 81 changed files with 4,939 additions and 2,599 deletions.
4 changes: 2 additions & 2 deletions .conda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This folder defines the conda package build for Linux and Windows. There are run
To build, first go to the base repo directory and install the build environment:

```
conda env create -f environment_build.yml -n sleap_build && conda activate sleap_build
mamba env create -f environment_build.yml -n sleap_build && conda activate sleap_build
```

And finally, run the build command pointing to this directory:
Expand All @@ -15,7 +15,7 @@ conda build .conda --output-folder build -c conda-forge -c nvidia -c https://con
To install the local package:

```
conda create -n sleap_0 -c conda-forge -c nvidia -c ./build -c https://conda.anaconda.org/sleap/ -c anaconda sleap=x.x.x
mamba create -n sleap_0 -c conda-forge -c nvidia -c ./build -c https://conda.anaconda.org/sleap/ -c anaconda sleap=x.x.x
```

replacing x.x.x with the version of SLEAP that you just built.
2 changes: 1 addition & 1 deletion .conda/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set PIP_IGNORE_INSTALLED=False

@REM Install the pip dependencies. Note: Using urls to wheels might be better:
@REM https://docs.conda.io/projects/conda-build/en/stable/user-guide/wheel-files.html)
pip install -r .\requirements.txt
pip install --no-cache-dir -r .\requirements.txt

@REM HACK(LM): (untested) Uninstall all opencv packages and install opencv-contrib-python
for /f "tokens=1" %%a in ('conda list ^| findstr opencv') do pip uninstall %%a -y
Expand Down
12 changes: 10 additions & 2 deletions .conda/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ export PIP_IGNORE_INSTALLED=False

# Install the pip dependencies. Note: Using urls to wheels might be better:
# https://docs.conda.io/projects/conda-build/en/stable/user-guide/wheel-files.html)
pip install -r ./requirements.txt
pip install --no-cache-dir -r ./requirements.txt

# HACK(LM): (untested) Uninstall all opencv packages and install opencv-contrib-python
conda list | grep opencv | awk '{system("pip uninstall " $1 " -y")}'
pip install "opencv-contrib-python<4.7.0"

# Install sleap itself. This does not install the requirements, but will list which
# requirements are missing (see "install_requires") when user attempts to install.
python setup.py install --single-version-externally-managed --record=record.txt
python setup.py install --single-version-externally-managed --record=record.txt

# Copy the activate scripts to $PREFIX/etc/conda/activate.d.
# This will allow them to be run on environment activation.
for CHANGE in "activate" "deactivate"
do
mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d"
cp "${RECIPE_DIR}/${PKG_NAME}_${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh"
done
4 changes: 2 additions & 2 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ source:
path: ../

build:
number: 9
number: 1

requirements:
host:
Expand Down Expand Up @@ -83,7 +83,7 @@ requirements:
- conda-forge::scikit-video
- conda-forge::seaborn
- sleap::tensorflow >=2.6.3,<2.11 # No windows GPU support for >2.10, sleap channel has 2.6.3
- conda-forge::tensorflow-hub
- conda-forge::tensorflow-hub <0.14.0 # Causes pynwb conflicts on linux GH-1446

test:
imports:
Expand Down
6 changes: 6 additions & 0 deletions .conda/sleap_activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# Remember the old library path for when we deactivate
export SLEAP_OLD_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
# Help CUDA find GPUs!
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
4 changes: 4 additions & 0 deletions .conda/sleap_deactivate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

# Reset to the old library path for when deactivating the environment
export LD_LIBRARY_PATH=$SLEAP_OLD_LD_LIBRARY_PATH
2 changes: 1 addition & 1 deletion .conda_mac/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export PIP_NO_INDEX=False
export PIP_NO_DEPENDENCIES=False
export PIP_IGNORE_INSTALLED=False

pip install -r requirements.txt
pip install --no-cache-dir -r requirements.txt

# HACK(LM): (untested) Uninstall all opencv packages and install opencv-contrib-python
conda list | grep opencv | awk '{system("pip uninstall " $1 " -y")}'
Expand Down
2 changes: 1 addition & 1 deletion .conda_mac/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ about:
summary: {{ data.get('description') }}

build:
number: 5
number: 1

source:
path: ../
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Please include information about how you installed.
- OS:
<!-- [e.g. ubuntu 20.04, macOS 11.0] -->
- Version(s):
<!-- e.g. [SLEAP v1.3.1, python 3.8] --->
<!-- e.g. [SLEAP v1.3.3, python 3.8] --->
- SLEAP installation method (listed [here](https://sleap.ai/installation.html#)):
- [ ] [Conda from package](https://sleap.ai/installation.html#conda-package)
- [ ] [Conda from source](https://sleap.ai/installation.html#conda-from-source)
Expand Down
155 changes: 155 additions & 0 deletions .github/workflows/build_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Run tests using built conda packages and wheels.
name: Build CI (no upload)

# Run when changes to pip wheel
on:
push:
paths:
- 'setup.py'
- 'requirements.txt'
- 'dev_requirements.txt'
- 'jupyter_requirements.txt'
- 'pypi_requirements.txt'
- 'environment_build.yml'
- '.github/workflows/build_ci.yml'

jobs:
build:
name: Build wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04"]
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
include:
# Use this condarc as default
- condarc: .conda/condarc.yaml
- wheel_name: sleap-wheel-linux
steps:
# Setup
- uses: actions/checkout@v2

- name: Cache conda
uses: actions/cache@v1
env:
# Increase this value to reset cache if environment_build.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment_build.yml', 'pyproject.toml') }}

- name: Setup Miniconda for Build
# https://github.com/conda-incubator/setup-miniconda
uses: conda-incubator/setup-miniconda@v2.0.1
with:
python-version: 3.7
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
environment-file: environment_build.yml
condarc-file: ${{ matrix.condarc }}
activate-environment: sleap_ci

- name: Print build environment info
shell: bash -l {0}
run: |
which python
conda list
pip freeze
# Build pip wheel
- name: Build pip wheel
shell: bash -l {0}
run: |
python setup.py bdist_wheel
# Upload artifact "tests" can use it
- name: Upload wheel artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.wheel_name }}
path: dist/*.whl
retention-days: 1

tests:
name: Run tests using wheel (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build # Ensure the build job has completed before starting this job.
strategy:
fail-fast: false
matrix:
os: ["ubuntu-22.04", "windows-2022", "macos-latest"]
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
include:
# Default values
- wheel_name: sleap-wheel-linux
- venv_cmd: source venv/bin/activate
- pip_cmd: |
wheel_path=$(find dist -name "*.whl")
echo $wheel_path
pip install '$wheel_path'[dev]
- test_args: pytest --durations=-1 tests/
- condarc: .conda/condarc.yaml
# Use special condarc if macos
- os: "macos-latest"
condarc: .conda_mac/condarc.yaml
# Ubuntu specific values
- os: ubuntu-22.04
# Otherwise core dumped in github actions
test_args: |
sudo apt install xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0
sudo Xvfb :1 -screen 0 1024x768x24 </dev/null &
export DISPLAY=":1"
pytest tests -k 'not exclude_from_linux_pip_test'
# Windows specific values
- os: windows-2022
venv_cmd: .\venv\Scripts\activate

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7

# Download wheel
- name: Download wheel artifact
uses: actions/download-artifact@v3
id: download
with:
name: ${{ matrix.wheel_name }}
path: dist

- name: Create virtual environment
run: python -m venv venv

- name: Activate virtual environment
run: ${{ matrix.venv_cmd }}

- name: Install the built wheel (not Mac)
if: runner.os != 'macOS'
shell: bash -l {0}
run: |
wheel_path=$(find dist -name "*.whl")
echo wheel_path
pip install "$wheel_path"[dev]
- name: Install the built wheel (Mac)
if: runner.os == 'macOS'
shell: bash -e {0}
run: |
wheel_path=$(find dist -name "*.whl")
echo wheel_path
pip install "$wheel_path"[dev]
- name: Print test environment info
shell: bash -l {0}
run: |
which python
pip freeze
# Install and test the wheel
- name: Test the built wheel
run: |
${{ matrix.test_args}}
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
# 'main' triggers updates to 'sleap.ai', all others to 'sleap.ai/develop'
- main
- develop
- liezl/update_installation_docs
- liezl/add-pip-extras
paths:
- "docs/**"
- "README.rst"
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Quick install

.. code-block:: bash
pip install sleap
pip install sleap[pypi]
See the docs for `full installation instructions <https://sleap.ai/installation.html>`_.
Expand Down
2 changes: 0 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ black==21.6b0
pre-commit
twine==3.3.0
PyGithub
jupyterlab
jedi==0.17.2
ipykernel
click==8.0.4
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
import os
import sys
import shutil
import docs.utils
from datetime import date

sys.path.insert(0, os.path.abspath(".."))
import docs.utils


# -- Project information -----------------------------------------------------
Expand All @@ -28,15 +28,15 @@
copyright = f"2019–{date.today().year}, Talmo Lab"

# The short X.Y version
version = "1.3.1"
version = "1.3.3"

# Get the sleap version
# with open("../sleap/version.py") as f:
# version_file = f.read()
# version = re.search("\d.+(?=['\"])", version_file).group(0)

# Release should be the full branch name
release = "v1.3.1"
release = "v1.3.3"

html_title = f"SLEAP ({release})"
html_short_title = "SLEAP"
Expand Down
Loading

0 comments on commit 348a656

Please sign in to comment.