Skip to content

Commit 6c00ee5

Browse files
authoredMar 27, 2024
add pre commit (opea-project#14)
* add pre-commit config Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com> * add prettier Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com> * update prettier Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com> * fix codespell Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com> --------- Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>
1 parent cd1d216 commit 6c00ee5

File tree

5 files changed

+250
-5
lines changed

5 files changed

+250
-5
lines changed
 

‎.github/code_spell_ignore.txt

Whitespace-only changes.

‎.github/license_template.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (c) 2024 Intel Corporation
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

‎.pre-commit-config.yaml

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
ci:
2+
autofix_prs: true
3+
autoupdate_schedule: quarterly
4+
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.5.0
8+
hooks:
9+
- id: end-of-file-fixer
10+
files: (.*\.(py|md|rst|yaml|yml|json|ts|js|html|svelte|sh))$
11+
- id: check-json
12+
exclude: |
13+
(?x)^(
14+
ChatQnA/ui/tsconfig.json
15+
)$
16+
- id: check-yaml
17+
- id: debug-statements
18+
- id: requirements-txt-fixer
19+
- id: trailing-whitespace
20+
files: (.*\.(py|rst|cmake|yaml|yml|json|ts|js|html|svelte|sh))$
21+
22+
- repo: https://github.com/Lucas-C/pre-commit-hooks
23+
rev: v1.5.5
24+
hooks:
25+
- id: insert-license
26+
files: |
27+
(?x)^(
28+
(ChatQnA|CodeGen|DocSum|VisualQnA)/.*(py|yaml|yml|sh)|
29+
)$
30+
args:
31+
[
32+
--license-filepath=.github/license_template.txt,
33+
--use-current-year,
34+
--detect-license-in-X-top-lines=40,
35+
--skip-license-insertion-comment=Copyright,
36+
]
37+
- id: insert-license
38+
files: |
39+
(?x)^(
40+
(ChatQnA|CodeGen|DocSum|VisualQnA)/.*(ts|js)|
41+
)$
42+
args:
43+
[
44+
--license-filepath=.github/license_template.txt,
45+
--use-current-year,
46+
--detect-license-in-X-top-lines=40,
47+
--skip-license-insertion-comment=Copyright,
48+
--comment-style=//,
49+
]
50+
- id: insert-license
51+
files: |
52+
(?x)^(
53+
(ChatQnA|CodeGen|DocSum|VisualQnA)/.*(html|svelte)|
54+
)$
55+
args:
56+
[
57+
--license-filepath=.github/license_template.txt,
58+
--use-current-year,
59+
--detect-license-in-X-top-lines=40,
60+
--skip-license-insertion-comment=Copyright,
61+
--comment-style=<!--| |-->,
62+
]
63+
64+
- repo: https://github.com/asottile/yesqa
65+
rev: v1.5.0
66+
hooks:
67+
- id: yesqa
68+
name: Unused noqa
69+
70+
- repo: https://github.com/pycqa/isort
71+
rev: 5.13.2
72+
hooks:
73+
- id: isort
74+
75+
- repo: https://github.com/PyCQA/docformatter
76+
rev: v1.7.5
77+
hooks:
78+
- id: docformatter
79+
args: [
80+
--in-place,
81+
--wrap-summaries=0, # 0 means disable wrap
82+
--wrap-descriptions=0, # 0 means disable wrap
83+
--black,
84+
--style=google,
85+
]
86+
87+
- repo: https://github.com/pre-commit/mirrors-prettier
88+
rev: "v3.1.0" # Use the sha / tag you want to point at
89+
hooks:
90+
- id: prettier
91+
args: [--print-width=120]
92+
types_or: [yaml, markdown, html, css, scss, javascript, json]
93+
additional_dependencies:
94+
- prettier@3.2.5
95+
96+
- repo: https://github.com/psf/black.git
97+
rev: 24.3.0
98+
hooks:
99+
- id: black
100+
files: (.*\.py)$
101+
102+
- repo: https://github.com/asottile/blacken-docs
103+
rev: 1.16.0
104+
hooks:
105+
- id: blacken-docs
106+
args: [--line-length=120, --skip-errors]
107+
additional_dependencies:
108+
- black==24.3.0
109+
110+
- repo: https://github.com/codespell-project/codespell
111+
rev: v2.2.6
112+
hooks:
113+
- id: codespell
114+
args: [-w]
115+
additional_dependencies:
116+
- tomli
117+
118+
- repo: https://github.com/astral-sh/ruff-pre-commit
119+
rev: v0.3.4
120+
hooks:
121+
- id: ruff
122+
args: [--fix, --exit-non-zero-on-fix, --no-cache]

‎ChatQnA/langchain/test/README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ Pre-requisite: Signup in langsmith [https://www.langchain.com/langsmith] and get
66
3. Statr redis container with docker-compose-redis.yml
77
4. Add your hugging face access token in docker-compose-langchain.yml and start langchain-rag-server container
88
5. enter into langchain-rag-server container and start jupyter notebook server (can specify needed IP address and jupyter will run on port 8888)
9-
```
10-
docker exec -it langchain-rag-server bash
11-
cd /test
12-
jupyter notebook --allow-root --ip=X.X.X.X
13-
```
9+
10+
```
11+
docker exec -it langchain-rag-server bash
12+
cd /test
13+
jupyter notebook --allow-root --ip=X.X.X.X
14+
```
15+
1416
6. Launch jupyter notebook in your browser and open the tgi_gaudi.ipynb notebook
1517
7. Add langsmith api key in first cell of the notebook [os.environ["LANGCHAIN_API_KEY"] = "add-your-langsmith-key" # Your API key]
1618
8. Clear all the cells and run all the cells

‎pyproject.toml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
[tool.isort]
2+
profile = "black"
3+
line_length = 120
4+
extend_skip_glob = ["**/__init__.py"]
5+
6+
7+
[tool.black]
8+
line-length = 120
9+
10+
11+
[tool.codespell]
12+
skip = '*.po,*.js,*.map,*.js.map,*.css.map,*.json'
13+
count = ''
14+
quiet-level = 3
15+
ignore-words = ".github/code_spell_ignore.txt"
16+
17+
18+
[tool.ruff]
19+
# Exclude a variety of commonly ignored directories.
20+
exclude = [
21+
".bzr",
22+
".direnv",
23+
".eggs",
24+
".git",
25+
".git-rewrite",
26+
".hg",
27+
".ipynb_checkpoints",
28+
".mypy_cache",
29+
".nox",
30+
".pants.d",
31+
".pyenv",
32+
".pytest_cache",
33+
".pytype",
34+
".ruff_cache",
35+
".svn",
36+
".tox",
37+
".venv",
38+
".vscode",
39+
"__pypackages__",
40+
"_build",
41+
"buck-out",
42+
"build",
43+
"dist",
44+
"node_modules",
45+
"site-packages",
46+
"venv",
47+
]
48+
49+
# Same as Black.
50+
line-length = 120
51+
indent-width = 4
52+
53+
# Assume Python 3.10
54+
target-version = "py310"
55+
56+
[tool.ruff.lint]
57+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
58+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
59+
# McCabe complexity (`C901`) by default.
60+
select = ["E4", "E7", "E9", "F"]
61+
ignore = [
62+
"E402", # Module level import not at top of file
63+
"E501", # Line too long (121 > 120 characters)
64+
"E721", # Do not compare types, use isinstance()
65+
"E722", # Do not use bare except
66+
"E731", # Do not assign a lambda expression, use a def
67+
"E741", # Do not use variables named ‘l’, ‘O’, or ‘I’
68+
"F401", # {name} imported but unused
69+
"F403", # from {name} import * used; unable to detect undefined names
70+
"F405", # {name} may be undefined, or defined from star imports
71+
"F841", # Local variable is assigned to but never used{name}
72+
]
73+
74+
# Allow fix for all enabled rules (when `--fix`) is provided.
75+
fixable = ["ALL"]
76+
unfixable = []
77+
78+
# Allow unused variables when underscore-prefixed.
79+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
80+
81+
ignore-init-module-imports = true
82+
83+
[tool.ruff.format]
84+
# Like Black, use double quotes for strings.
85+
quote-style = "double"
86+
87+
# Like Black, indent with spaces, rather than tabs.
88+
indent-style = "space"
89+
90+
# Like Black, respect magic trailing commas.
91+
skip-magic-trailing-comma = false
92+
93+
# Like Black, automatically detect the appropriate line ending.
94+
line-ending = "auto"
95+
96+
# Enable auto-formatting of code examples in docstrings. Markdown,
97+
# reStructuredText code/literal blocks and doctests are all supported.
98+
#
99+
# This is currently disabled by default, but it is planned for this
100+
# to be opt-out in the future.
101+
docstring-code-format = false
102+
103+
# Set the line length limit used when formatting code snippets in
104+
# docstrings.
105+
#
106+
# This only has an effect when the `docstring-code-format` setting is
107+
# enabled.
108+
docstring-code-line-length = "dynamic"

0 commit comments

Comments
 (0)