python companion for github.com/src-d/hercules以可视化结果。
labours的Python项目详细描述
大力神
快速、深入和高度可定制的Git历史分析。
/a>
目录
概述
Hercules是一个用Go编写的快速且高度可定制的Git存储库分析引擎。包括电池。 由go-git和babelfish提供支持
有两种命令行工具:hercules
和labours
。首先是一个程序
使用go编写,它接受git存储库,并在完整的提交历史记录中执行分析任务的定向非循环图(dag)。
第二个是python脚本,它在收集的数据上显示一些预定义的图。这两种工具通常通过
管子可以使用插件系统编写自定义分析。也有可能
合并多个分析结果-与组织相关。
分析的提交历史包括分支、合并等。
Hercules已经成功地用于source{d}的几个内部项目。 有一些博客文章:1,2和 a演示文稿。请贡献 通过测试、修复错误、添加新分析,或编码狂妄!
燃耗和耦合分析与uast diff精炼的dag。由 Torvalds/Linux线路烧毁(粒度30,采样30,按年份重新采样)。用 从发布页面获取二进制文件。
可以使用http://www.lfd.uci.edu/%7egohlke/pythonlibs/" rel="nofollow">http://www.lfd.uci.edu/~gohlke/pythonlibs/ 你要走了ng需要go(>;=v1.10), 在Windows上将 最有用、最可靠的最新命令行参考: 一些示例: 可以将克隆的存储库存储在磁盘上。后续分析可以在
相应的目录而不是从头开始克隆: 整个存储库的行消耗统计信息。
与特修斯的git完全相同
但速度要快得多。通过使用自定义rb树跟踪,可以高效、增量地执行责备。
算法,运行分析时只记录最后修改日期。 所有燃耗分析都取决于粒度和采样的值。
粒度是堆栈中每个频带包含的天数。抽样
是捕捉耗尽状态的频率。越小的
值,绘图越平滑,但完成的工作越多。 有一个选项可以对 存储库中最新版本中活动的每个文件的消耗统计信息。 注意:它将为每个文件生成单独的图形。您不想在包含许多文件的存储库上运行它。 存储库贡献者的耗尽统计信息。如果未指定 如果指定了 Wireshark 20强开发者-覆盖矩阵 除了燃尽信息之外,燃尽人员根据
开发商。因此,可以直观地看到开发人员a写的行被开发人员b删除了多少行。
这表示人员之间的协作,并定义专业团队。 格式是包含n行和(n+2)列的矩阵,其中n是开发人员的数量。 开发人员的序列存储在 ember.js前20名开发人员-代码所有权 Tensorflow投影仪中的Torvalds/Linux文件耦合 重要信息:需要安装TensorFlow,请遵循官方说明 如果在同一提交中更改了这些文件,则它们是耦合的。如果开发人员
更改同一文件。 多亏了巴贝菲什,赫拉克勒斯能够测量每个结构单元被修改了多少次。
默认情况下,它查看函数;请参阅语义uast xpath
手动切换到其他位置。 如果可用,耦合分析会自动加载"快照"数据。 tensorflow/tensorflow-aligned commit系列,按commit编号排列,由前50名开发人员组成。 我们记录每个开发人员每天进行的提交以及添加、删除和更改的行数。
我们使用一些技巧来绘制结果提交时间序列,以显示时间分组。换句话说,
正常化后,两个相邻的提交序列应该看起来相似。 这个图可以发现开发团队是如何随着时间而发展的。它还显示了"提交flashmobs"
例如,hacktoberfest。例如,下面是
从上面的 tensorflow/tensorflow随着时间的推移添加和更改行。 kubernetes/kubernetes通过时间的努力。 此外, 可以清楚地看到,django的评论一开始是积极/乐观的,但后来变成消极/悲观的。 我们在每次提交时从源代码中提取新的和更改的注释,应用bidisentition
通用情绪递归神经网络并绘制结果。要求
libtensorflow。
例如,很遗憾,我们需要从文档查找器f中隐藏rect或者现在hercules--burndown--burndown people--couples--feature=uast--dry run--dump dag doc/dag.dot https://github.com/src-d/hercules生成
是负数
hercules--burndown--first parent--pb https://github.com/torvalds/linux labours-f pb-m burndown project
在1小时40分钟内生成。安装
labours
可从pypi安装::pip3 install labours
pip3
是python包管理器。从源代码生成
protoc
,
以及dep
go get -d gopkg.in/src-d/hercules.v10/cmd/hercules
cd $GOPATH/src/gopkg.in/src-d/hercules.v10
make
pip3 install -e ./python
$gopath
替换为%gopath%
。贡献
许可证
用法
hercules --help
# Use "memory" go-git backend and display the burndown plot. "memory" is the fastest but the repository's git data must fit into RAM.
hercules --burndown https://github.com/src-d/go-git | labours -m burndown-project --resample month
# Use "file system" go-git backend and print some basic information about the repository.
hercules /path/to/cloned/go-git
# Use "file system" go-git backend, cache the cloned repository to /tmp/repo-cache, use Protocol Buffers and display the burndown plot without resampling.
hercules --burndown --pb https://github.com/git/git /tmp/repo-cache | labours -m burndown-project -f pb --resample raw
# Now something fun
# Get the linear history from git rev-list, reverse it
# Pipe to hercules, produce burndown snapshots for every 30 days grouped by 30 days
# Save the raw data to cache.yaml, so that later is possible to labours -i cache.yaml
# Pipe the raw data to labours, set text font size to 16pt, use Agg matplotlib backend and save the plot to output.png
git rev-list HEAD | tac | hercules --commits - --burndown https://github.com/git/git | tee cache.yaml | labours -m burndown-project --font-size 16 --backend Agg --output git.png
labours-i/path/to/yaml
允许读取保存在磁盘上的hercules的输出。
缓存
# First time - cache
hercules https://github.com/git/git /tmp/repo-cache
# Second time - use the cache
hercules --some-analysis /tmp/repo-cache
Docker图像
docker run --rm srcd/hercules hercules --burndown --pb https://github.com/git/git | docker run --rm -i -v $(pwd):/io srcd/hercules labours -f pb -m burndown-project -o /io/git_git.png
内置分析
项目耗竭
hercules --burndown
labours -m burndown-project
labours
中的频带重新采样,这样您就可以
定义一个非常精确的分布并以不同的方式将其可视化。此外,
重新采样跨周期边界(例如,月或年)对齐波段。
未限制的波段显然没有对齐,并且从项目的出生日期开始。文件
hercules --burndown --burndown-files
labours -m burndown-file
人
hercules --burndown --burndown-people [--people-dict=/path/to/identities]
labours -m burndown-person
--people dict
,则标识为
通过以下算法发现:--people dict
,则应指向具有自定义标识的文本文件。这个
格式是:每一行都是一个开发人员,它包含所有匹配的电子邮件和分隔的名称
通过。忽略案例。
覆盖矩阵
0
pip3 install labours
people\u sequence
yaml节点中。代码所有权
1
pip3 install labours
--burndown people
还允许通过时间叠加面积图绘制代码共享。也就是说,
对于每个确定的显影剂,在采样时刻有多少行是活动的。对
2
pip3 install labours
hercules
记录整个提交历史中的对数
并输出两个对应的共生矩阵。劳动
然后训练
旋转嵌入-反映
通过欧氏距离的共现概率。训练需要一个
安装。中间文件存储在
系统临时目录或--如果指定,则耦合tmp dir
。经过训练的嵌入是
写入当前工作目录,其名称取决于-o
。输出格式为tsv
并与tensorflow projector匹配
可以在tf投影仪中实现t-sne的可视化。结构热度
3
pip3 install labours
4
pip3 install labours
赫拉克勒斯——肖特内斯——PB https://github.com/pallets/jinja劳工——M对夫妇——F PB
对齐提交序列
5
pip3 install labours
tensorflow/tensorflow
plot获得的见解:随时间增加与更改的行数
6
pip3 install labours
--devs
上一节允许绘制添加了多少行以及现有更改了多少行
(删除或替换)通过时间。此绘图已平滑。通过时间的努力
7
pip3 install labours
--devs
允许绘制每个开发人员更改(添加或删除)的行数。
地块的上部是一个累积(综合)的下部。不可能有同样的规模
对于这两部分,将缩放较低的值,因此没有较低的Y轴刻度。
努力图和所有权图之间有区别,尽管变化的线与
拥有自己的线路。情绪(正面和负面评论)
赫拉克勒斯——情绪——pb https://github.com/django/django labours-m情绪——f pb
Theano有一个内置的logsumexp(…)优化,因此我们可以直接编写表达式
是积极的。但是不要期望太高-正如所写的,情绪模型是
一般用途和代码注释具有不同的性质,因此暂时没有魔力。
Hercules必须用"TensorFlow"标记构建-默认情况下不是这样:
pip3 install labours
8
这样的构建需要libtensorflow
一次完成所有操作
pip3 install labours
9
插件
pip3 install labours
Hercules有一个插件系统,允许运行自定义分析。请参见plugins.md。
合并
hercules combine是将多个分析结果以协议缓冲区格式连接在一起的命令。
go get -d gopkg.in/src-d/hercules.v10/cmd/hercules
cd $GOPATH/src/gopkg.in/src-d/hercules.v10
make
pip3 install -e ./python
0
错误的Unicode错误
yaml不支持unicode字符的整个范围,也不支持labours
侧的解析器
可能引发异常。从hercules
到fix-yaml\u unicode.py的输出进行筛选以丢弃
这些令人讨厌的角色。
go get -d gopkg.in/src-d/hercules.v10/cmd/hercules
cd $GOPATH/src/gopkg.in/src-d/hercules.v10
make
pip3 install -e ./python
1
绘图
这些选项影响所有绘图:
go get -d gopkg.in/src-d/hercules.v10/cmd/hercules
cd $GOPATH/src/gopkg.in/src-d/hercules.v10
make
pip3 install -e ./python
2
--style
设置绘图的常规样式(请参见labours--help
)。
--背景
将绘图背景更改为白色或黑色。
--backend
选择matplotlib后端。
--size
以英寸为单位设置图形的大小。默认值为12,9
(在MacOS中是必需的)您可以用
go get -d gopkg.in/src-d/hercules.v10/cmd/hercules
cd $GOPATH/src/gopkg.in/src-d/hercules.v10
make
pip3 install -e ./python
3
这些选项仅在燃尽图表中有效:
go get -d gopkg.in/src-d/hercules.v10/cmd/hercules
cd $GOPATH/src/gopkg.in/src-d/hercules.v10
make
pip3 install -e ./python
4
--text size
更改字体大小,--relative
激活拉伸的burndown布局。
自定义打印后端
可以输出以json格式绘制图所需的所有信息。
只需将.json
附加到输出(-o
)即可。数据格式不完整
指定并依赖于生成它的python代码。每个json文件都应该
包含反映绘图类型的"type"。
注意事项
- 在某些罕见的情况下,处理所有提交可能会失败。如果出现类似于https://github.com/src-d/hercules/issues/106" rel="nofollow">https://github.com/src-d/hercules/issues/106的错误
请在此处报告并指定
--第一个父级
作为解决方法。 - 耗尽收集可能会失败,并出现内存不足错误。有关解决方法,请参见下一节课。
- 当内部对象的数量很大时,在python中解析yaml很慢。
hercules
'输出 对于处于"耦合"模式的Linux内核来说,是1.5GB,需要一个多小时/180GB的RAM 解析。然而,大多数存储库在一分钟内就被解析了。尝试使用协议缓冲区 相反(hercules--pb
和labours-f pb
)。 - 加速yaml解析
5go get -d gopkg.in/src-d/hercules.v10/cmd/hercules cd $GOPATH/src/gopkg.in/src-d/hercules.v10 make pip3 install -e ./python
< > >
内存耗尽
如果分析的存储库很大并且广泛使用分支,那么burndown stats集合可以 一声"呜呜"就失败了。您应该尝试以下操作: