-
Notifications
You must be signed in to change notification settings - Fork 1
Add Lichess integration #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
olivierphi
wants to merge
42
commits into
main
Choose a base branch
from
add-lichess-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
☂️ Python Coverage
Overall Coverage
New Files
Modified Files
|
It will be a long run 😅, but hey that's the very first stone now laid. With this 1st commit we add an ugly-but-functional Oauth2 flow that allows a user to get an API token from Lichess.
Still super basic and ugly at the moment, but that's a good start :-)
As Lichess-related Views will mainly be proxies to the Lichess HTTP API, we would likely benefit from being able to not block workers' threads while the I/O between our server and Lichess are taking place.
9188878
to
0c746f3
Compare
We can now create correspondence games on Lichess, and display the ongoing games. [bugfix] Our assets are now correctly served straight from the "static/" folder of each app in development mode, even though we stopped using "runserver" - thanks to WhiteNoise. Misc other bugfixes here and there.
0c746f3
to
24769a5
Compare
There's still a hell lot of work to do 😅, but hey that's a first milestone reached :-)
Baby steps! Still ugly as hell, but we'll get there :-)
That wouldn't be very fair, right? 😅
Because we want to cache the result of many of our chess-related functions, we'd better use immutable data structures (such as NamedTuples) to prevent bugs where we would unintentionally mutate a cached result, used by the whole app.
Let's use `pip install -e .` instead
...which comes with unexpected required updates, as we now have to manage that cache using the async API when our Views are async 😅 (which makes complete sense in retrospect, but I didn't see it coming :-)
Better than using our quick-n-dirty manual solution 😅
And while we're here... Let's change the "active/opponent" semantic of the CSS classes we add to selected pieces and targets to "playable/non-playable", which is more accurate and generic.
For some reason, it seems that the "game export" ednpoint returns outdated information about the ongoing games. It was returning up-to-date data until yesterday, but for a mysterious reason it stopped doing so 🤷 Maybe it returns only the few first moves, when the game is still ongoing? Anyway... Thankfully, it seems that using the "Stream Board game state" endpoint works correctly. 🤞🤞🤞 Also improve code there and there while I was here :-)
…d there Still pretty ugly overall... but we're working on it 😅
Design is hard - especially when you have no natural talent nor acquired skills for it 😅
1b0e713
to
1d60d71
Compare
19edbcc
to
a9f8e49
Compare
We're not using them anyhow, since our bot ended up being based on a WebAssembly version of Stockfish, running in te player's own browser.
Now that the next major version of Python finally seems to land with PEP 649 implemented, it seems safe to use `from __future__ import annotations` everywhere we use non-builtin type hints :-) And thanks to the "flake8 type-checking" rules (re-implemented in Ruff), we can make sure we're still using "if TYPE_CHECKING:" for type-only imports 👌
4c6e17c
to
34a0378
Compare
That will give us better semantics, and should make maintenance a bit easier in the long term 🤞
…e install the project in editable mode
…ponents This should lead to better code overall, with the extra benefit of preparing the ground for the Lichess UI
…to Lichess The UI for this is pretty basic for now, but as implementing this and the "atoms" & "molecules" design was my goal for today's session... I'll call it a day! :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP...
Roadmap:
Probably for later: