Skip to content

Commit e3ad67e

Browse files
committed
add: lint pre-commit
update: .pre-commit-config.yaml is not a file add: lint
1 parent b216a7e commit e3ad67e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+267
-233
lines changed

.github/workflows/IntegrationTest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
branches: [ "main" ]
1111
workflow_dispatch:
1212

13-
13+
1414
jobs:
1515
build:
1616

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: lint
2+
3+
on: [push, pull_request]
4+
5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.10.15]
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install pre-commit hook
22+
run: |
23+
pip install pre-commit==3.8.0
24+
pre-commit install
25+
- name: Linting
26+
run: |
27+
pre-commit sample-config > .pre-commit-config.yaml
28+
pre-commit run --all-files

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v3.2.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@
198198
distributed under the License is distributed on an "AS IS" BASIS,
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201-
limitations under the License.
201+
limitations under the License.

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ $ cat test/data/config_gpt.json
8383
"llm_config": {
8484
"openai": {
8585
"model": "gpt-4o",
86-
"key": "xxxx",
86+
"key": "xxxx",
8787
"api_url": "https://api.openai.com/v1/chat/completions"
8888
}
8989
}
@@ -153,17 +153,17 @@ then you can refer to: [Install Dependencies](requirements)
153153

154154
## Register Rules/Prompts/Models
155155

156-
If the heuristic rules inside the project do not meet the user's quality inspection requirements, users can also customize rules or models.
156+
If the heuristic rules inside the project do not meet the user's quality inspection requirements, users can also customize rules or models.
157157

158158
### Register Rules
159159

160-
If the user wants to create a new rule `CommonPatternDemo`, then the first step is to add a decorator to the rule to inject the rule into the project.
161-
Secondly, the `metric_type` type, such as `QUALITY_BAD_RELEVANCE`, needs to be set for the rule, and `group` does not need to be set.
162-
Then the user needs to define the `DynamicRuleConfig` object, so that the properties of the rule can be configured dynamically.
163-
In addition, the method name of the rule must be `eval` and it needs to be a class method.
164-
The return value of the last step should be a `ModelRes` object.
160+
If the user wants to create a new rule `CommonPatternDemo`, then the first step is to add a decorator to the rule to inject the rule into the project.
161+
Secondly, the `metric_type` type, such as `QUALITY_BAD_RELEVANCE`, needs to be set for the rule, and `group` does not need to be set.
162+
Then the user needs to define the `DynamicRuleConfig` object, so that the properties of the rule can be configured dynamically.
163+
In addition, the method name of the rule must be `eval` and it needs to be a class method.
164+
The return value of the last step should be a `ModelRes` object.
165165

166-
For example: [Register Rules](examples/register/sdk_register_rule.py)
166+
For example: [Register Rules](examples/register/sdk_register_rule.py)
167167

168168
### Register Prompts
169169

@@ -173,8 +173,8 @@ For example: [Register Prompts](examples/register/sdk_register_prompt.py)
173173

174174
### Register Models
175175

176-
The way to register models is slightly different, users need to implement a call_api method, accept MetaData type parameters, and return ModelRes type results.
177-
There are already implemented basic model classes [BaseOpenAI](dingo/model/llm/base_openai.py) in the project, users can directly inherit.
176+
The way to register models is slightly different, users need to implement a call_api method, accept MetaData type parameters, and return ModelRes type results.
177+
There are already implemented basic model classes [BaseOpenAI](dingo/model/llm/base_openai.py) in the project, users can directly inherit.
178178
If the user has special functions to implement, then you can rewrite the corresponding methods.
179179

180180
For example: [Register Models](examples/register/sdk_register_llm.py)
@@ -185,7 +185,7 @@ For example: [Register Models](examples/register/sdk_register_llm.py)
185185

186186
## Execution Engine
187187

188-
`Dingo` can run locally or on a spark cluster.
188+
`Dingo` can run locally or on a spark cluster.
189189
Regardless of the choice of engine, the executor supports some common methods:
190190

191191
| function name | description |
@@ -203,9 +203,9 @@ When choosing the spark engine, users can freely choose rules, models for qualit
203203

204204
### Spark Mode
205205

206-
When choosing the spark engine, users can only choose rules for quality inspection, and models cannot be used.
207-
And only `eval_group`,`save_data`,`save_correct`,`custom_config` in `InputArgs` are still valid.
208-
Therefore, the user needs to input `spark_session` to initialize spark, and input `spark_rdd` (composed of `MetaData` structure) as data for quality inspection.
206+
When choosing the spark engine, users can only choose rules for quality inspection, and models cannot be used.
207+
And only `eval_group`,`save_data`,`save_correct`,`custom_config` in `InputArgs` are still valid.
208+
Therefore, the user needs to input `spark_session` to initialize spark, and input `spark_rdd` (composed of `MetaData` structure) as data for quality inspection.
209209
It should be noted that if `save_data` is `False`, then the data in memory will be cleared immediately after the quality inspection is completed, and `spark_session` will also stop immediately.
210210

211211
[Spark Example](examples/spark/sdk_spark.py)
@@ -278,4 +278,4 @@ If you find this project useful, please consider citing our tool:
278278
howpublished={\url{https://github.com/DataEval/dingo}},
279279
year={2024}
280280
}
281-
```
281+
```

README_CN.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ $ cat test/data/config_gpt.json
8282
"llm_config": {
8383
"openai": {
8484
"model": "gpt-4o",
85-
"key": "xxxx",
85+
"key": "xxxx",
8686
"api_url": "https://api.openai.com/v1/chat/completions"
8787
}
8888
}
@@ -152,17 +152,17 @@ Dingo 支持输出7个Quality Metrics概况报告和异常数据追溯详情报
152152

153153
## 2.注册规则/prompt/模型
154154

155-
如果项目内部的启发式规则不满足用户的质检需求,用户还可以自定义规则或者模型。
155+
如果项目内部的启发式规则不满足用户的质检需求,用户还可以自定义规则或者模型。
156156

157157
### 2.1 注册规则
158158

159-
如果用户想要创建一个新规则 `CommonPatternDemo`,那么首先要为规则添加装饰器,将规则注入项目中。
160-
其次还需要为规则设置 `metric_type` 类型,比如 `QUALITY_BAD_RELEVANCE``group` 可以不用设置。
161-
然后用户需要定义 `DynamicRuleConfig` 对象,这样可以动态的配置规则的属性。
162-
除此之外,规则的方法名称必须是 `eval` 且需要是类方法。
163-
最后一步的返回值应该是 `ModelRes` 对象。
159+
如果用户想要创建一个新规则 `CommonPatternDemo`,那么首先要为规则添加装饰器,将规则注入项目中。
160+
其次还需要为规则设置 `metric_type` 类型,比如 `QUALITY_BAD_RELEVANCE``group` 可以不用设置。
161+
然后用户需要定义 `DynamicRuleConfig` 对象,这样可以动态的配置规则的属性。
162+
除此之外,规则的方法名称必须是 `eval` 且需要是类方法。
163+
最后一步的返回值应该是 `ModelRes` 对象。
164164

165-
例如:[注册规则](examples/register/sdk_register_rule.py)
165+
例如:[注册规则](examples/register/sdk_register_rule.py)
166166

167167
### 2.2 注册prompt
168168

@@ -172,8 +172,8 @@ Dingo 支持输出7个Quality Metrics概况报告和异常数据追溯详情报
172172

173173
### 2.3 注册模型
174174

175-
注册模型的方式略有不同,用户需要实现一个call_api方法,接受MetaData类型参数,返回ModelRes类型结果。
176-
项目中有已经实现好的基础模型类[BaseOpenAI](dingo/model/llm/base_openai.py),用户可以直接继承。
175+
注册模型的方式略有不同,用户需要实现一个call_api方法,接受MetaData类型参数,返回ModelRes类型结果。
176+
项目中有已经实现好的基础模型类[BaseOpenAI](dingo/model/llm/base_openai.py),用户可以直接继承。
177177
如果用户有特殊的功能要实现,那么就可以重写对应的方法。
178178

179179
例如:[注册模型](examples/register/sdk_register_llm.py)
@@ -184,7 +184,7 @@ Dingo 支持输出7个Quality Metrics概况报告和异常数据追溯详情报
184184

185185
## 4.执行引擎
186186

187-
`Dingo` 可以在本地运行,也可以在spark集群上运行。
187+
`Dingo` 可以在本地运行,也可以在spark集群上运行。
188188
无论选择何种引擎,executor都支持一些公共方法:
189189

190190
| function name | description |
@@ -202,9 +202,9 @@ Dingo 支持输出7个Quality Metrics概况报告和异常数据追溯详情报
202202

203203
### 4.2 Spark Mode
204204

205-
选择spark引擎时,用户只能选择规则进行质检,模型无法使用。
206-
而且`InputArgs`中仅有`eval_group`,`save_data`,`save_correct`,`custom_config`依旧有效。
207-
因此,用户需要输入`spark_session`用来初始化spark,输入`spark_rdd`(由`MetaData`结构组成)作为数据用来质检。
205+
选择spark引擎时,用户只能选择规则进行质检,模型无法使用。
206+
而且`InputArgs`中仅有`eval_group`,`save_data`,`save_correct`,`custom_config`依旧有效。
207+
因此,用户需要输入`spark_session`用来初始化spark,输入`spark_rdd`(由`MetaData`结构组成)作为数据用来质检。
208208
需要注意,`save_data`如果为`False`,那么质检完成后会立刻清除内存中的数据,`spark_session`也立即停止。
209209

210210
[spark示例](examples/spark/sdk_spark.py)

Todo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"verion":"0.0.1","entries":[]}
1+
{"verion":"0.0.1","entries":[]}

app/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ indent_style = space
66
indent_size = 2
77
end_of_line = lf
88
insert_final_newline = true
9-
trim_trailing_whitespace = true
9+
trim_trailing_whitespace = true

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@
8080
"typescript": "^5.5.2",
8181
"vite": "^5.3.1"
8282
}
83-
}
83+
}

0 commit comments

Comments
 (0)