Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Feb 22, 2023
1 parent 7f17a57 commit ec78af2
Show file tree
Hide file tree
Showing 29 changed files with 702 additions and 500 deletions.
59 changes: 59 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
default_stages: [commit, push]
exclude: (^.github/|^docs/|^images/|^notebooks/py_scripts/|^tests/)
# Current tests/__init__ violates many flake8. Excluding pending change to conftest

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files # prevent giant files from being committed
- id: requirements-txt-fixer
- id: mixed-line-ending
args: ["--fix=lf"]
description: Forces to replace line ending by the UNIX 'lf' character.

# black
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- id: black-jupyter
args:
- --line-length=88

# isort
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
description: Sorts imports in an alphabetical order

# flake8
- repo: https://github.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
args: # arguments to configure flake8
# making isort line length compatible with black
- "--max-line-length=88"
- "--max-complexity=18"
- "--select=B,C,E,F,W,T4,B9"

# these are errors that will be ignored by flake8
# https://www.flake8rules.com/rules/{code}.html
- "--ignore=E203,E501,W503,W605,E402"
# E203 - Colons should not have any space before them.
# Needed for list indexing
# E501 - Line lengths are recommended to be no greater than 79 characters.
# Needed as we conform to 88
# W503 - Line breaks should occur after the binary operator.
# Needed because not compatible with black
# W605 - a backslash-character pair that is not a valid escape sequence now
# generates a DeprecationWarning. This will eventually become a SyntaxError.
# Needed because we use \d as an escape sequence
# E402 - Place module level import at the top.
# Needed to prevent circular import error
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DataJoint Workflow - Calcium Imaging

Workflow for calcium imaging data acquired with
[ScanImage](http://scanimage.vidriotechnologies.com),
[ScanImage](http://scanimage.vidriotechnologies.com),
[Scanbox](https://scanbox.org), or `Nikon NIS` software and processed with
[Suite2p](https://github.com/MouseLand/suite2p) or
[CaImAn](https://github.com/flatironinstitute/CaImAn).
Expand Down
6 changes: 3 additions & 3 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ COPY ./workflow-calcium-imaging/docker/apt_requirements.txt /tmp/
RUN /entrypoint.sh echo "Installed dependencies."

# Install Caiman
RUN git clone --branch master https://github.com/datajoint-company/CaImAn
RUN git clone --branch master https://github.com/datajoint-company/CaImAn
WORKDIR /main/CaImAn
RUN conda install -n base -c conda-forge -y mamba
RUN /bin/bash -c 'mamba env update --n base --file environment.yml'
RUN /bin/bash -c 'mamba env update --n base --file environment.yml'
# Suite2p requires np.__version__ == 1.21
RUN pip install numpy==1.21
RUN pip install .
Expand Down Expand Up @@ -42,4 +42,4 @@ RUN pip install -r /main/workflow-calcium-imaging/requirements_test.txt

WORKDIR /main/workflow-calcium-imaging

ENTRYPOINT ["tail", "-f", "/dev/null"]
ENTRYPOINT ["tail", "-f", "/dev/null"]
6 changes: 3 additions & 3 deletions docker/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ COPY ./workflow-calcium-imaging/docker/apt_requirements.txt /tmp/
RUN /entrypoint.sh echo "Installed dependencies."

# Install Caiman
RUN git clone --branch master https://github.com/datajoint-company/CaImAn
RUN git clone --branch master https://github.com/datajoint-company/CaImAn
WORKDIR /main/CaImAn
RUN conda install -n base -c conda-forge -y mamba
RUN /bin/bash -c 'mamba env update --n base --file environment.yml'
RUN /bin/bash -c 'mamba env update --n base --file environment.yml'
# Suite2p requires np.__version__ == 1.21
RUN pip install numpy==1.21
RUN pip install .
Expand Down Expand Up @@ -54,4 +54,4 @@ RUN rm -f /main/workflow-calcium-imaging/dj_local_conf.json
RUN pip install /main/workflow-calcium-imaging
RUN pip install -r /main/workflow-calcium-imaging/requirements_test.txt

WORKDIR /main/workflow-calcium-imaging
WORKDIR /main/workflow-calcium-imaging
8 changes: 4 additions & 4 deletions docker/apt_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
git
gcc
g++
ffmpeg
g++
gcc
git
libhdf5-dev
libsm6
libxext6
libhdf5-dev
pkg-config
12 changes: 9 additions & 3 deletions notebooks/00-data-download-optional.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"source": [
"import os\n",
"import djarchive_client\n",
"\n",
"client = djarchive_client.client()"
]
},
Expand Down Expand Up @@ -90,7 +91,7 @@
"metadata": {},
"outputs": [],
"source": [
"mkdir /tmp/example_data"
"mkdir / tmp / example_data"
]
},
{
Expand All @@ -107,7 +108,8 @@
"outputs": [],
"source": [
"from workflow_calcium_imaging import version\n",
"revision = version.__version__.replace('.', '_')\n",
"\n",
"revision = version.__version__.replace(\".\", \"_\")\n",
"revision"
]
},
Expand All @@ -124,7 +126,11 @@
"metadata": {},
"outputs": [],
"source": [
"client.download('workflow-calcium-imaging-test-set', target_directory='/tmp/example_data', revision=revision)"
"client.download(\n",
" \"workflow-calcium-imaging-test-set\",\n",
" target_directory=\"/tmp/example_data\",\n",
" revision=revision,\n",
")"
]
},
{
Expand Down
11 changes: 7 additions & 4 deletions notebooks/01-configure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"outputs": [],
"source": [
"import os\n",
"if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")\n",
"\n",
"if os.path.basename(os.getcwd()) == \"notebooks\":\n",
" os.chdir(\"..\")\n",
"import datajoint as dj"
]
},
Expand Down Expand Up @@ -49,7 +51,8 @@
"outputs": [],
"source": [
"import getpass\n",
"dj.config[\"database.host\"] = \"{YOUR_HOST}\" # CodeBook users should omit this\n",
"\n",
"dj.config[\"database.host\"] = \"{YOUR_HOST}\" # CodeBook users should omit this\n",
"dj.config[\"database.user\"] = \"{YOUR_USERNAME}\"\n",
"dj.config[\"database.password\"] = getpass.getpass() # enter the password securely"
]
Expand Down Expand Up @@ -145,8 +148,8 @@
"metadata": {},
"outputs": [],
"source": [
"dj.config['custom']['imaging_root_data_dir'] = '/tmp/example_data' # local download\n",
"dj.config['custom']['imaging_root_data_dir'] = '/home/inbox/0_1_0a2/' # on CodeBook"
"dj.config[\"custom\"][\"imaging_root_data_dir\"] = \"/tmp/example_data\" # local download\n",
"dj.config[\"custom\"][\"imaging_root_data_dir\"] = \"/home/inbox/0_1_0a2/\" # on CodeBook"
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion notebooks/02-workflow-structure-optional.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"outputs": [],
"source": [
"import os\n",
"if os.path.basename(os.getcwd()) == \"notebooks\": os.chdir(\"..\")"
"\n",
"if os.path.basename(os.getcwd()) == \"notebooks\":\n",
" os.chdir(\"..\")"
]
},
{
Expand Down
Loading

0 comments on commit ec78af2

Please sign in to comment.