Skip to content

Commit

Permalink
Merge pull request #13 from kushalbakshi/main
Browse files Browse the repository at this point in the history
Add Codespaces tutorial + general updates to the Element
  • Loading branch information
Thinh Nguyen authored Jan 19, 2024
2 parents 1cc2699 + d2366d0 commit f9ce4c2
Show file tree
Hide file tree
Showing 25 changed files with 3,192 additions and 225 deletions.
47 changes: 47 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
FROM python:3.9-slim@sha256:5f0192a4f58a6ce99f732fe05e3b3d00f12ae62e183886bca3ebe3d202686c7f

ENV PATH /usr/local/bin:$PATH
ENV PYTHON_VERSION 3.9.17

RUN \
adduser --system --disabled-password --shell /bin/bash vscode && \
# install docker
apt-get update && \
apt-get install ca-certificates curl gnupg lsb-release -y && \
mkdir -m 0755 -p /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
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 && \
apt-get update && \
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y && \
usermod -aG docker vscode && \
apt-get clean

RUN \
# dev setup
apt update && \
apt-get install sudo git bash-completion graphviz default-mysql-client s3fs procps -y && \
usermod -aG sudo vscode && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
pip install --no-cache-dir --upgrade black pip nbconvert && \
echo '. /etc/bash_completion' >> /home/vscode/.bashrc && \
echo 'export PS1="\[\e[32;1m\]\u\[\e[m\]@\[\e[34;1m\]\H\[\e[m\]:\[\e[33;1m\]\w\[\e[m\]$ "' >> /home/vscode/.bashrc && \
apt-get clean

COPY ./ /tmp/element-optogenetics/

RUN \
# pipeline dependencies
apt-get install gcc g++ ffmpeg libsm6 libxext6 -y && \
pip install --no-cache-dir -e /tmp/element-optogenetics[elements,tests] && \
# clean up
rm -rf /tmp/element-optogenetics && \
apt-get clean

ENV DJ_HOST fakeservices.datajoint.io
ENV DJ_USER root
ENV DJ_PASS simple

ENV DATABASE_PREFIX neuro_

USER vscode
CMD bash -c "sudo rm /var/run/docker.pid; sudo dockerd"
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "Environment + Data",
"dockerComposeFile": "docker-compose.yaml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
},
"onCreateCommand": "pip install -e .",
"postStartCommand": "docker volume prune -f",
"hostRequirements": {
"cpus": 4,
"memory": "8gb",
"storage": "32gb"
},
"forwardPorts": [
3306
],
"customizations": {
"settings": {
"python.pythonPath": "/usr/local/bin/python"
},
"vscode": {
"extensions": [
"[email protected]",
"[email protected]"
]
}
}
}
23 changes: 23 additions & 0 deletions .devcontainer/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3"
services:
app:
cpus: 4
mem_limit: 8g
build:
context: ..
dockerfile: ./.devcontainer/Dockerfile
# image: datajoint/element_optogenetics:latest
extra_hosts:
- fakeservices.datajoint.io:127.0.0.1
devices:
- /dev/fuse
cap_add:
- SYS_ADMIN
security_opt:
- apparmor:unconfined
volumes:
- ..:/workspaces/element-optogenetics:cached
- docker_data:/var/lib/docker # persist docker images
privileged: true # only because of dind
volumes:
docker_data:
19 changes: 19 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release
on:
workflow_dispatch:
jobs:
make_github_release:
uses: datajoint/.github/.github/workflows/make_github_release.yaml@main
mkdocs_release:
uses: datajoint/.github/.github/workflows/mkdocs_release.yaml@main
permissions:
contents: write
devcontainer-build:
uses: datajoint/.github/.github/workflows/devcontainer-build.yaml@main
devcontainer-publish:
needs:
- devcontainer-build
uses: datajoint/.github/.github/workflows/devcontainer-publish.yaml@main
secrets:
DOCKERHUB_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
DOCKERHUB_TOKEN: ${{secrets.DOCKERHUB_TOKEN_FOR_ELEMENTS}}
34 changes: 34 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test
on:
push:
pull_request:
workflow_dispatch:
jobs:
devcontainer-build:
uses: datajoint/.github/.github/workflows/devcontainer-build.yaml@main
tests:
runs-on: ubuntu-latest
strategy:
matrix:
py_ver: ["3.9", "3.10"]
mysql_ver: ["8.0", "5.7"]
include:
- py_ver: "3.8"
mysql_ver: "5.7"
- py_ver: "3.7"
mysql_ver: "5.7"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{matrix.py_ver}}
uses: actions/setup-python@v4
with:
python-version: ${{matrix.py_ver}}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 "black[jupyter]"
- name: Run style tests
run: |
python_version=${{matrix.py_ver}}
black element_optogenetics --check --verbose --target-version py${python_version//.}
17 changes: 0 additions & 17 deletions .github/workflows/u24_element_before_release.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/u24_element_release_call.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/u24_element_tag_to_release.yaml

This file was deleted.

94 changes: 68 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# User data
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution, packaging, PyInstaller
# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
Expand All @@ -21,11 +27,17 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
.idea/

# 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*.txt
.idea/
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
Expand All @@ -37,52 +49,82 @@ nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# C extension, Translations
*.so
# Translations
*.mo
*.pot

# editors: vscode, emacs, Mac
.vscode
**/*~
**/#*#
**/.#*
.DS_Store

# Django, Flask, Scrapy, Sphinx, mkdocs:
# PyBuilder, Jupyter, SageMath, celery beat
# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy
scratchpaper.*

# Sphinx documentation
docs/_build/
/site

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv, virtualenv, pyenv, mypy
# dotenv
./.env
.env

# virtualenv
.venv
venv/
ENV/
.python-version
.mypy_cache/

# Spyder/Rope project settings
# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# datajoint, notes, nwb export
dj_local_c*.json
# mkdocs documentation
docs/site
docs/src/tutorials/*ipynb

# mypy
.mypy_cache/

# datajoint
dj_local_conf.json
dj_local_conf_old.json

# emacs
**/*~
**/#*#
**/.#*


# include
!docs/docker-compose.yaml

# vscode settings
*.code-workspace

# exports/notes
temp*
temp/*
*nwb
/docs/site
/docs/src/tutorials/*ipynb

# Codespaces
example_data/
18 changes: 18 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Markdown Linter configuration for docs
# https://github.com/DavidAnson/markdownlint
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
MD009: false # permit trailing spaces
MD007: false # List indenting - permit 4 spaces
MD013:
line_length: "88" # Line length limits
tables: false # disable for tables
headings: false # disable for headings
MD030: false # Number of spaces after a list
MD033: # HTML elements allowed
allowed_elements:
- "br"
- "figure"
- "figcaption"
MD034: false # Permit bare URLs
MD031: false # Spacing w/code blocks. Conflicts with `??? Note` and code tab styling
MD046: false # Spacing w/code blocks. Conflicts with `??? Note` and code tab styling
Loading

0 comments on commit f9ce4c2

Please sign in to comment.