Skip to content

Commit 9ab5aec

Browse files
authored
hello world
1 parent cf10d51 commit 9ab5aec

File tree

12 files changed

+340
-0
lines changed

12 files changed

+340
-0
lines changed

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
2+
# Code Guidelines
3+
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.
5+
6+
## Overview
7+
8+
This repository is a work-in-progress template for structuring coding projects with clean, reproducible, and collaborative workflows. It includes tools and practices that streamline development, documentation, testing, and deployment.
9+
10+
### Core Components
11+
12+
1. **Code Organization**
13+
14+
* Make a clear folder structure for modules, tests, and configs; try to keep this across project/s
15+
* Naming conventions and modular design principles, [here are useful standards](https://dmeg.cessda.eu/Data-Management-Expert-Guide/2.-Organise-Document/File-naming-and-folder-structure) to consider.
16+
17+
#### Recommended Directory Structure
18+
19+
```bash
20+
project_name/
21+
├── README.md
22+
├── LICENSE
23+
├── pyproject.toml
24+
├── setup.cfg
25+
├── .gitignore
26+
├── .pre-commit-config.yaml
27+
├── _toc.yml
28+
├── docker/
29+
│ └── Dockerfile
30+
├── examples/
31+
│ └── basic_usage.ipynb
32+
├── placeholder (project_name)/ # Main package code
33+
│ ├── __init__.py
34+
│ ├── module_example.py
35+
├── version.py
36+
│ └── utils/
37+
│ └── helpers.py
38+
├── tests/
39+
│ ├── __init__.py
40+
│ ├── test_module1.py
41+
│ └── conftest.py
42+
├── docs/ # JupyterBook documentation
43+
│ ├── _config.yml
44+
│ └── index.md
45+
└── .github/
46+
└── workflows/
47+
└── codespell.yml
48+
└── publish-book.yml
49+
```
50+
51+
2. **Documentation**
52+
53+
* [JupyterBook](https://jupyterbook.org/en/stable/intro.html) setup for comprehensive, interactive project documentation!
54+
* Here are [guidelines for writing readable and maintainable docstrings](https://www.datacamp.com/tutorial/docstrings-python) - this is as important as documentation!
55+
56+
3. **Code Formatting & Linting**
57+
58+
* Formatted code makes your life and those who use/review your code easier. Standardized formatting with tools like `black` and `isort` (see the provided `.pre-commit-config.yaml`).
59+
* [Pre-commit hooks](https://pre-commit.com/) to automate checks before pushing code! Follow their quick Guide to do this, but in short:
60+
(1) install it in your dev env
61+
```python
62+
pip install pre-commit
63+
```
64+
(2) install the git hooks:
65+
```python
66+
pre-commit install
67+
```
68+
(3) Just run it on your code BEFORE you git push:
69+
```python
70+
pre-commit run --all-files
71+
```
72+
4. **Continuous Integration**
73+
74+
* Use GitHub Actions for automated testing and code quality checks
75+
* This template repo gies you built-in `codespell`, `publish-book` and `pre-commit` validations (go to actions in your repo to follow the guidelines to set up/also chatGPT can help ;)
76+
77+
5. **Containerization**
78+
79+
* Docker setup for consistent development and deployment environments - this is not just an after thought, use Docker to develop and share your code!
80+
* Examples of `Dockerfile` and `docker-compose.yml` configurations (coming)
81+
* You are welcome/encouraged to use our containers: https://hub.docker.com/u/mmathislab
82+
83+
6. **Data Workflow Integration**
84+
85+
* [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!)
86+
* [Templates for common workflows and schema management are here!](https://docs.datajoint.com/elements/)
87+
88+
---
89+
90+
Contributions welcome as we refine this template!
91+
92+
93+
## Acknowledgement
94+
95+
Some items in this repo are adapted from [DeepLabCut](https://github.com/DeepLabCut/DeepLabCut), [CEBRA](https://cebra.ai/), and the [Mathis Lab of Adaptive Intelligence](https://github.com/orgs/AdaptiveMotorControlLab). It is under an Apache 2.0 License.

__init__.py

Whitespace-only changes.

_config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
title: DocTemplate
2+
author: MWM
3+
logo: docs/logo.png
4+
only_build_toc_files: true
5+
6+
sphinx:
7+
config:
8+
autodoc_mock_imports: list #["wx"]
9+
extra_extensions:
10+
- numpydoc
11+
12+
execute:
13+
execute_notebooks: "off"
14+
15+
html:
16+
extra_navbar: ""
17+
use_issues_button: true
18+
use_repository_button: true
19+
extra_footer: |
20+
<div>Powered by <a href="https://jupyterbook.org/">Jupyter Book</a>.</div>
21+
22+
repository:
23+
url: https://github.com/SCENE-Collaboration/Code_and_Documentation_Guidelines #change me
24+
path_to_book: docs
25+
branch: main
26+
27+
launch_buttons:
28+
colab_url: "https://colab.research.google.com/github/SCENE-Collaboration/Code_and_Documentation_Guidelines/examples/yourdemo.ipynb"

_toc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
format: jb-book
2+
root: README
3+
parts:
4+
- caption: Main Documentation
5+
chapters:
6+
- file: docs/HowTo_JupyterBook
7+
- file: docs/Learning_reseources

docs/HowTo_JupyterBook.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# What is Jupyterbook?
2+
3+
https://jupyterbook.org/en/stable/intro.html
4+
5+
6+
## Quick start
7+
- have your repo cloned and run this to generate a starting template:
8+
```python
9+
jupyter-book create --cookiecutter YourClonedRepo/
10+
```
11+
12+
### Build from the template provided
13+
14+
(1) Use and adapt the two template files (_toc.yml, _config.yml) to your main code base, and be sure to keep the `docs` structure, i.e.,
15+
```
16+
/docs
17+
├── /images
18+
│ └── logo.png # add logo here
19+
├── intro.md # main welcome page
20+
21+
```
22+
(2) write in markdown (or myst) your docs, as usual:
23+
- for an example: https://github.com/DeepLabCut/DeepLabCut/blob/mmain/docs/intro.md
24+
25+
(3) to build your docs & hosting see here: https://jupyterbook.org/en/stable/publish/gh-pages.html
26+
27+
TL;DR in the main repo run:
28+
```python
29+
❯ jupyter-book build .
30+
```
31+
and then follow terminal prompt (check errors, etc)- viola!
32+
33+
34+
To then deploy the book live, see: https://jupyterbook.org/en/stable/publish/gh-pages.html#automatically-host-your-book-with-github-actions
35+
36+
In short, you will set up a git action to deploy to a new branch (that you never merge) called `gh-pages`

docs/Learning_resources.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Learning Resources
2+
3+
Here is a growing list of resources that I've (Mackenzie M.) found useful for learning about various topics.
4+
5+
## Python
6+
7+
- [Python.org](https://www.python.org/)
8+
- [Real Python](https://realpython.com/)
9+
- [Automate the Boring Stuff with Python](https://automatetheboringstuff.com/)
10+
11+
## SQL
12+
13+
- [mySQL](https://dev.mysql.com/doc/)
14+
- [SQL Zoo](https://sqlzoo.net/)
15+
16+
## Data Science
17+
18+
- [DataJoint](https://datajoint.io/)
19+
20+
## Machine Learning
21+
22+
- [Scikit-learn](https://scikit-learn.org/)
23+
- [TensorFlow](https://www.tensorflow.org/)
24+
- [PyTorch](https://pytorch.org/)
25+
26+
## Jupyter
27+
- Dissection of Jupyter ecosystem by Chris Holdgraf https://www.youtube.com/watch?v=t0MjcXZf7SM (40 min⏰)
28+
- The Guide📙: How to make a JB basics/tips/features by Chris Holdgraf https://www.youtube.com/watch?v=lZ2FHTkyaMU (30 min⏰) - most updated video
29+
-Similar to 2 from Jupyter meets earth https://www.youtube.com/watch?v=seKOq-VMJgY (as they cover the same topic there are many duplications) updated the past 9 months (22 min⏰)
30+
- Honorary mention with features and comments from JupyterCon https://www.youtube.com/watch?v=tUDHysfzAxs (30 min⏰)
31+
- In the documentation it is important to start from the anatomy of jb https://jupyterbook.org/en/stable/start/create.html#anatomy-of-a-book and the command line interface reference https://jupyterbook.org/en/stable/reference/cli.html
32+
33+
## Git
34+
35+
- Crash course tutorial: https://www.youtube.com/watch?v=RGOj5yH7evk&t=2543s (70 min⏰)
36+
- Interactive with all the basics https://www.youtube.com/watch?v=8JJ101D3knE&t=3131s (70 min⏰)

docs/intro

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Introduction
2+
3+
This is the intro to the JupyterBook!
4+
5+
This is just a placeholder for you to document your package.
6+
7+
8+
## Developer Guide
9+
10+
### 0. Edit your `config` and `toc` to your specs.
11+
12+
### 1. Set Organization-level Permissions (already done for SCENE)
13+
Go to:
14+
`Org Settings` → `Actions` → `General` → `Select the repo` → Check:
15+
16+
"Allow GitHub Actions to access the GITHUB_TOKEN with write permissions" must be enabled.
17+
18+
"Workflow permissions" must allow read and write by default, or per repo.
19+
20+
21+
22+
### 2. Deploy the Docs
23+
24+
First, this is done via the GitHub actions `publish-book.yml`.
25+
26+
To get a public `github.io` link, you must enable GitHub Pages.
27+
Note, this only works for public repos, or if private, from paid org.
28+
29+
### Steps:
30+
31+
1. Go to your repo → **Settings** → **Pages**
32+
2. Under **"Source"**, select:
33+
34+
* **Branch**: e.g., `main`
35+
* **Folder**: `/_build/html`
36+
3. Click **"Save"**
37+
38+
GitHub will deploy your book and show a link like:
39+
`https://<username>.github.io/<repo>/`
40+
41+
Deployment may take a minute. Refresh the page to see the live link!

placeholder/__init__.py

Whitespace-only changes.

placeholder/version.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#
2+
3+
__version__ = "0.0.0rc1"
4+
VERSION = __version__

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.yapf]
6+
based_on_style = "google"
7+
indent_width = 4
8+
9+
[tool.isort]
10+
force_single_line = true
11+
force_sort_within_sections = false
12+
lexicographical = true
13+
single_line_exclusions = ['typing']
14+
order_by_type = false
15+
group_by_package = true
16+
skip = [
17+
"__init__.py",
18+
"third_party"
19+
]
20+
21+
[tool.pylint.format]
22+
# Maximum number of characters on a single line.
23+
max-line-length=100

0 commit comments

Comments
 (0)