Skip to content

Commit f9ce4c2

Browse files
author
Thinh Nguyen
authored
Merge pull request #13 from kushalbakshi/main
Add Codespaces tutorial + general updates to the Element
2 parents 1cc2699 + d2366d0 commit f9ce4c2

25 files changed

+3192
-225
lines changed

.devcontainer/Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM python:3.9-slim@sha256:5f0192a4f58a6ce99f732fe05e3b3d00f12ae62e183886bca3ebe3d202686c7f
2+
3+
ENV PATH /usr/local/bin:$PATH
4+
ENV PYTHON_VERSION 3.9.17
5+
6+
RUN \
7+
adduser --system --disabled-password --shell /bin/bash vscode && \
8+
# install docker
9+
apt-get update && \
10+
apt-get install ca-certificates curl gnupg lsb-release -y && \
11+
mkdir -m 0755 -p /etc/apt/keyrings && \
12+
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
13+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
14+
apt-get update && \
15+
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y && \
16+
usermod -aG docker vscode && \
17+
apt-get clean
18+
19+
RUN \
20+
# dev setup
21+
apt update && \
22+
apt-get install sudo git bash-completion graphviz default-mysql-client s3fs procps -y && \
23+
usermod -aG sudo vscode && \
24+
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
25+
pip install --no-cache-dir --upgrade black pip nbconvert && \
26+
echo '. /etc/bash_completion' >> /home/vscode/.bashrc && \
27+
echo 'export PS1="\[\e[32;1m\]\u\[\e[m\]@\[\e[34;1m\]\H\[\e[m\]:\[\e[33;1m\]\w\[\e[m\]$ "' >> /home/vscode/.bashrc && \
28+
apt-get clean
29+
30+
COPY ./ /tmp/element-optogenetics/
31+
32+
RUN \
33+
# pipeline dependencies
34+
apt-get install gcc g++ ffmpeg libsm6 libxext6 -y && \
35+
pip install --no-cache-dir -e /tmp/element-optogenetics[elements,tests] && \
36+
# clean up
37+
rm -rf /tmp/element-optogenetics && \
38+
apt-get clean
39+
40+
ENV DJ_HOST fakeservices.datajoint.io
41+
ENV DJ_USER root
42+
ENV DJ_PASS simple
43+
44+
ENV DATABASE_PREFIX neuro_
45+
46+
USER vscode
47+
CMD bash -c "sudo rm /var/run/docker.pid; sudo dockerd"

.devcontainer/devcontainer.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "Environment + Data",
3+
"dockerComposeFile": "docker-compose.yaml",
4+
"service": "app",
5+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
6+
"remoteEnv": {
7+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
8+
},
9+
"onCreateCommand": "pip install -e .",
10+
"postStartCommand": "docker volume prune -f",
11+
"hostRequirements": {
12+
"cpus": 4,
13+
"memory": "8gb",
14+
"storage": "32gb"
15+
},
16+
"forwardPorts": [
17+
3306
18+
],
19+
"customizations": {
20+
"settings": {
21+
"python.pythonPath": "/usr/local/bin/python"
22+
},
23+
"vscode": {
24+
"extensions": [
25+
26+
27+
]
28+
}
29+
}
30+
}

.devcontainer/docker-compose.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "3"
2+
services:
3+
app:
4+
cpus: 4
5+
mem_limit: 8g
6+
build:
7+
context: ..
8+
dockerfile: ./.devcontainer/Dockerfile
9+
# image: datajoint/element_optogenetics:latest
10+
extra_hosts:
11+
- fakeservices.datajoint.io:127.0.0.1
12+
devices:
13+
- /dev/fuse
14+
cap_add:
15+
- SYS_ADMIN
16+
security_opt:
17+
- apparmor:unconfined
18+
volumes:
19+
- ..:/workspaces/element-optogenetics:cached
20+
- docker_data:/var/lib/docker # persist docker images
21+
privileged: true # only because of dind
22+
volumes:
23+
docker_data:

.github/workflows/release.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
make_github_release:
6+
uses: datajoint/.github/.github/workflows/make_github_release.yaml@main
7+
mkdocs_release:
8+
uses: datajoint/.github/.github/workflows/mkdocs_release.yaml@main
9+
permissions:
10+
contents: write
11+
devcontainer-build:
12+
uses: datajoint/.github/.github/workflows/devcontainer-build.yaml@main
13+
devcontainer-publish:
14+
needs:
15+
- devcontainer-build
16+
uses: datajoint/.github/.github/workflows/devcontainer-publish.yaml@main
17+
secrets:
18+
DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
19+
DOCKERHUB_TOKEN: ${{secrets.DOCKERHUB_TOKEN_FOR_ELEMENTS}}

.github/workflows/test.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
jobs:
7+
devcontainer-build:
8+
uses: datajoint/.github/.github/workflows/devcontainer-build.yaml@main
9+
tests:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
py_ver: ["3.9", "3.10"]
14+
mysql_ver: ["8.0", "5.7"]
15+
include:
16+
- py_ver: "3.8"
17+
mysql_ver: "5.7"
18+
- py_ver: "3.7"
19+
mysql_ver: "5.7"
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Set up Python ${{matrix.py_ver}}
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: ${{matrix.py_ver}}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8 "black[jupyter]"
30+
- name: Run style tests
31+
run: |
32+
python_version=${{matrix.py_ver}}
33+
black element_optogenetics --check --verbose --target-version py${python_version//.}
34+

.github/workflows/u24_element_before_release.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/u24_element_release_call.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/u24_element_tag_to_release.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

.gitignore

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
# User data
2+
.DS_Store
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]
47
*$py.class
58

6-
# Distribution, packaging, PyInstaller
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
713
.Python
814
env/
915
build/
@@ -21,11 +27,17 @@ wheels/
2127
*.egg-info/
2228
.installed.cfg
2329
*.egg
30+
.idea/
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
2435
*.manifest
2536
*.spec
37+
38+
# Installer logs
2639
pip-log.txt
27-
pip-delete*.txt
28-
.idea/
40+
pip-delete-this-directory.txt
2941

3042
# Unit test / coverage reports
3143
htmlcov/
@@ -37,52 +49,82 @@ nosetests.xml
3749
coverage.xml
3850
*.cover
3951
.hypothesis/
40-
.pytest_cache/
4152

42-
# C extension, Translations
43-
*.so
53+
# Translations
4454
*.mo
4555
*.pot
4656

47-
# editors: vscode, emacs, Mac
48-
.vscode
49-
**/*~
50-
**/#*#
51-
**/.#*
52-
.DS_Store
53-
54-
# Django, Flask, Scrapy, Sphinx, mkdocs:
55-
# PyBuilder, Jupyter, SageMath, celery beat
57+
# Django stuff:
5658
*.log
5759
local_settings.py
60+
61+
# Flask stuff:
5862
instance/
5963
.webassets-cache
64+
65+
# Scrapy stuff:
6066
.scrapy
6167
scratchpaper.*
68+
69+
# Sphinx documentation
6270
docs/_build/
63-
/site
71+
72+
# PyBuilder
6473
target/
74+
75+
# Jupyter Notebook
6576
.ipynb_checkpoints
77+
78+
# pyenv
79+
.python-version
80+
81+
# celery beat schedule file
6682
celerybeat-schedule
83+
84+
# SageMath parsed files
6785
*.sage.py
6886

69-
# dotenv, virtualenv, pyenv, mypy
87+
# dotenv
7088
./.env
89+
.env
90+
91+
# virtualenv
7192
.venv
7293
venv/
7394
ENV/
74-
.python-version
75-
.mypy_cache/
7695

77-
# Spyder/Rope project settings
96+
# Spyder project settings
7897
.spyderproject
7998
.spyproject
99+
100+
# Rope project settings
80101
.ropeproject
81102

82-
# datajoint, notes, nwb export
83-
dj_local_c*.json
103+
# mkdocs documentation
104+
docs/site
105+
docs/src/tutorials/*ipynb
106+
107+
# mypy
108+
.mypy_cache/
109+
110+
# datajoint
111+
dj_local_conf.json
112+
dj_local_conf_old.json
113+
114+
# emacs
115+
**/*~
116+
**/#*#
117+
**/.#*
118+
119+
120+
# include
121+
!docs/docker-compose.yaml
122+
123+
# vscode settings
124+
*.code-workspace
125+
126+
# exports/notes
84127
temp*
85-
temp/*
86-
*nwb
87-
/docs/site
88-
/docs/src/tutorials/*ipynb
128+
129+
# Codespaces
130+
example_data/

.markdownlint.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Markdown Linter configuration for docs
2+
# https://github.com/DavidAnson/markdownlint
3+
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
4+
MD009: false # permit trailing spaces
5+
MD007: false # List indenting - permit 4 spaces
6+
MD013:
7+
line_length: "88" # Line length limits
8+
tables: false # disable for tables
9+
headings: false # disable for headings
10+
MD030: false # Number of spaces after a list
11+
MD033: # HTML elements allowed
12+
allowed_elements:
13+
- "br"
14+
- "figure"
15+
- "figcaption"
16+
MD034: false # Permit bare URLs
17+
MD031: false # Spacing w/code blocks. Conflicts with `??? Note` and code tab styling
18+
MD046: false # Spacing w/code blocks. Conflicts with `??? Note` and code tab styling

0 commit comments

Comments
 (0)