Download app.py from Lavanet/gputest: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/Lavanet/gputest/resolve/main/app.py
- Command line
-
hf download hf://spaces/Lavanet/gputest/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Lavanet/gputest/resolve/main/app.py
1.16 kB
| import os | |
| import gradio as gr | |
| from datetime import timezone | |
| from huggingface_hub import get_zero_gpu_quota | |
| def check_quota(): | |
| token = os.environ.get("HF_TOKEN") | |
| if not token: | |
| return "لم يتم العثور على HF_TOKEN في Secrets." | |
| try: | |
| quota = get_zero_gpu_quota(token=token) | |
| reset = quota.resets_at | |
| reset_text = ( | |
| reset.astimezone(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC") | |
| if reset else "لم يحدد النظام موعد التجديد" | |
| ) | |
| return ( | |
| f"الرصيد المتبقي: {quota.remaining / 60:.2f} دقيقة\n" | |
| f"الرصيد الأساسي: {quota.base / 60:.2f} دقيقة\n" | |
| f"موعد التجديد: {reset_text}\n" | |
| f"الرصيد المدفوع المستهلك: " | |
| f"{(quota.overquota_used or 0) / 60:.2f} دقيقة" | |
| ) | |
| except Exception as e: | |
| return f"{type(e).__name__}: {e}" | |
| demo = gr.Interface( | |
| fn=check_quota, | |
| inputs=[], | |
| outputs=gr.Textbox(label="نتيجة فحص ZeroGPU", lines=6), | |
| title="ZeroGPU Quota Checker", | |
| ) | |
| demo.launch() | |