Finalize major update
Browse files- README.md +22 -4
- docs/cli.md +77 -0
- src/chessli2/cli.py +3 -2
- tests/test_cli.py +4 -5
README.md
CHANGED
@@ -11,12 +11,12 @@ pinned: True
|
|
11 |
|
12 |
# Welcome to Chessli2 π°
|
13 |
|
14 |
-
[
|
15 |
|
16 |
## Why a second version?
|
17 |
|
18 |
-
Incredibly, despite my prolonged absence, I continue to receive heartfelt π thank you notes and eager requests for
|
19 |
-
This overwhelming support has inspired me to develop a sleek new version of
|
20 |
|
21 |
## Features π
|
22 |
|
@@ -29,7 +29,7 @@ Chessli2 is here to support your journey to becoming a chess master. Dive in and
|
|
29 |
|
30 |
## Quickstart π
|
31 |
|
32 |
-
### π Click here to try out the app directly:
|
33 |
[**Chessli2**](https://pwenker-chessli2.hf.space/)
|
34 |
|
35 |
### π Inspect code at:
|
@@ -65,6 +65,9 @@ For more details, visit: [Basics - Rye](https://rye-up.com/guide/basics/)
|
|
65 |
|
66 |
### Start the App π
|
67 |
|
|
|
|
|
|
|
68 |
Launch the app using:
|
69 |
```
|
70 |
rye run python src/chessli2/app.py
|
@@ -72,6 +75,21 @@ rye run python src/chessli2/app.py
|
|
72 |
|
73 |
Finally, open your browser and visit [http://localhost:7860](http://localhost:7860/) to start practicing!
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
## FAQ
|
76 |
|
77 |
### ποΈ How to Obtain Your Lichess API Token
|
|
|
11 |
|
12 |
# Welcome to Chessli2 π°
|
13 |
|
14 |
+
[chessli2](https://github.com/pwenker/chessli2) is your **always free** and **open-source** chess trainer π‘οΈ, designed to elevate your game by allowing you to analyze games, identify mistakes, and sharpen your tactics, all sourced directly from [lichess.org](https://lichess.org/).
|
15 |
|
16 |
## Why a second version?
|
17 |
|
18 |
+
Incredibly, despite my prolonged absence, I continue to receive heartfelt π thank you notes and eager requests for [chessli](https://github.com/pwenker/chessli).
|
19 |
+
This overwhelming support has inspired me to develop a sleek new version of `chessli` that not only squashes all those pesky bugs π but also introduces a user-friendly graphical interface. This means no programming experience is required to dive in!
|
20 |
|
21 |
## Features π
|
22 |
|
|
|
29 |
|
30 |
## Quickstart π
|
31 |
|
32 |
+
### π Click here to try out the app directly without any setup:
|
33 |
[**Chessli2**](https://pwenker-chessli2.hf.space/)
|
34 |
|
35 |
### π Inspect code at:
|
|
|
65 |
|
66 |
### Start the App π
|
67 |
|
68 |
+
> [!NOTE]
|
69 |
+
> If you choose to install `chessli2` without `rye`, or in case you activate the rye shell with `rye shell`, just omit `rye run` for the following commands.
|
70 |
+
|
71 |
Launch the app using:
|
72 |
```
|
73 |
rye run python src/chessli2/app.py
|
|
|
75 |
|
76 |
Finally, open your browser and visit [http://localhost:7860](http://localhost:7860/) to start practicing!
|
77 |
|
78 |
+
|
79 |
+
## Programmatic Access
|
80 |
+
|
81 |
+
### API endpoints
|
82 |
+
Thanks to [Gradio](https://www.gradio.app/), you can find an API documentation for `chessli2` at [Chessli2 API](https://pwenker-chessli2.hf.space/?view=api).
|
83 |
+
|
84 |
+
### CLI
|
85 |
+
|
86 |
+
There is also a CLI, for usage information type:
|
87 |
+
```
|
88 |
+
rye run chessli2 --help
|
89 |
+
```
|
90 |
+
|
91 |
+
For complete usage information of all commands and options, take a look at the CLI documentation at [docs/cli.md](docs/cli.md).
|
92 |
+
|
93 |
## FAQ
|
94 |
|
95 |
### ποΈ How to Obtain Your Lichess API Token
|
docs/cli.md
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# `chessli2`
|
2 |
+
|
3 |
+
**Usage**:
|
4 |
+
|
5 |
+
```console
|
6 |
+
$ chessli2 [OPTIONS] COMMAND [ARGS]...
|
7 |
+
```
|
8 |
+
|
9 |
+
**Options**:
|
10 |
+
|
11 |
+
* `--install-completion`: Install completion for the current shell.
|
12 |
+
* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
|
13 |
+
* `--help`: Show this message and exit.
|
14 |
+
|
15 |
+
**Commands**:
|
16 |
+
|
17 |
+
* `mistakes`: Fetches mistakes from the API based on the...
|
18 |
+
* `puzzles`: Fetches puzzles from the API based on the...
|
19 |
+
* `serve`: Starts the app and serves it given...
|
20 |
+
|
21 |
+
## `chessli2 mistakes`
|
22 |
+
|
23 |
+
Fetches mistakes from the API based on the specified parameters.
|
24 |
+
|
25 |
+
**Usage**:
|
26 |
+
|
27 |
+
```console
|
28 |
+
$ chessli2 mistakes [OPTIONS]
|
29 |
+
```
|
30 |
+
|
31 |
+
**Options**:
|
32 |
+
|
33 |
+
* `--src TEXT`: Select either the name of the Hugging Face Space to load, (e.g. "pwenker/chessli2") or the full URL (including "http" or "https") of the hosted Gradio app to load (e.g. "http://localhost:7860/" or "https://bec81a83-5b5c-471e.gradio.live/ [default: pwenker/chessli2]
|
34 |
+
* `--lichess-api-token TEXT`: Select lichess API token [default: lip_5tGPs3qUPcYoWpSnEZfH]
|
35 |
+
* `--user-name TEXT`: Select user name [default: pwenker]
|
36 |
+
* `--start-date TEXT`: Select start date (YYYY-MM-DD) [default: 2017-05-14]
|
37 |
+
* `--end-date TEXT`: Select end date (YYYY-MM-DD) [default: 2024-05-14]
|
38 |
+
* `--nags INTEGER`: Filter by mistake nag type (blunder=4, mistake=2, speculative=5, dubious=6) [default: 4, 2]
|
39 |
+
* `--time-control [Bullet|Blitz|Rapid|Classical|UltraBullet|All Time Controls]`: Filter by time control [default: All Time Controls]
|
40 |
+
* `--output [file|info|pgn]`: Select whether to output mistakes as markdown table, as PGN string, or file path of CSV file containing PGNS [default: file]
|
41 |
+
* `--help`: Show this message and exit.
|
42 |
+
|
43 |
+
## `chessli2 puzzles`
|
44 |
+
|
45 |
+
Fetches puzzles from the API based on the specified parameters.
|
46 |
+
|
47 |
+
**Usage**:
|
48 |
+
|
49 |
+
```console
|
50 |
+
$ chessli2 puzzles [OPTIONS]
|
51 |
+
```
|
52 |
+
|
53 |
+
**Options**:
|
54 |
+
|
55 |
+
* `--src TEXT`: Select either the name of the Hugging Face Space to load, (e.g. 'pwenker/chessli2') or the full URL (including 'http' or 'https') of the hosted Gradio app to load (e.g. 'http://localhost:7860/' or 'https://bec81a83-5b5c-471e.gradio.live/') [default: http://pwenker.github.io/chessli2/]
|
56 |
+
* `--lichess-api-token TEXT`: Select lichess API token [default: lip_5tGPs3qUPcYoWpSnEZfH]
|
57 |
+
* `--before TEXT`: Only get puzzle activity before this date (format YYYY-MM-DD) [default: 2024-05-15]
|
58 |
+
* `--max INTEGER`: Select maxmimum number of puzzles [default: 100]
|
59 |
+
* `--themes [Advanced pawn|Advantage|Anastasia's mate|Arabian mate|Attacking f2 or f7|Attraction|Back rank mate|Bishop endgame|Boden's mate|Castling|Capture the defender|Crushing|Double bishop mate|Dovetail mate|Equality|Kingside attack|Clearance|Defensive move|Deflection|Discovered attack|Double check|Endgame|Exposed king|Fork|Hanging piece|Hook mate|Interference|Intermezzo|Knight endgame|Long puzzle|Master games|Master vs Master games|Checkmate|Mate in 1|Mate in 2|Mate in 3|Mate in 4|Mate in 5 or more|Middlegame|One-move puzzle|Opening|Pawn endgame|Pin|Promotion|Queen endgame|Queen and Rook|Queenside attack|Quiet move|Rook endgame|Sacrifice|Short puzzle|Skewer|Smothered mate|Super GM games|Trapped piece|Underpromotion|Very long puzzle|X-Ray attack|Zugzwang|Healthy mix|Player games]`: Filter by puzzle themes [default: Advanced pawn, Advantage, Anastasia's mate, Arabian mate, Attacking f2 or f7, Attraction, Back rank mate, Bishop endgame, Boden's mate, Castling, Capture the defender, Crushing, Double bishop mate, Dovetail mate, Equality, Kingside attack, Clearance, Defensive move, Deflection, Discovered attack, Double check, Endgame, Exposed king, Fork, Hanging piece, Hook mate, Interference, Intermezzo, Knight endgame, Long puzzle, Master games, Master vs Master games, Checkmate, Mate in 1, Mate in 2, Mate in 3, Mate in 4, Mate in 5 or more, Middlegame, One-move puzzle, Opening, Pawn endgame, Pin, Promotion, Queen endgame, Queen and Rook, Queenside attack, Quiet move, Rook endgame, Sacrifice, Short puzzle, Skewer, Smothered mate, Super GM games, Trapped piece, Underpromotion, Very long puzzle, X-Ray attack, Zugzwang, Healthy mix, Player games]
|
60 |
+
* `--output [file|info|pgn]`: Select whether to output info about mistakes, mistakes as PGN string, or a file path of CSV file containing PGNs [default: file]
|
61 |
+
* `--help`: Show this message and exit.
|
62 |
+
|
63 |
+
## `chessli2 serve`
|
64 |
+
|
65 |
+
Starts the app and serves it given specified `server_name` and `server_port`.
|
66 |
+
|
67 |
+
**Usage**:
|
68 |
+
|
69 |
+
```console
|
70 |
+
$ chessli2 serve [OPTIONS]
|
71 |
+
```
|
72 |
+
|
73 |
+
**Options**:
|
74 |
+
|
75 |
+
* `--server-name TEXT`: To make app accessible on local network, set this to '0.0.0.0'. Can be set by environment variable GRADIO_SERVER_NAME. If None, will use '127.0.0.1 [default: 127.0.0.1]
|
76 |
+
* `--server-port INTEGER`: Will start gradio app on this port (if available). Can be set by environment variable GRADIO_SERVER_PORT. If None, will search for an available port starting at 7860. [default: 7860]
|
77 |
+
* `--help`: Show this message and exit.
|
src/chessli2/cli.py
CHANGED
@@ -72,7 +72,7 @@ def mistakes(
|
|
72 |
elif output == Output.pgn:
|
73 |
print(mistake_pgns)
|
74 |
elif output == Output.file:
|
75 |
-
print(mistake_csv
|
76 |
|
77 |
|
78 |
@app.command()
|
@@ -107,6 +107,7 @@ def puzzles(
|
|
107 |
before=before,
|
108 |
max=max,
|
109 |
themes_selection=themes,
|
|
|
110 |
api_name="/get_puzzles",
|
111 |
)
|
112 |
|
@@ -115,7 +116,7 @@ def puzzles(
|
|
115 |
elif output == Output.pgn:
|
116 |
print(puzzle_pgns)
|
117 |
elif output == Output.file:
|
118 |
-
print(puzzle_csv
|
119 |
|
120 |
|
121 |
if __name__ == "__main__":
|
|
|
72 |
elif output == Output.pgn:
|
73 |
print(mistake_pgns)
|
74 |
elif output == Output.file:
|
75 |
+
print(mistake_csv.get("value", "No mistakes found"))
|
76 |
|
77 |
|
78 |
@app.command()
|
|
|
107 |
before=before,
|
108 |
max=max,
|
109 |
themes_selection=themes,
|
110 |
+
lichess_api_token=lichess_api_token,
|
111 |
api_name="/get_puzzles",
|
112 |
)
|
113 |
|
|
|
116 |
elif output == Output.pgn:
|
117 |
print(puzzle_pgns)
|
118 |
elif output == Output.file:
|
119 |
+
print(puzzle_csv.get("value", "No puzzles found"))
|
120 |
|
121 |
|
122 |
if __name__ == "__main__":
|
tests/test_cli.py
CHANGED
@@ -6,10 +6,10 @@ from chessli2.settings import settings
|
|
6 |
|
7 |
runner = CliRunner()
|
8 |
|
9 |
-
sources = ["pwenker/chessli2", "http://localhost:7860"]
|
10 |
|
11 |
|
12 |
-
@pytest.mark.parametrize("src",
|
13 |
def test_mistakes_with_options(src):
|
14 |
result = runner.invoke(
|
15 |
app,
|
@@ -38,7 +38,7 @@ def test_mistakes_with_options(src):
|
|
38 |
assert result.exit_code == 0
|
39 |
|
40 |
|
41 |
-
@pytest.mark.parametrize("src",
|
42 |
def test_puzzles_with_options(src):
|
43 |
"""
|
44 |
chessli puzzles --src http://localhost:7860 --user-name pwenker --before 2024-05-14 --max 100 --output file
|
@@ -54,10 +54,9 @@ def test_puzzles_with_options(src):
|
|
54 |
"--before",
|
55 |
"2024-05-14",
|
56 |
"--max",
|
57 |
-
|
58 |
"--output",
|
59 |
"file",
|
60 |
],
|
61 |
)
|
62 |
-
__import__('pdb').set_trace()
|
63 |
assert result.exit_code == 0
|
|
|
6 |
|
7 |
runner = CliRunner()
|
8 |
|
9 |
+
sources = ["pwenker/chessli2"] # , "http://localhost:7860"]
|
10 |
|
11 |
|
12 |
+
@pytest.mark.parametrize("src", sources)
|
13 |
def test_mistakes_with_options(src):
|
14 |
result = runner.invoke(
|
15 |
app,
|
|
|
38 |
assert result.exit_code == 0
|
39 |
|
40 |
|
41 |
+
@pytest.mark.parametrize("src", sources)
|
42 |
def test_puzzles_with_options(src):
|
43 |
"""
|
44 |
chessli puzzles --src http://localhost:7860 --user-name pwenker --before 2024-05-14 --max 100 --output file
|
|
|
54 |
"--before",
|
55 |
"2024-05-14",
|
56 |
"--max",
|
57 |
+
10,
|
58 |
"--output",
|
59 |
"file",
|
60 |
],
|
61 |
)
|
|
|
62 |
assert result.exit_code == 0
|