Skip to content
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

Introduce Calculate Elo API for external use. #1742

Merged
merged 1 commit into from
Aug 19, 2023

Conversation

peregrineshahin
Copy link
Contributor

@peregrineshahin peregrineshahin commented Jul 9, 2023

This should make it possible for external use to calculate the ELo based on Either (Ptnml or WDL) and elo0, elo1 bounds (elo_model is optional and defaults to "normalized").

The format is:
https://tests.stockfishchess.org/api/calc_elo?LL=93&LD=18711&DDWL=58877&WD=18739&WW=100&elo0=-1.75&elo1=0.25

needs testing.

@vondele
Copy link
Member

vondele commented Jul 9, 2023

Maybe consider renaming "DD" in "DDWL" to make clear this is not just about DD

Also, for the purpose discussed on discord, this probably should have an nginx cache enabled.

@peregrineshahin peregrineshahin force-pushed the Calc_elo-APi branch 8 times, most recently from 2cf0431 to db543fb Compare July 9, 2023 11:17
@peregrineshahin
Copy link
Contributor Author

solved the issue of CI
by adding --trailing-comma none and formatted the code with that option.

prettier --check "server/fishtest/static/{css/*.css,html/*.html,js/*.js}" --trailing-comma none
      - name: Check linters and formatters status
        run: |
          echo "Run the following commands to format the code:"
          echo "black --exclude='env|packages' ."
          echo "isort --profile black --skip env --skip venv --skip worker/packages ."
          echo "npx prettier --write 'server/fishtest/static/{css/*.css,html/*.html,js/*.js}' --trailing-comma none"

@peregrineshahin peregrineshahin force-pushed the Calc_elo-APi branch 3 times, most recently from f7e40bf to 3cb7683 Compare July 9, 2023 17:05
@ppigazzini ppigazzini added enhancement server server side changes labels Aug 19, 2023
server/fishtest/api.py Outdated Show resolved Hide resolved
@peregrineshahin peregrineshahin force-pushed the Calc_elo-APi branch 2 times, most recently from ad7a644 to ddadc22 Compare August 19, 2023 09:44
@ppigazzini
Copy link
Collaborator

DEV updated.

@peregrineshahin
Copy link
Contributor Author

peregrineshahin commented Aug 19, 2023

DEV updated.

It works but it seems like handling errors does not work. any idea what's wrong with calling self.handle_error()

@ppigazzini
Copy link
Collaborator

ppigazzini commented Aug 19, 2023

It works but it seems like handling errors does not work. any idea what's wrong with calling self.handle_error()

-- Logs begin at Sun 2023-08-13 13:24:46 CEST, end at Sat 2023-08-19 13:18:28 CEST. --
Aug 19 13:18:20 dfts-0 pserve[30511]: 2023-08-19 13:18:20,309 ERROR [waitress][waitress-1] Exception while serving /api/calc_elo
Aug 19 13:18:20 dfts-0 pserve[30511]: Traceback (most recent call last):
Aug 19 13:18:20 dfts-0 pserve[30511]:   File "/home/usr00/fishtest/server/env/lib/python3.11/site-packages/pyramid/tweens.py", line 13, in _error_handler
Aug 19 13:18:20 dfts-0 pserve[30511]:     response = request.invoke_exception_view(exc_info)
Aug 19 13:18:20 dfts-0 pserve[30511]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
packages/pyramid/viewderivers.py", line 113, in _class_requestonly_view
Aug 19 13:18:20 dfts-0 pserve[30511]:     response = getattr(inst, attr)()
Aug 19 13:18:20 dfts-0 pserve[30511]:                ^^^^^^^^^^^^^^^^^^^^^
Aug 19 13:18:20 dfts-0 pserve[30511]:   File "/home/usr00/fishtest/server/fishtest/api.py", line 384, in calc_elo
Aug 19 13:18:20 dfts-0 pserve[30511]:     self.handle_error(
Aug 19 13:18:20 dfts-0 pserve[30511]:   File "/home/usr00/fishtest/server/fishtest/api.py", line 124, in handle_error
Aug 19 13:18:20 dfts-0 pserve[30511]:     error = "{}: {}".format(self.__api, error)
Aug 19 13:18:20 dfts-0 pserve[30511]:                             ^^^^^^^^^^
Aug 19 13:18:20 dfts-0 pserve[30511]: AttributeError: 'ApiView' object has no attribute '_ApiView__api'

@ppigazzini
Copy link
Collaborator

ppigazzini commented Aug 19, 2023

If I read correctly the code, self.handle_error() is a custom function used to handle an error during the validation of the worker's APIs. It depends on validate_username_password() to work:
https://github.com/glinscott/fishtest/blob/3cb76834a6cabc72ab479f13f5b74190fc1bf35e/server/fishtest/api.py#L122-L131

@peregrineshahin
Copy link
Contributor Author

initialized the mandatory Class variables to use the function and return a 400.

This should make it possible for external use to calculate the ELo based on Either (Ptnml or WDL) and elo0, elo1 bounds (elo_model is optional and defaults to "normalized").

The format is:
https://tests.stockfishchess.org/api/calc_elo?LL=93&LD=18711&DDWL=58877&WD=18739&WW=100&elo0=-1.75&elo1=0.25

needs testing.

Introduce Calculate Elo API for external use.

This should make it possible for external use to calculate the ELo based on Either (Ptnml or WDL) and elo0, elo1 bounds (elo_model is optional and defaults to "normalized").

The format is:
https://tests.stockfishchess.org/api/calc_elo?LL=93&LD=18711&DDWL=58877&WD=18739&WW=100&elo0=-1.75&elo1=0.25

needs testing.

Introduce Calculate Elo API for external use.

This should make it possible for external use to calculate the ELo based on Either (Ptnml or WDL) and elo0, elo1 bounds (elo_model is optional and defaults to "normalized").

The format is:
https://tests.stockfishchess.org/api/calc_elo?LL=93&LD=18711&DDWL=58877&WD=18739&WW=100&elo0=-1.75&elo1=0.25

needs testing.
Copy link
Collaborator

@ppigazzini ppigazzini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG on DEV

@ppigazzini ppigazzini merged commit b708fe7 into official-stockfish:master Aug 19, 2023
17 checks passed
@ppigazzini
Copy link
Collaborator

ppigazzini commented Aug 19, 2023

PROD updated, nginx configured to serve the route with the pserve instance on port 6545. The nginx admin should check for the nginx cache. Thank you @peregrineshahin :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement server server side changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants