Skip to content

Commit 4c67940

Browse files
authored
helpers & actions & more docs! (#2)
* Create codespell.yml * Create publish-book.yml * Create .gitignore * Create StyleGuide.md * Update _toc.yml * Update StyleGuide.md - typo * Update _toc.yml * Update README.md
1 parent 9ab5aec commit 4c67940

File tree

6 files changed

+359
-3
lines changed

6 files changed

+359
-3
lines changed

.github/workflows/codespell.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Codespell
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
codespell:
12+
name: Check for spelling errors
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
- name: Annotate locations with typos
19+
uses: codespell-project/codespell-problem-matcher@v1
20+
- name: Codespell
21+
uses: codespell-project/actions-codespell@v2

.github/workflows/publish-book.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: publish-book
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy-book:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python 3.10
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.10"
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip setuptools
22+
python -m pip install .[docs]
23+
pip install jupyter-book sphinxcontrib-mermaid
24+
25+
- name: Build the book
26+
run: |
27+
jupyter-book build .
28+
29+
- name: GitHub Pages action
30+
uses: peaceiris/[email protected]
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
publish_dir: ./_build/html

.gitignore

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# Abstra
171+
# Abstra is an AI-powered process automation framework.
172+
# Ignore directories containing user credentials, local state, and settings.
173+
# Learn more at https://abstra.io/docs
174+
.abstra/
175+
176+
# Visual Studio Code
177+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
178+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
179+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
180+
# you could uncomment the following to ignore the enitre vscode folder
181+
# .vscode/
182+
183+
# Ruff stuff:
184+
.ruff_cache/
185+
186+
# PyPI configuration file
187+
.pypirc
188+
189+
# Cursor
190+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
191+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
192+
# refer to https://docs.cursor.com/context/ignore-files
193+
.cursorignore
194+
.cursorindexingignore

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
# Code Guidelines
2+
# Code & Data Guidelines
33

4-
The hub for discussions and best practices on code management! The goal is someone can fork/clone this repo and start a new project easily. This was written by Mackenzie Mathis, and I thank my lab and the open-source community for many lessons learned.
4+
The is a hub for discussions and best practices on code management! The goal is someone can fork/clone this [template repo](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-template-repository) and start a new project easily. This was written by Mackenzie Mathis, and I thank my lab and the open-source community for many lessons learned.
55

66
## Overview
77

@@ -84,6 +84,12 @@ project_name/
8484

8585
* [DataJoint](https://www.datajoint.com/) examples for managing and querying scientific data pipelines - these are a must; use minimally for data + meta data storage, and use it to automate things you do daily (preprocessing, running DeepLabCut, etc!)
8686
* [Templates for common workflows and schema management are here!](https://docs.datajoint.com/elements/)
87+
88+
89+
7. **Style Guide for overall code & project management**
90+
91+
* Tips and practices for code, manuscripts, and figures.
92+
8793

8894
---
8995

_toc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
format: jb-book
2-
root: README
2+
root: docs/StyleGuide
33
parts:
44
- caption: Main Documentation
55
chapters:
6+
- file: README
67
- file: docs/HowTo_JupyterBook
78
- file: docs/Learning_reseources

docs/StyleGuide.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Style Guide for Projects in the MLAI
2+
3+
4+
## Well before a publication:
5+
6+
Please see our overall guide on code & project formatting [here](https://github.com/AdaptiveMotorControlLab/WorkspaceTemplate/blob/main/README.md).
7+
8+
### Main Principles 🔨 Organize your code & data :
9+
- For experimental and ML projects, please use [DataJoint/databases](https://www.datajoint.com/)
10+
- Be sure you work under a lab repo, typically called "https://github.com/AdaptiveMotorControlLab/YourName_workspace".
11+
- For larger projects (DLC, CEBRA, ExperimentalPipelines, you should be sure your "final" work gets into a pipeline; talk to Mackenzie about this)
12+
- Lab Specific: please check the [CommonHelperCode](https://github.com/AdaptiveMotorControlLab/CommonHelperCode) for useful tips & scripts, and contribute your own!
13+
14+
### Main Principles 🚧 Format your code & documentation:
15+
- In the lab we use the [Google Style Guide](https://google.github.io/styleguide/pyguide.html) for code. Please review this.
16+
- In the lab we use the [semantic versioning of code](https://semver.org/). Please review this.
17+
- In the lab we use the code formatting we outline in the main README [here](https://github.com/AdaptiveMotorControlLab/WorkspaceTemplate/blob/main/README.md).
18+
- As soon as you start a repo, start a JupterBook! Please see [here](https://github.com/AdaptiveMotorControlLab/WorkspaceTemplate/blob/main/README.md), and this repo has the template.
19+
20+
21+
22+
## Ready to write up your work and share your hard work, data, & code?
23+
Here is how to do so most efficiently with me.
24+
25+
- 🚨 First, I recommend having a one-on-one so we can lay out the paper sketch, authors, data and code sharing plan together if not already done.
26+
- 📝 I ask that we use [overleaf](https://www.overleaf.com/project) for **manuscripts**! Please ask me to start a template to share with you.
27+
- 🗺 I ask we use [figma](https://www.figma.com/) for **figures**; you can start a free educational group (or ask me to start one). Please then link this in the paper basecamp group.
28+
- If you have a deadline (ICCV/NeurIPS, etc), you must have everything ready **1 week before the deadline** and schedule a meeting to go over it (see Timeline below).
29+
30+
### How to organize this all with Basecamp:
31+
- 🔗 Please link the development code repo code in basecamp
32+
- 🔗 Please link the overleaf
33+
- 🔗 Please link the figma file
34+
35+
Collectively, your basecamp project should look like this:
36+
![demo](https://github.com/user-attachments/assets/e21bdee1-ede6-4463-a65f-0d1dff3d224f)
37+
38+
39+
40+
## Styles for plots, figures, and how to produce them
41+
- We use `matplotlib` and `seaborn` in python.
42+
- **Every plot in a paper must be reproducible in a Jupyter Notebook**. This means it loads the data (from datajoint/ possible later figshare or zenodo), plots it, and saves it.
43+
- By the time we are ready to submit a paper, it must have a `AMCL\PaperName-figures` repo.
44+
- Here are examples from the lab:
45+
- CellSeg3D: https://github.com/C-Achard/cellseg3d-figures
46+
- CEBRA: https://github.com/AdaptiveMotorControlLab/CEBRA-demos
47+
- I really like the plots in [CEBRA](https://www.nature.com/articles/s41586-023-06031-6), which you can find here: https://github.com/AdaptiveMotorControlLab/cebra-figures
48+
49+
### Example plotting style:
50+
- Here is an example, be sure to note the **font, size, broken axis, transparency output**, etc:
51+
52+
```python
53+
plt.figure(figsize=(3.5, 3.5), dpi = 200)
54+
ax = plt.subplot(111)
55+
56+
keys = ['cebra', 'pivae', 'autolfads', 'tsne', 'umap']
57+
df = pd.DataFrame(synthetic_scores)
58+
sns.stripplot(data=df[keys] * 100, color="black", s=3, zorder=1, jitter=0.15)
59+
sns.scatterplot(data=df[keys].median() * 100, color="orange", s=50)
60+
plt.ylabel("$R^2$", fontsize=20)
61+
plt.yticks(
62+
np.linspace(0, 100, 11, dtype=int), np.linspace(0, 100, 11, dtype=int), fontsize=20
63+
)
64+
plt.ylim(70, 100)
65+
ax.spines["right"].set_visible(False)
66+
ax.spines["top"].set_visible(False)
67+
ax.tick_params(axis="both", which="major", labelsize=15)
68+
ax.tick_params(axis = 'x', rotation = 45)
69+
ax.set_xticklabels(
70+
['CEBRA', 'piVAE', 'autoLFADS', 'tSNE', 'UMAP'],
71+
)
72+
sns.despine(
73+
left=False,
74+
right=True,
75+
bottom=False,
76+
top=True,
77+
trim=True,
78+
offset={"bottom": 40, "left": 15},
79+
)
80+
plt.savefig('figure1_synthetic_comparison.jpg', bbox_inches = "tight", transparent = True)
81+
plt.savefig('figure1_synthetic_comparison.svg', bbox_inches = "tight", transparent = True)
82+
```
83+
#### THEN: 🚨 Put the SVG into figma, AND for the final versions, make a white axis page & versions 🙏:
84+
85+
Modify by adding:
86+
```python
87+
for spine in ax.spines.values():
88+
spine.set_color("white")
89+
ax.tick_params(colors="white")
90+
ax.yaxis.label.set_color("white")
91+
ax.xaxis.label.set_color("white")
92+
```
93+
94+
95+
### Timeline Major Point:
96+
97+
For conference submissions, all papers must be in final form 1 week prior to the deadline.
98+
There will be no exceptions going forward.
99+
This gives us needed time to reflect, refine writing, get some distance, and ask colleagues for feedback.
100+
It also gives us time to prepare the code submission, and potentially arXiv the work -- which is always preferred.
101+
We should not be submitting manuscripts to conferences we would not want publicly read!

0 commit comments

Comments
 (0)