fix analysis failure handling
parent
e0c1474653
commit
5140740a0c
|
@ -36,7 +36,7 @@ object Ai extends LilaController {
|
|||
requestedByHuman = getBool("human", req),
|
||||
variant = requestVariant(req)
|
||||
).effectFold(
|
||||
err => WS.url(replyToUrl).post(err.toString),
|
||||
err => WS.url(s"$replyToUrl/err").post(err.toString),
|
||||
infos => WS.url(replyToUrl).post(lila.analyse.Info encodeList infos)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@ object Analyse extends LilaController {
|
|||
} inject Ok
|
||||
}
|
||||
|
||||
def postAnalysisErr(id: String) = Action(parse.text) { req =>
|
||||
env.analyser.completeErr(id, req.body, req.remoteAddress)
|
||||
logwarn(s"AI failure ${req.remoteAddress} ${req.body}")
|
||||
Ok
|
||||
}
|
||||
|
||||
def replay(pov: Pov, userTv: Option[lila.user.User])(implicit ctx: Context) =
|
||||
if (HTTPRequest isBot ctx.req) replayBot(pov)
|
||||
else GameRepo initialFen pov.game.id flatMap { initialFen =>
|
||||
|
|
|
@ -168,8 +168,9 @@ GET /team/:id/kick controllers.Team.kickForm(id: Stri
|
|||
POST /team/:id/kick controllers.Team.kick(id: String)
|
||||
|
||||
# Analyse
|
||||
POST /$gameId<\w{8}>/request-analysis controllers.Analyse.requestAnalysis(gameId: String)
|
||||
POST /$gameId<\w{8}>/post-analysis controllers.Analyse.postAnalysis(gameId: String)
|
||||
POST /$gameId<\w{8}>/request-analysis controllers.Analyse.requestAnalysis(gameId: String)
|
||||
POST /$gameId<\w{8}>/post-analysis controllers.Analyse.postAnalysis(gameId: String)
|
||||
POST /$gameId<\w{8}>/post-analysis/err controllers.Analyse.postAnalysisErr(gameId: String)
|
||||
|
||||
GET /game/export/$gameId<\w{8}>.pgn controllers.Export.pgn(gameId: String)
|
||||
GET /game/export/pdf/$gameId<\w{8}>.pdf controllers.Export.pdf(gameId: String)
|
||||
|
|
|
@ -40,10 +40,7 @@ final class Client(
|
|||
} yield PlayResult(progress, move)
|
||||
}
|
||||
|
||||
private val networkLatency = 1 second
|
||||
|
||||
def move(uciMoves: List[String], initialFen: Option[String], level: Int, variant: Variant): Fu[MoveResult] = {
|
||||
implicit val timeout = makeTimeout(config.playTimeout + networkLatency)
|
||||
sendRequest(true) {
|
||||
WS.url(s"$endpoint/move").withQueryString(
|
||||
"uciMoves" -> uciMoves.mkString(" "),
|
||||
|
|
|
@ -23,6 +23,7 @@ final class Analyser(
|
|||
modActor: ActorSelection) {
|
||||
|
||||
def get(id: String): Fu[Option[Analysis]] = AnalysisRepo byId id flatMap evictStalled
|
||||
def getNotDone(id: String): Fu[Option[Analysis]] = AnalysisRepo notDoneById id flatMap evictStalled
|
||||
|
||||
def getDone(id: String): Fu[Option[Analysis]] = AnalysisRepo doneById id flatMap evictStalled
|
||||
|
||||
|
@ -91,4 +92,9 @@ final class Analyser(
|
|||
} addFailureEffect {
|
||||
_ => AnalysisRepo remove id
|
||||
}
|
||||
|
||||
def completeErr(id: String, err: String, from: String) =
|
||||
$find.byId[Game](id) zip getNotDone(id) flatMap {
|
||||
case (Some(game), Some(a1)) if game.analysable => AnalysisRepo remove id
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@ object AnalysisRepo {
|
|||
def doneById(id: ID): Fu[Option[Analysis]] =
|
||||
$find.one($select(id) ++ Json.obj("done" -> true))
|
||||
|
||||
def notDoneById(id: ID): Fu[Option[Analysis]] =
|
||||
$find.one($select(id) ++ Json.obj("done" -> false))
|
||||
|
||||
def doneByIds(ids: Seq[ID]): Fu[Seq[Option[Analysis]]] =
|
||||
$find optionsByOrderedIds ids map2 { (a: Option[Analysis]) =>
|
||||
a.filter(_.done)
|
||||
|
|
Loading…
Reference in New Issue