Skip to content

Commit

Permalink
Add from cookiecutter-my-lab-to-nwb-template
Browse files Browse the repository at this point in the history
  • Loading branch information
weiglszonja committed Jul 24, 2024
1 parent 12f82af commit 7b73c4a
Show file tree
Hide file tree
Showing 20 changed files with 656 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/add-to-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Add Issue or Pull Request to Dashboard

on:
issues:
types:
- opened
pull_request:
types:
- opened

jobs:
add-to-project:
name: Add issue or pull request to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
project-url: https://github.com/orgs/catalystneuro/projects/3
github-token: ${{ secrets.PROJECT_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/auto-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# For the template repo, we simply won't specify a PYPI token. We also won't do any actual releases.
# For your actual conversion project using this template, add the PYPI_API_TOKEN to your secrets.

name: Upload Package to PyPI

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

name: Installation
on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *" # First day of the month

jobs:
run:
name: Installation on (${{ matrix.os }} with Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow --tags
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pip
run: |
python -m pip install --upgrade pip
pip3 install packaging
- name: Install package
run: pip install -e .
- name: Test module load
run: python -c "import constantinople_lab_to_nwb"

149 changes: 149 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder repo_name settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# vscode
.vscode/*
.vscode/settings.json
.vscode/tasks.json
.vscode/launch.json
.vscode/extensions.json
*.code-workspace

# pycharm
.idea/*

# Local History for Visual Studio Code
.history/

#Mac
.DS_Store

# NWB files
**.nwb
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
exclude: ^docs/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 CatalystNeuro
Copyright (c) 2020 CatalystNeuro

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include *.yml
include *.json
include *.txt
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# constantinople-lab-to-nwb
NWB conversion scripts for Constantinople lab data to the [Neurodata Without Borders](https://nwb-overview.readthedocs.io/) data format.


## Installation
## Basic installation

You can install the latest release of the package with pip:

```
pip install constantinople-lab-to-nwb
```

We recommend that you install the package inside a [virtual environment](https://docs.python.org/3/tutorial/venv.html). A simple way of doing this is to use a [conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html) from the `conda` package manager ([installation instructions](https://docs.conda.io/en/latest/miniconda.html)). Detailed instructions on how to use conda environments can be found in their [documentation](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).

### Running a specific conversion
Once you have installed the package with pip, you can run any of the conversion scripts in a notebook or a python file:

https://github.com/catalystneuro/constantinople-lab-to-nwb//tree/main/src/schierek_embargo_2024/schierek_embargo_2024_convert_session.py




## Installation from Github
Another option is to install the package directly from Github. This option has the advantage that the source code can be modifed if you need to amend some of the code we originally provided to adapt to future experimental differences. To install the conversion from GitHub you will need to use `git` ([installation instructions](https://github.com/git-guides/install-git)). We also recommend the installation of `conda` ([installation instructions](https://docs.conda.io/en/latest/miniconda.html)) as it contains all the required machinery in a single and simple instal

From a terminal (note that conda should install one in your system) you can do the following:

```
git clone https://github.com/catalystneuro/constantinople-lab-to-nwb
cd constantinople-lab-to-nwb
conda env create --file make_env.yml
conda activate constantinople-lab-to-nwb-env
```

This creates a [conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html) which isolates the conversion code from your system libraries. We recommend that you run all your conversion related tasks and analysis from the created environment in order to minimize issues related to package dependencies.

Alternatively, if you want to avoid conda altogether (for example if you use another virtual environment tool) you can install the repository with the following commands using only pip:

```
git clone https://github.com/catalystneuro/constantinople-lab-to-nwb
cd constantinople-lab-to-nwb
pip install -e .
```

Note:
both of the methods above install the repository in [editable mode](https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs).

### Running a specific conversion
To run a specific conversion, you might need to install first some conversion specific dependencies that are located in each conversion directory:
```
pip install -r src/constantinople_lab_to_nwb/schierek_embargo_2024/schierek_embargo_2024_requirements.txt
```

You can run a specific conversion with the following command:
```
python src/constantinople_lab_to_nwb/schierek_embargo_2024/schierek_embargo_2024_convert_session.py
```

## Repository structure
Each conversion is organized in a directory of its own in the `src` directory:

constantinople-lab-to-nwb/
├── LICENSE
├── make_env.yml
├── pyproject.toml
├── README.md
├── requirements.txt
├── setup.py
└── src
├── constantinople_lab_to_nwb
│ ├── conversion_directory_1
│ └── schierek_embargo_2024
│ ├── schierek_embargo_2024_behaviorinterface.py
│ ├── schierek_embargo_2024_convert_session.py
│ ├── schierek_embargo_2024_metadata.yml
│ ├── schierek_embargo_2024_nwbconverter.py
│ ├── schierek_embargo_2024_requirements.txt
│ ├── schierek_embargo_2024_notes.md

│ └── __init__.py
│ ├── conversion_directory_b

└── __init__.py

For example, for the conversion `schierek_embargo_2024` you can find a directory located in `src/constantinople-lab-to-nwb/schierek_embargo_2024`. Inside each conversion directory you can find the following files:

* `schierek_embargo_2024_convert_sesion.py`: this script defines the function to convert one full session of the conversion.
* `schierek_embargo_2024_requirements.txt`: dependencies specific to this conversion.
* `schierek_embargo_2024_metadata.yml`: metadata in yaml format for this specific conversion.
* `schierek_embargo_2024_behaviorinterface.py`: the behavior interface. Usually ad-hoc for each conversion.
* `schierek_embargo_2024_nwbconverter.py`: the place where the `NWBConverter` class is defined.
* `schierek_embargo_2024_notes.md`: notes and comments concerning this specific conversion.

The directory might contain other files that are necessary for the conversion but those are the central ones.
9 changes: 9 additions & 0 deletions make_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: constantinople_lab_to_nwb_env
channels:
- conda-forge
- defaults
dependencies:
- python>=3.9
- pip
- pip:
- -e . # This calls the setup and therefore requirements minimal
Loading

0 comments on commit 7b73c4a

Please sign in to comment.