Skip to content

Instantly share code, notes, and snippets.

@Autoplectic
Autoplectic / pre-commit
Last active December 26, 2015 02:29
A git pre-commit hook to run tests and pylint prior to a commit, and fail if any tests fail.
#!/usr/bin/env python
###############################################################################
# Ryan James
"""
This pre-commit hook runs nosetests and pylint, reporting their scores.
It blocks commits with failing tests.
To install
----------
@Autoplectic
Autoplectic / dispatcher.py
Last active August 29, 2015 14:19
A python script to farm out tasks to a SLURM cluster.
#!/usr/bin/env python
"""
You might need to run the following before running this script:
pip install --upgrade --user click clusterlib decorator logbook minibar pathlib sarge
Usage:
dispatcher.py ./script.py dispatch arg1 arg2 arg3
"""
This is an example script for use with dispatcher.py. It is manditory to define three things:
- NAME: the base name to give all jobs.
- params: a function that transforms global parameters to a set of local parameters.
- compute: a function that takes in local parameters and performs the desired computation.
"""
from logbook import Logger
# dispatcher.py has a logbook handler all set up, so we just need a logger.
# color shortcuts
RED="%{$fg[red]%}"
YELLOW="%{$fg[yellow]%}"
GREEN="%{$fg[green]%}"
WHITE="%{$fg[white]%}"
BLUE="%{$fg[blue]%}"
CYAN="%{$fg[cyan]%}"
RED_BOLD="%{$fg_bold[red]%}"
YELLOW_BOLD="%{$fg_bold[yellow]%}"
GREEN_BOLD="%{$fg_bold[green]%}"