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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
projects/
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.8
hooks:
# Run the linter.
- id: ruff
args: [--select, "E1,E4,F,I,W", --extend-ignore, "W5,W6,F841,W291", --fix, --line-length, "92"]
types:
- python
# Run the formatter.
- id: ruff-format
types:
- python
67 changes: 38 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,42 @@ environment and separate from `bnd`.
# Miniconda
$ curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe -o miniconda.exe; Start-Process -FilePath ".\miniconda.exe" -ArgumentList "/S" -Wait; del miniconda.exe
```
3. Clone repo and navigate to folder:
```shell
git clone git@github.com:BeNeuroLab/beneuro_pose_estimation.git
cd ./beneuro_pose_estimation
```
4. Creating the conda environment

```shell
conda create -y -n bnp -c conda-forge -c nvidia -c sleap/label/dev -c sleap -c anaconda sleap=1.4.1

# Activate the Conda environment
conda activate bnp

# Remove opencv pypi version to avoid conflicts
pip uninstall -y opencv-python-headless

# Install the required version of OpenCV
pip install "opencv-contrib-python<4.7.0"

# Install sleap_anipose and the required version of anipose
pip install sleap_anipose
pip install "anipose<1.1"

# Upgrade apptools to the latest version
pip install --upgrade apptools

# Install package in editable form
pip install -e .\ # Windows
```

3. Creating the conda environment

This seems to be working:
```shell
# Create the environment called bnp and install sleap
$ conda create -y -n bnp -c conda-forge -c nvidia -c sleap -c anaconda sleap
$ conda activate bnp

# Remove opencv pypi version because it conflicts with sleap-anipose and anipose
$ pip uninstall -y opencv-python-headless

# Install required version
$ pip install "opencv-contrib-python<4.7.0"

# Install sleap anipose and anipose version 1.0 because we cannot use 1.1
$ pip install sleap_anipose
$ pip install "anipose<1.1"
$ pip install --upgrade apptools
```

The key package versions are:
```text
# Name Version Build Channel
anipose 1.0.1 pypi_0 pypi
aniposelib 0.5.1 pypi_0 pypi
sleap-anipose 0.1.8 pypi_0 pypi
opencv-contrib-python 4.6.0.66 pypi_0 pypi
opencv-python 4.10.0.84 pypi_0 pypi
```
The key package versions are:
```text
# Name Version Build Channel
anipose 1.0.1 pypi_0 pypi
aniposelib 0.5.1 pypi_0 pypi
sleap-anipose 0.1.8 pypi_0 pypi
opencv-contrib-python 4.6.0.66 pypi_0 pypi
opencv-python 4.10.0.84 pypi_0 pypi
```
64 changes: 38 additions & 26 deletions beneuro_pose_estimation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
"""
Initialize macro variables and functions
"""
import logging
from pathlib import Path

from rich.logging import RichHandler

def set_logging(file_path = None, overwrite = True):
frmt = '%(asctime)s - %(levelname)s - %(message)s'

if file_path is not None:
file_path = Path(file_path)
if overwrite is True and file_path.exists() is True:
file_path.unlink()
logging.basicConfig(
filename=file_path,
level=logging.INFO,
format=frmt,
datefmt='%Y-%m-%d %H:%M:%S'
)
else:
logging.basicConfig(
handlers=[RichHandler(level="NOTSET")],
level=logging.INFO,
format=frmt, datefmt='%Y-%m-%d %H:%M:%S'
)
import warnings


# Create a logger for the package
def set_logging(
file_name: str,
) -> logging.Logger:
"""
Set project-wide logging

Parameters
----------
file_name: str
Name of the module being logged

Returns
-------
logger: logging.Logger
logger object
"""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
logging.captureWarnings(True)

logger = logging.getLogger(file_name)

def custom_warning_handler(
message, category, filename, lineno, file=None, line=None
):
logger.warning(f"{category.__name__}: {message}")

# Set the custom handler
warnings.showwarning = custom_warning_handler

return logger
Loading
Loading