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

Add batching leaderboard generator. #984

Merged
merged 2 commits into from
Dec 13, 2023
Merged

Conversation

Andrei-Dolgolev
Copy link
Contributor

@Andrei-Dolgolev Andrei-Dolgolev commented Dec 12, 2023

Add batching upload scores to leaderboard.
test

leaderboards-generator leaderboards-generate --query-api-access-token $MOONSTREAM_TOKEN --leaderboard_id <id_of_leaderboard>(where amount of scores more then 20k)

Add cli params --leaderboard-push-batch-size and --leaderboard-push-timeout-seconds
Via parameter --leaderboard_id now can run any leaderboard config.

Logic:
Create_version - > upload in batch -> make version public -> delete (new_version -1)

Copy link
Contributor

@zomglings zomglings left a comment

Choose a reason for hiding this comment

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

lgtm


leaderboard_version_push_api_url = f"{MOONSTREAM_ENGINE_URL}/leaderboard/{leaderboard_id}/versions/{leaderboard_version_id}/scores?normalize_addresses={leaderboard_config['normalize_addresses']}&overwrite=false"

chunks = chunk_data(data, chunk_size=batch_size)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can also use a generator comprehension here instead of defining def chunk_data... function:

chunks = (data[i:i+batch_size] for i in range(0, len(data), batch_size))

See this for more details on generator comprehensions: https://python-reference.readthedocs.io/en/latest/docs/comprehensions/gen_expression.html

@Andrei-Dolgolev Andrei-Dolgolev merged commit b7ea344 into main Dec 13, 2023
1 of 2 checks passed
@Andrei-Dolgolev Andrei-Dolgolev deleted the leaderboard-push-batching branch December 13, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants