A general template for analytics projects, inspired heavily by https://goodresearch.dev and https://nbdev.fast.ai/.
If you do not have cookiecutter installed, do so with:
> pip install cookiecutter
Next, generate your project:
> cookiecutter https://github.com/calremmel/analysis-template.git
Install basic dependences using the following command (assumes conda
or mamba
installed):
> conda env create -n ENV_NAME -f environment.yml
To make your packages in src
importable from anywhere:
> pip install -e .
Next, in order to name your package:
> mv src PACKAGE_NAME
To auto-generate paired Markdown files for version-controlling notebooks:
- Open command palette with
Cmd Shift C
- Select
Pair Notebook with Markdown
To enable a shortcut for "Restart Kernel and Run All Cells":
- Open Advanced Settings with
Cmd ,
- Select
JSON Settings Editor
in top-right corner - Select
Keyboard Shortcuts
on left sidebar - Copy in the following under
User Preferences
inside the curly brackets:
"shortcuts": [
{
"args": {},
"command": "runmenu:restart-and-run-all",
"keys": [
"Cmd Shift Enter"
],
"selector": "[data-jp-code-runner]"
}
]
Feel free to replace Cmd Shift Enter
with whatever you like.
To autoformat notebooks with both isort
and black
:
- Open Advanced Settings with
Cmd ,
- Select
JSON Settings Editor
in top-right corner - Select
Jupyterlab Code Formatter
on left sidebar - Copy in the following under
User Preferences
replacing the"python"
line under"default_formatter"
"python": ["isort", "black"]