Download setup_cronjob.py from dirven/numerai_all_48_models: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/datasets/dirven/numerai_all_48_models/resolve/main/setup_cronjob.py
- Command line
-
hf download hf://datasets/dirven/numerai_all_48_models/setup_cronjob.py
-
curl -L -o setup_cronjob.py https://huggingface.co/datasets/dirven/numerai_all_48_models/resolve/main/setup_cronjob.py
1.6 kB
| """Manage cron-job.org jobs for Numerai orchestrator""" | |
| import requests | |
| import json | |
| CRONJOB_API = "https://api.cron-job.org" | |
| CRONJOB_KEY = "qhGses5hN/WwOoRySWvffihEyh5dPQtJFCkm2gyaSfs=" | |
| HF_URL = "https://dirven-numerai-all-48.hf.space/trigger?token=qhGses5hN/WwOoRySWvffihEyh5dPQtJFCkm2gyaSfs=" | |
| headers = { | |
| 'Authorization': f'Bearer {CRONJOB_KEY}', | |
| 'Content-Type': 'application/json' | |
| } | |
| # List existing jobs | |
| print("Listing existing jobs...") | |
| resp = requests.get(f"{CRONJOB_API}/jobs", headers=headers) | |
| jobs = resp.json().get('jobs', []) | |
| print(f"Found {len(jobs)} existing jobs") | |
| for job in jobs: | |
| print(f" Deleting job {job['jobId']}: {job['title']}") | |
| requests.delete(f"{CRONJOB_API}/jobs/{job['jobId']}", headers=headers) | |
| print("Creating new trigger job...") | |
| # Create job for Tue-Sat at 12UTC | |
| new_job = { | |
| "job": { | |
| "url": HF_URL, | |
| "title": "Numerai 48 Models Trigger", | |
| "enabled": True, | |
| "saveResponses": True, | |
| "requestTimeout": 300, | |
| "requestMethod": 0, # GET | |
| "schedule": { | |
| "timezone": "UTC", | |
| "expiresAt": 0, | |
| "hours": [12], | |
| "mdays": [-1], | |
| "minutes": [0], | |
| "months": [-1], | |
| "wdays": [2, 3, 4, 5, 6] # Tue-Sat | |
| } | |
| } | |
| } | |
| resp = requests.put(f"{CRONJOB_API}/jobs", headers=headers, data=json.dumps(new_job)) | |
| if resp.status_code == 200: | |
| job_id = resp.json().get('jobId') | |
| print(f"Created job ID: {job_id}") | |
| print(f"URL: {HF_URL}") | |
| print("Schedule: 12:00 UTC, Tuesday-Saturday") | |
| else: | |
| print(f"Error: {resp.text}") |