Skip to content

Commit

Permalink
use lichess client with max retries to avoid getting stuck on evaluat…
Browse files Browse the repository at this point in the history
…ion api call
  • Loading branch information
guidopetri committed Sep 1, 2024
1 parent 98cd597 commit 5ea22b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pipeline_import/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@
from utils.types import Json, Visitor


class LichessApiClient(lichess.api.DefaultApiClient):
max_retries = 3


def get_sf_evaluation(fen: str,
sf_location: Path,
sf_depth: int,
) -> float:
# get cloud eval if available
try:
cloud_eval = lichess.api.cloud_eval(fen=fen, multiPv=1)
client = LichessApiClient()
cloud_eval = lichess.api.cloud_eval(fen=fen, multiPv=1, client=client)
rating = cloud_eval['pvs'][0]
if 'cp' in rating:
rating = rating['cp'] / 100
Expand Down

0 comments on commit 5ea22b8

Please sign in to comment.