Last active
April 5, 2021 23:37
-
-
Save bsmith89/c6811893c1cbd2a72cc1d144a197bef2 to your computer and use it in GitHub Desktop.
Example files for http://blog.byronjsmith.com/makefile-shortcuts.html, a default makefile for computational research projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.ipynb filter=dropoutput_jupyter | |
*.[tc]sv diff=daff-csv | |
*.[tc]sv merge=daff-csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# run `chmod +x drop_jupyter_output.sh` to make it executable. | |
file=$(mktemp) | |
cat <&0 >$file | |
jupyter nbconvert --to notebook --ClearOutputPreprocessor.enabled=True \ | |
$file --stdout 2>/dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define PROJECT_HELP_MSG | |
Usage: | |
make help show this message | |
make clean remove intermediate files (see CLEANUP) | |
make ${VENV} make a virtualenv in the base directory (see VENV) | |
make python-reqs install python packages in requirements.pip | |
make git-config set local git configuration | |
make setup git init; make python-reqs git-config | |
make start-jupyter launch a jupyter server from the local virtualenv | |
endef | |
export PROJECT_HELP_MSG | |
help: | |
echo $$PROJECT_HELP_MSG | less | |
.git: | |
git init | |
git-config: | .git | |
git config --local filter.dropoutput_jupyter.clean \ | |
drop_jupyter_output.sh | |
git config --local filter.dropoutput_jupyter.smudge cat | |
git config --local core.page 'less -x4' | |
git config --local diff.daff-csv.command "daff.py diff --git" | |
git config --local merge.daff-csv.name "daff.py tabular merge" | |
git config --local merge.daff-csv.driver "daff.py merge --output %A %O %A %B" | |
VENV = .venv | |
export VIRTUAL_ENV := $(abspath ${VENV}) | |
export PATH := ${VIRTUAL_ENV}/bin:${PATH} | |
${VENV}: | |
python3 -m venv $@ | |
python-reqs: requirements.pip | ${VENV} | |
pip install --upgrade -r requirements.pip | |
setup: python-reqs git-config | .git ${VENV} | |
start-jupyter: | |
jupyter notebook --config=jupyter_notebook_config.py | |
CLEANUP = *.pyc | |
clean: | |
rm -rf ${CLEANUP} | |
.PHONY: help git-config start-jupter python-reqs setup clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jupyter | |
daff |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Huh. Hadn't thought about the risks yet of that particular cleanup recipe. I'll take a look at your stuff.
In general, I wouldn't use this makefile outside of a single, well defined, project directory, so I wasn't as concerned about broader fs structure.