一个Looker清理工具
项目描述
Henry:一个Looker清理工具
Henry是一个命令行工具,可以帮助确定您的Looker实例中的模型冗余,并识别模型和探索中未使用的内 容。它旨在帮助开发者清理模型中未使用的探索,以及探索中未使用的连接和字段,同时维护一个健壮且用户友好的实例。
目录
状态和支持
Henry在任何方面都未经Looker支持或保证。请勿联系Looker支持解决Henry相关的问题。问题可以通过https://github.com/looker-open-source/henry/issues进行记录。
安装
Henry需要python3.7+。它发布在PyPI上,可以使用pip进行安装。
$ pip install henry
为了开发设置,请遵循下面的开发设置以下。
使用
为了显示使用信息,请使用
$ henry --help
适用于许多命令的全局选项
身份验证
Henry使用Looker SDK发出API调用,并需要API3凭证。这些凭证可以通过.ini文件或环境变量提供,具体文档请参考此处。默认情况下,工具会在工作目录中查找名为"looker.ini"的文件。如果配置文件名称不同或位于其他位置,则必须使用--config-file
参数指定。
示例.ini文件
[Looker]
# Base URL for API. Do not include /api/* in the url
base_url=https://self-signed.looker.com:19999
# API 3 client id
client_id=YourClientID
# API 3 client secret
client_secret=YourClientSecret
# Set to false if testing locally against self-signed certs. Otherwise leave True
verify_ssl=True
[Production]
base_url=https://production.looker.com:19999
client_id=YourClientID
client_secret=YourClientSecret
verify_ssl=True
假设上面的ini文件内容,Henry可以按以下方式运行
$ henry pulse --config-file=looker.ini --section=Looker
由于默认设置,等价于
$ henry pulse
使用生产
部分下的详细信息运行它,可以这样做
$ henry pulse --section=Production
API超时设置
默认情况下,API调用超时时间为120秒。这可以通过--timeout
参数覆盖。
输出到文件
如果使用--save
标志,则工具会将结果保存到您的当前工作目录。例如使用
$ henry vacuum models --save
将结果保存到当前工作目录中的vacuum_models_{date}_{time}.csv。
Pulse命令
命令henry pulse
运行多个测试,有助于确定实例的整体健康状况。
分析命令
命令analyze
旨在帮助识别变得臃肿的模型和探索,并对它们使用vacuum
进行修剪。
分析项目
命令analyze projects
扫描项目的内容,并检查成功所需的基本功能的状态,例如git连接状态和验证要求。
+-------------------+---------------+--------------+-------------------------+---------------------+------------------------+
| Project | # Models | # View Files | Git Connection Status | PR Mode | Is Validation Required |
|-------------------+---------------+--------------+-------------------------+---------------------+------------------------|
| marketing | 1 | 13 | OK | links | True |
| admin | 2 | 74 | OK | off | True |
| powered_by_looker | 1 | 14 | OK | links | True |
| salesforce | 1 | 36 | OK | required | False |
| thelook_event | 1 | 17 | OK | required | True |
+-------------------+---------------+--------------+-------------------------+---------------------+------------------------+
分析模型
显示每个模型中的探索数量以及针对该模型进行的查询数量。
+-------------------+------------------+-----------------+-------------------+-------------------+
| Project | Model | # Explores | # Unused Explores | Query Count |
|-------------------+------------------+-----------------+-------------------+-------------------|
| salesforce | salesforce | 8 | 0 | 39923 |
| thelook_event | thelook | 10 | 0 | 166307 |
| powered_by_looker | powered_by | 5 | 0 | 49122 |
| marketing | thelook_adwords | 3 | 0 | 40869 |
| admin | looker_base | 0 | 0 | 0 |
| admin | looker_on_looker | 10 | 9 | 28 |
+-------------------+------------------+-----------------+-------------------+-------------------+
分析探索
显示探索及其使用情况。如果传递了--min-queries
参数,则将考虑使用次数低于指定阈值的连接和字段为未使用。
+---------+-----------------------------------------+-------------+-------------------+--------------+----------------+---------------+-----------------+---------------+
| Model | Explore | Is Hidden | Has Description | # Joins | # Unused Joins | # Fields | # Unused Fields | Query Count |
|---------+-----------------------------------------+-------------+-------------------+--------------+----------------+---------------+-----------------+---------------|
| thelook | cohorts | True | False | 3 | 0 | 19 | 4 | 333 |
| thelook | data_tool | True | False | 3 | 0 | 111 | 90 | 736 |
| thelook | order_items | False | True | 7 | 0 | 153 | 16 | 126898 |
| thelook | events | False | True | 6 | 0 | 167 | 68 | 19372 |
| thelook | sessions | False | False | 6 | 0 | 167 | 83 | 12205 |
| thelook | affinity | False | False | 2 | 0 | 34 | 13 | 3179 |
| thelook | orders_with_share_of_wallet_application | False | True | 9 | 0 | 161 | 140 | 1586 |
| thelook | journey_mapping | False | False | 11 | 2 | 238 | 228 | 14 |
| thelook | inventory_snapshot | False | False | 3 | 0 | 25 | 15 | 33 |
| thelook | kitten_order_items | True | False | 8 | 0 | 154 | 138 | 39 |
+---------+-----------------------------------------+-------------+-------------------+--------------+----------------+---------------+-----------------+---------------+
真空信息
命令vacuum
根据预定义的标准输出未使用的内容列表,开发人员可以使用它来清理模型和探索。
真空模型
命令vacuum models
公开模型以及它们在预定义时间段内的查询数量。列出的探索在此时间段内没有达到最小查询数。因此,可以安全地隐藏它们并在以后删除它们。
+------------------+---------------------------------------------+-------------------------+
| Model | Explore | Model Query Count |
|------------------+---------------------------------------------+-------------------------|
| salesforce | | 39450 |
| thelook | | 164930 |
| powered_by | | 49453 |
| thelook_adwords | | 38108 |
| looker_on_looker | user_full | 27 |
| | history_full | |
| | content_view | |
| | project_status | |
| | field_usage_full | |
| | dashboard_performance_full | |
| | user_weekly_app_activity_period_over_period | |
| | pdt_state | |
| | user_daily_query_activity | |
+------------------+---------------------------------------------+-------------------------+
真空探索
命令vacuum explores
公开在指定时间段(默认:90,可以使用--timeframe
参数更改)内查询次数低于或等于最小查询阈值(默认=0,可以使用--min-queries
参数更改)的连接和字段。
示例:从上面的分析函数运行以上,我们知道cohorts探索有4个字段在过去90天内一次也没有被查询过。运行以下真空命令
$ henry vacuum explores --model thelook --explore cohorts
提供未使用字段的名称
+---------+-----------+----------------+------------------------------+
| Model | Explore | Unused Joins | Unused Fields |
|---------+-----------+----------------+------------------------------|
| thelook | cohorts | users | users.id |
| | | | order_items.id |
| | | | order_items.id |
| | | | order_items.total_sale_price |
+---------+-----------+----------------+------------------------------+
如果一个连接未使用,这意味着该连接引入的字段在定义的时间框架内没有被使用。因此,该连接作为结果暴露的字段不会明确列出为未使用字段。
非常重要的一点是要注意,列出的一个探索中未使用的字段并不意味着要从视图文件中完全删除,因为它们可能在其他探索(通过扩展)或过滤器中使用。相反,应该要么隐藏这些字段(如果它们在其他地方没有使用),要么使用fields LookML参数从探索中排除它们。
贡献
请参阅CONTRIBUTING文件。欢迎在GitHub上提交错误报告和拉取请求:https://github.com/looker-open-source/henry/issues。
行为准则
所有与Henry项目代码库、问题跟踪器、聊天室和邮件列表互动的人士都应遵守行为准则。
版权
版权(c)2018 Joseph Axisa,Looker Data Sciences。有关详细信息,请参阅MIT许可证。
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码发行版
构建分发版
henry-0.4.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8cbc1fbbe8b016ad652550444702790db2bed40c301ac52352237a83779530d0 |
|
MD5 | 4052312a0359fa7eba444ea208df3bc3 |
|
BLAKE2b-256 | 6d7e3bcb6d79c66423edbdd3027c37b78197a2350fd58521e834f5e7c670892a |
henry-0.4.2-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | eaccde641281d31930ff6ed1735a976376e8a30bb8f79447e99d5e540903e33a |
|
MD5 | f16e8e6f185f4f7f2fac2dd4565030aa |
|
BLAKE2b-256 | a2cc286df3886f9b6af62ae960adda5285af4ffe6eaacb6e2ca759e09f50b2b7 |