Spaces:
Sleeping
Sleeping
Update
Browse files- .pre-commit-config.yaml +10 -19
- .vscode/extensions.json +8 -0
- .vscode/settings.json +5 -14
- README.md +1 -1
- app.py +5 -7
- pyproject.toml +37 -1
- requirements.txt +36 -33
- uv.lock +0 -0
.pre-commit-config.yaml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
repos:
|
2 |
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
-
rev:
|
4 |
hooks:
|
5 |
- id: check-executables-have-shebangs
|
6 |
- id: check-json
|
@@ -13,18 +13,15 @@ repos:
|
|
13 |
args: ["--fix=lf"]
|
14 |
- id: requirements-txt-fixer
|
15 |
- id: trailing-whitespace
|
16 |
-
- repo: https://github.com/
|
17 |
-
rev:
|
18 |
hooks:
|
19 |
-
- id:
|
20 |
-
args: ["--
|
21 |
-
|
22 |
-
|
23 |
-
hooks:
|
24 |
-
- id: isort
|
25 |
-
args: ["--profile", "black"]
|
26 |
- repo: https://github.com/pre-commit/mirrors-mypy
|
27 |
-
rev: v1.
|
28 |
hooks:
|
29 |
- id: mypy
|
30 |
args: ["--ignore-missing-imports"]
|
@@ -35,14 +32,8 @@ repos:
|
|
35 |
"types-PyYAML",
|
36 |
"types-pytz",
|
37 |
]
|
38 |
-
- repo: https://github.com/psf/black
|
39 |
-
rev: 24.8.0
|
40 |
-
hooks:
|
41 |
-
- id: black
|
42 |
-
language_version: python3.10
|
43 |
-
args: ["--line-length", "119"]
|
44 |
- repo: https://github.com/kynan/nbstripout
|
45 |
-
rev: 0.
|
46 |
hooks:
|
47 |
- id: nbstripout
|
48 |
args:
|
@@ -51,7 +42,7 @@ repos:
|
|
51 |
"metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
|
52 |
]
|
53 |
- repo: https://github.com/nbQA-dev/nbQA
|
54 |
-
rev: 1.
|
55 |
hooks:
|
56 |
- id: nbqa-black
|
57 |
- id: nbqa-pyupgrade
|
|
|
1 |
repos:
|
2 |
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
+
rev: v5.0.0
|
4 |
hooks:
|
5 |
- id: check-executables-have-shebangs
|
6 |
- id: check-json
|
|
|
13 |
args: ["--fix=lf"]
|
14 |
- id: requirements-txt-fixer
|
15 |
- id: trailing-whitespace
|
16 |
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
17 |
+
rev: v0.8.4
|
18 |
hooks:
|
19 |
+
- id: ruff
|
20 |
+
args: ["--fix"]
|
21 |
+
- id: ruff-format
|
22 |
+
args: ["--line-length", "119"]
|
|
|
|
|
|
|
23 |
- repo: https://github.com/pre-commit/mirrors-mypy
|
24 |
+
rev: v1.14.0
|
25 |
hooks:
|
26 |
- id: mypy
|
27 |
args: ["--ignore-missing-imports"]
|
|
|
32 |
"types-PyYAML",
|
33 |
"types-pytz",
|
34 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
- repo: https://github.com/kynan/nbstripout
|
36 |
+
rev: 0.8.1
|
37 |
hooks:
|
38 |
- id: nbstripout
|
39 |
args:
|
|
|
42 |
"metadata.interpreter metadata.kernelspec cell.metadata.pycharm",
|
43 |
]
|
44 |
- repo: https://github.com/nbQA-dev/nbQA
|
45 |
+
rev: 1.9.1
|
46 |
hooks:
|
47 |
- id: nbqa-black
|
48 |
- id: nbqa-pyupgrade
|
.vscode/extensions.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"recommendations": [
|
3 |
+
"ms-python.python",
|
4 |
+
"charliermarsh.ruff",
|
5 |
+
"streetsidesoftware.code-spell-checker",
|
6 |
+
"tamasfe.even-better-toml"
|
7 |
+
]
|
8 |
+
}
|
.vscode/settings.json
CHANGED
@@ -2,29 +2,20 @@
|
|
2 |
"editor.formatOnSave": true,
|
3 |
"files.insertFinalNewline": false,
|
4 |
"[python]": {
|
5 |
-
"editor.defaultFormatter": "
|
6 |
"editor.formatOnType": true,
|
7 |
"editor.codeActionsOnSave": {
|
|
|
8 |
"source.organizeImports": "explicit"
|
9 |
}
|
10 |
},
|
11 |
"[jupyter]": {
|
12 |
"files.insertFinalNewline": false
|
13 |
},
|
14 |
-
"black-formatter.args": [
|
15 |
-
"--line-length=119"
|
16 |
-
],
|
17 |
-
"isort.args": ["--profile", "black"],
|
18 |
-
"flake8.args": [
|
19 |
-
"--max-line-length=119"
|
20 |
-
],
|
21 |
-
"ruff.lint.args": [
|
22 |
-
"--line-length=119"
|
23 |
-
],
|
24 |
"notebook.output.scrolling": true,
|
25 |
"notebook.formatOnCellExecution": true,
|
26 |
"notebook.formatOnSave.enabled": true,
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
}
|
|
|
2 |
"editor.formatOnSave": true,
|
3 |
"files.insertFinalNewline": false,
|
4 |
"[python]": {
|
5 |
+
"editor.defaultFormatter": "charliermarsh.ruff",
|
6 |
"editor.formatOnType": true,
|
7 |
"editor.codeActionsOnSave": {
|
8 |
+
"source.fixAll.ruff": "explicit",
|
9 |
"source.organizeImports": "explicit"
|
10 |
}
|
11 |
},
|
12 |
"[jupyter]": {
|
13 |
"files.insertFinalNewline": false
|
14 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
"notebook.output.scrolling": true,
|
16 |
"notebook.formatOnCellExecution": true,
|
17 |
"notebook.formatOnSave.enabled": true,
|
18 |
+
"notebook.codeActionsOnSave": {
|
19 |
+
"source.organizeImports": "explicit"
|
20 |
+
}
|
21 |
}
|
README.md
CHANGED
@@ -4,7 +4,7 @@ emoji: ⚡
|
|
4 |
colorFrom: red
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 5.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
4 |
colorFrom: red
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.9.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
app.py
CHANGED
@@ -33,8 +33,7 @@ TEXTBOX_PLACEHOLDER_EN = "Please input text here."
|
|
33 |
def set_default_language(request: gr.Request) -> gr.Radio:
|
34 |
if request.headers["Accept-Language"].split(",")[0].lower().startswith("ja"):
|
35 |
return gr.Radio(value="🇯🇵 JA")
|
36 |
-
|
37 |
-
return gr.Radio(value="🇺🇸 EN")
|
38 |
|
39 |
|
40 |
def switch_ui_language(language: str) -> tuple[gr.Markdown, gr.Textbox]:
|
@@ -43,11 +42,10 @@ def switch_ui_language(language: str) -> tuple[gr.Markdown, gr.Textbox]:
|
|
43 |
gr.Markdown(value=DESCRIPTION_JA),
|
44 |
gr.Textbox(label=TEXTBOX_LABEL_JA, placeholder=TEXTBOX_PLACEHOLDER_JA),
|
45 |
)
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
)
|
51 |
|
52 |
|
53 |
with gr.Blocks(css_paths="style.css") as demo:
|
|
|
33 |
def set_default_language(request: gr.Request) -> gr.Radio:
|
34 |
if request.headers["Accept-Language"].split(",")[0].lower().startswith("ja"):
|
35 |
return gr.Radio(value="🇯🇵 JA")
|
36 |
+
return gr.Radio(value="🇺🇸 EN")
|
|
|
37 |
|
38 |
|
39 |
def switch_ui_language(language: str) -> tuple[gr.Markdown, gr.Textbox]:
|
|
|
42 |
gr.Markdown(value=DESCRIPTION_JA),
|
43 |
gr.Textbox(label=TEXTBOX_LABEL_JA, placeholder=TEXTBOX_PLACEHOLDER_JA),
|
44 |
)
|
45 |
+
return (
|
46 |
+
gr.Markdown(value=DESCRIPTION_EN),
|
47 |
+
gr.Textbox(label=TEXTBOX_LABEL_EN, placeholder=TEXTBOX_PLACEHOLDER_EN),
|
48 |
+
)
|
|
|
49 |
|
50 |
|
51 |
with gr.Blocks(css_paths="style.css") as demo:
|
pyproject.toml
CHANGED
@@ -5,5 +5,41 @@ description = ""
|
|
5 |
readme = "README.md"
|
6 |
requires-python = ">=3.10"
|
7 |
dependencies = [
|
8 |
-
"gradio>=5.1
|
9 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
readme = "README.md"
|
6 |
requires-python = ">=3.10"
|
7 |
dependencies = [
|
8 |
+
"gradio>=5.9.1",
|
9 |
]
|
10 |
+
|
11 |
+
[tool.ruff]
|
12 |
+
line-length = 119
|
13 |
+
|
14 |
+
[tool.ruff.lint]
|
15 |
+
select = ["ALL"]
|
16 |
+
ignore = [
|
17 |
+
"COM812", # missing-trailing-comma
|
18 |
+
"D203", # one-blank-line-before-class
|
19 |
+
"D213", # multi-line-summary-second-line
|
20 |
+
"E501", # line-too-long
|
21 |
+
"SIM117", # multiple-with-statements
|
22 |
+
]
|
23 |
+
extend-ignore = [
|
24 |
+
"D100", # undocumented-public-module
|
25 |
+
"D101", # undocumented-public-class
|
26 |
+
"D102", # undocumented-public-method
|
27 |
+
"D103", # undocumented-public-function
|
28 |
+
"D104", # undocumented-public-package
|
29 |
+
"D105", # undocumented-magic-method
|
30 |
+
"D107", # undocumented-public-init
|
31 |
+
"EM101", # raw-string-in-exception
|
32 |
+
"FBT001", # boolean-type-hint-positional-argument
|
33 |
+
"FBT002", # boolean-default-value-positional-argument
|
34 |
+
"PD901", # pandas-df-variable-name
|
35 |
+
"PGH003", # blanket-type-ignore
|
36 |
+
"PLR0913", # too-many-arguments
|
37 |
+
"PLR0915", # too-many-statements
|
38 |
+
"TRY003", # raise-vanilla-args
|
39 |
+
]
|
40 |
+
unfixable = [
|
41 |
+
"F401", # unused-import
|
42 |
+
]
|
43 |
+
|
44 |
+
[tool.ruff.format]
|
45 |
+
docstring-code-format = true
|
requirements.txt
CHANGED
@@ -4,49 +4,50 @@ aiofiles==23.2.1
|
|
4 |
# via gradio
|
5 |
annotated-types==0.7.0
|
6 |
# via pydantic
|
7 |
-
anyio==4.
|
8 |
# via
|
9 |
# gradio
|
10 |
# httpx
|
11 |
# starlette
|
12 |
-
certifi==2024.
|
13 |
# via
|
14 |
# httpcore
|
15 |
# httpx
|
16 |
# requests
|
17 |
-
charset-normalizer==3.4.
|
18 |
# via requests
|
19 |
-
click==8.1.
|
20 |
# via
|
21 |
# typer
|
22 |
# uvicorn
|
23 |
exceptiongroup==1.2.2
|
24 |
# via anyio
|
25 |
-
fastapi==0.115.
|
26 |
# via gradio
|
27 |
-
ffmpy==0.
|
28 |
# via gradio
|
29 |
filelock==3.16.1
|
30 |
# via huggingface-hub
|
31 |
-
fsspec==2024.
|
32 |
# via
|
33 |
# gradio-client
|
34 |
# huggingface-hub
|
35 |
-
gradio==5.1
|
36 |
# via gradio-language-switch-demo (pyproject.toml)
|
37 |
-
gradio-client==1.
|
38 |
# via gradio
|
39 |
h11==0.14.0
|
40 |
# via
|
41 |
# httpcore
|
42 |
# uvicorn
|
43 |
-
httpcore==1.0.
|
44 |
# via httpx
|
45 |
-
httpx==0.
|
46 |
# via
|
47 |
# gradio
|
48 |
# gradio-client
|
49 |
-
|
|
|
50 |
# via
|
51 |
# gradio
|
52 |
# gradio-client
|
@@ -55,7 +56,7 @@ idna==3.10
|
|
55 |
# anyio
|
56 |
# httpx
|
57 |
# requests
|
58 |
-
jinja2==3.1.
|
59 |
# via gradio
|
60 |
markdown-it-py==3.0.0
|
61 |
# via rich
|
@@ -65,26 +66,26 @@ markupsafe==2.1.5
|
|
65 |
# jinja2
|
66 |
mdurl==0.1.2
|
67 |
# via markdown-it-py
|
68 |
-
numpy==2.1
|
69 |
# via
|
70 |
# gradio
|
71 |
# pandas
|
72 |
-
orjson==3.10.
|
73 |
# via gradio
|
74 |
-
packaging==24.
|
75 |
# via
|
76 |
# gradio
|
77 |
# gradio-client
|
78 |
# huggingface-hub
|
79 |
pandas==2.2.3
|
80 |
# via gradio
|
81 |
-
pillow==
|
82 |
# via gradio
|
83 |
-
pydantic==2.
|
84 |
# via
|
85 |
# fastapi
|
86 |
# gradio
|
87 |
-
pydantic-core==2.
|
88 |
# via pydantic
|
89 |
pydub==0.25.1
|
90 |
# via gradio
|
@@ -92,7 +93,7 @@ pygments==2.18.0
|
|
92 |
# via rich
|
93 |
python-dateutil==2.9.0.post0
|
94 |
# via pandas
|
95 |
-
python-multipart==0.0.
|
96 |
# via gradio
|
97 |
pytz==2024.2
|
98 |
# via pandas
|
@@ -102,27 +103,29 @@ pyyaml==6.0.2
|
|
102 |
# huggingface-hub
|
103 |
requests==2.32.3
|
104 |
# via huggingface-hub
|
105 |
-
rich==13.9.
|
106 |
# via typer
|
107 |
-
ruff==0.
|
|
|
|
|
108 |
# via gradio
|
109 |
semantic-version==2.10.0
|
110 |
# via gradio
|
111 |
shellingham==1.5.4
|
112 |
# via typer
|
113 |
-
six==1.
|
114 |
# via python-dateutil
|
115 |
sniffio==1.3.1
|
|
|
|
|
116 |
# via
|
117 |
-
#
|
118 |
-
#
|
119 |
-
|
120 |
-
# via fastapi
|
121 |
-
tomlkit==0.12.0
|
122 |
# via gradio
|
123 |
-
tqdm==4.
|
124 |
# via huggingface-hub
|
125 |
-
typer==0.
|
126 |
# via gradio
|
127 |
typing-extensions==4.12.2
|
128 |
# via
|
@@ -138,9 +141,9 @@ typing-extensions==4.12.2
|
|
138 |
# uvicorn
|
139 |
tzdata==2024.2
|
140 |
# via pandas
|
141 |
-
urllib3==2.
|
142 |
# via requests
|
143 |
-
uvicorn==0.
|
144 |
# via gradio
|
145 |
-
websockets==
|
146 |
# via gradio-client
|
|
|
4 |
# via gradio
|
5 |
annotated-types==0.7.0
|
6 |
# via pydantic
|
7 |
+
anyio==4.7.0
|
8 |
# via
|
9 |
# gradio
|
10 |
# httpx
|
11 |
# starlette
|
12 |
+
certifi==2024.12.14
|
13 |
# via
|
14 |
# httpcore
|
15 |
# httpx
|
16 |
# requests
|
17 |
+
charset-normalizer==3.4.1
|
18 |
# via requests
|
19 |
+
click==8.1.8
|
20 |
# via
|
21 |
# typer
|
22 |
# uvicorn
|
23 |
exceptiongroup==1.2.2
|
24 |
# via anyio
|
25 |
+
fastapi==0.115.6
|
26 |
# via gradio
|
27 |
+
ffmpy==0.5.0
|
28 |
# via gradio
|
29 |
filelock==3.16.1
|
30 |
# via huggingface-hub
|
31 |
+
fsspec==2024.12.0
|
32 |
# via
|
33 |
# gradio-client
|
34 |
# huggingface-hub
|
35 |
+
gradio==5.9.1
|
36 |
# via gradio-language-switch-demo (pyproject.toml)
|
37 |
+
gradio-client==1.5.2
|
38 |
# via gradio
|
39 |
h11==0.14.0
|
40 |
# via
|
41 |
# httpcore
|
42 |
# uvicorn
|
43 |
+
httpcore==1.0.7
|
44 |
# via httpx
|
45 |
+
httpx==0.28.1
|
46 |
# via
|
47 |
# gradio
|
48 |
# gradio-client
|
49 |
+
# safehttpx
|
50 |
+
huggingface-hub==0.27.0
|
51 |
# via
|
52 |
# gradio
|
53 |
# gradio-client
|
|
|
56 |
# anyio
|
57 |
# httpx
|
58 |
# requests
|
59 |
+
jinja2==3.1.5
|
60 |
# via gradio
|
61 |
markdown-it-py==3.0.0
|
62 |
# via rich
|
|
|
66 |
# jinja2
|
67 |
mdurl==0.1.2
|
68 |
# via markdown-it-py
|
69 |
+
numpy==2.2.1
|
70 |
# via
|
71 |
# gradio
|
72 |
# pandas
|
73 |
+
orjson==3.10.13
|
74 |
# via gradio
|
75 |
+
packaging==24.2
|
76 |
# via
|
77 |
# gradio
|
78 |
# gradio-client
|
79 |
# huggingface-hub
|
80 |
pandas==2.2.3
|
81 |
# via gradio
|
82 |
+
pillow==11.1.0
|
83 |
# via gradio
|
84 |
+
pydantic==2.10.4
|
85 |
# via
|
86 |
# fastapi
|
87 |
# gradio
|
88 |
+
pydantic-core==2.27.2
|
89 |
# via pydantic
|
90 |
pydub==0.25.1
|
91 |
# via gradio
|
|
|
93 |
# via rich
|
94 |
python-dateutil==2.9.0.post0
|
95 |
# via pandas
|
96 |
+
python-multipart==0.0.20
|
97 |
# via gradio
|
98 |
pytz==2024.2
|
99 |
# via pandas
|
|
|
103 |
# huggingface-hub
|
104 |
requests==2.32.3
|
105 |
# via huggingface-hub
|
106 |
+
rich==13.9.4
|
107 |
# via typer
|
108 |
+
ruff==0.8.4
|
109 |
+
# via gradio
|
110 |
+
safehttpx==0.1.6
|
111 |
# via gradio
|
112 |
semantic-version==2.10.0
|
113 |
# via gradio
|
114 |
shellingham==1.5.4
|
115 |
# via typer
|
116 |
+
six==1.17.0
|
117 |
# via python-dateutil
|
118 |
sniffio==1.3.1
|
119 |
+
# via anyio
|
120 |
+
starlette==0.41.3
|
121 |
# via
|
122 |
+
# fastapi
|
123 |
+
# gradio
|
124 |
+
tomlkit==0.13.2
|
|
|
|
|
125 |
# via gradio
|
126 |
+
tqdm==4.67.1
|
127 |
# via huggingface-hub
|
128 |
+
typer==0.15.1
|
129 |
# via gradio
|
130 |
typing-extensions==4.12.2
|
131 |
# via
|
|
|
141 |
# uvicorn
|
142 |
tzdata==2024.2
|
143 |
# via pandas
|
144 |
+
urllib3==2.3.0
|
145 |
# via requests
|
146 |
+
uvicorn==0.34.0
|
147 |
# via gradio
|
148 |
+
websockets==14.1
|
149 |
# via gradio-client
|
uv.lock
CHANGED
The diff for this file is too large to render.
See raw diff
|
|