Spaces:
Build error
Build error
Download src/rate_limiting.py from Ahmedhajjajworkspace/open_llm_leaderboard: direct link, hf CLI and curl.
- Browser
- Download file 577 Bytes
-
https://huggingface.co/spaces/Ahmedhajjajworkspace/open_llm_leaderboard/resolve/06acefdca9f85d474bb85b4353502970edcfe289/src/rate_limiting.py
- Command line
-
hf download hf://spaces/Ahmedhajjajworkspace/open_llm_leaderboard@06acefdca9f85d474bb85b4353502970edcfe289/src/rate_limiting.py
-
curl -L -o rate_limiting.py https://huggingface.co/spaces/Ahmedhajjajworkspace/open_llm_leaderboard/resolve/06acefdca9f85d474bb85b4353502970edcfe289/src/rate_limiting.py
577 Bytes
| from datetime import datetime, timedelta, timezone | |
| def user_submission_permission(submission_name, users_to_submission_dates, rate_limit_period): | |
| org_or_user, _ = submission_name.split("/") | |
| if org_or_user not in users_to_submission_dates: | |
| return 0 | |
| submission_dates = sorted(users_to_submission_dates[org_or_user]) | |
| time_limit = (datetime.now(timezone.utc) - timedelta(days=rate_limit_period)).strftime("%Y-%m-%dT%H:%M:%SZ") | |
| submissions_after_timelimit = [d for d in submission_dates if d > time_limit] | |
| return len(submissions_after_timelimit) | |