用于跟踪、记录和复制软件运行的实用程序。
lab-notebook的Python项目详细描述
实验笔记本
计算机科学的研究人员经常需要在一个过程的不同版本之间比较结果。 Lab Notebook帮助记录、跟踪和组织这些类型的运行。 这对于再现性是至关重要的,并且有助于研究人员找出代码中的哪些变化导致了不同的结果。 Lab Notebook的目标是再现性、模块化和组织。 具体来说,Lab Notebook提供以下功能:
- 维护每次运行的元数据,包括描述、时间戳和git提交。
- 自动设置运行,生成与tmux中的每次运行和启动运行相对应的具有唯一名称的标志和目录。
- 将运行组织到分层类别中。
- 将运行与目录同步,以便在移动和删除运行时移动和删除目录。
安装
此工具的唯一外部依赖项是tmux和git。之后,pip install lab-notebook。
配置
程序将默认为.runsrc中指定的任何参数。 用户始终可以使用命令行参数覆盖.runsrc文件。 对于参数的描述,请使用runs -h或runs [command] -h 程序在当前工作目录的祖先(包括祖先)中搜索.runsrc文件。 如果程序找不到.runsrc文件,它将在当前工作目录中创建一个具有默认值的文件。 用户可以在.runsrc:
中使用两个关键字- <path>将替换为运行的路径。路径看起来就像普通的文件路径(/-分隔符)。
- <name>将被path的头替换。
用户还可以使用语法${section:value}从.runsrc的其他部分插入字符串。 详情请见 configparser ExtendedInterpolation。
下面是一个示例.runsrc文件:
[main]root=/Users/ethan/demo-lab-notebook/.runsdb_path=/Users/ethan/demo-lab-notebook/runs.pkldir_names=tensorboardprefix=Source ~/virtualenvs/demo-lab-notebook/bin/activate;nice[flags]--log-dir=${main:root}/tensorboard/<path>[new]description=demo lab-notebook
这将传递标志--logdir=/Users/ethan/baselines/.runs/tensorboard/<path> 任何用run启动的程序,其中<path>将被用户给定的path参数替换。
runs-git
这是一个简单的git包装,它用runs lookup commit your-path替换+your-path。 例如,查看自启动your-run:
runs-git diff +your-run
如果你想活在荒野的一面,当你想用direnv来命名git到runs-git时 在项目目录中。
示例用法
设置环境:
mkdir ~/lab-notebook-demo/ && cd ~/lab-notebook-demo
wget https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
pip install tensorflow lab-notebook
git init
echo 'runs.pkl .runs .runsrc' > .gitignore
git add -A
git commit -am init
创建新管路。运行将在tmux:
中启动runs new train 'python mnist_with_summaries.py' --description='demo new command'
查看您的跑步记录:
tmux attach -t train
重新开始跑步:
runs reproduce train
runs reproduce --no-overwrite train
尝试修改.runsrc文件,使其看起来像 Configuration为您的系统提供适当更改的部分。 然后创建新管路:
runs new subdir/train 'python mnist_with_summaries.py' --description='demo categorization'
了解数据库中运行的内容:
runs ls
runs ls 'tra*'
runs ls --show-attrs
查询当前运行的信息:
runs lookup description train
runs lookup commit train
runs-git:避免一直键入runs lookup commit <path>:
echo '# Hello' >> mnist_with_summaries.py
runs-git diff +train
组织跑步
runs mv train subdir/train2
runs ls
tree .runs # note that directories are synchronized with database entries
runs mv subdir archive
runs ls
删除跑步记录
runs rm archive/train
runs killall
子命令
有关子命令的概述,请运行
runs -h
有关每个子命令及其参数的详细说明,请运行
runs <subcommand> -h
选项卡自动完成
如果您使用zsh,那么简单地将_runs复制到fpath上的某个位置。 然后按Tab键将提示您当前在 数据库
为什么不直接使用git呢?
- 如果进程是长时间运行的,则很难知道给定运行对应于哪个提交。
- commit语句实际上是用来描述对软件的changes更改,而不是runs。对变更的描述实际上并不能告诉您软件运行的动机。
- 并非所有提交都对应于运行,因此您需要通过大量提交来查找对应于运行的提交。 <里>进程通常依赖于特定的文件结构(例如日志目录)。手动设置和删除这些目录既费时又容易出错。
- 提交创建后不能按层次结构组织或分类。