-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtest_scoring_api.py
56 lines (49 loc) · 1.71 KB
/
test_scoring_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import sys
import json
import time
import requests
from requests.auth import HTTPBasicAuth
import bittensor as bt
from neurons.scoring_manager import ScoreModelInputs
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--scoring_api_url", type=str, default="http://localhost:8080")
parser.add_argument("--hf_repo_id", type=str)
parser.add_argument("--competition_id", type=str)
parser.add_argument("--block", type=int, default=0)
bt.wallet.add_args(parser)
config = bt.config(parser)
wallet = bt.wallet(config=config)
keypair = wallet.hotkey
if len(sys.argv) < 2:
print("Please provide the API URL as a command line argument")
sys.exit(1)
post_url = f"{config.scoring_api_url}/api/start_model_scoring"
get_url = f"{config.scoring_api_url}/api/check_scoring_status"
hotkey = keypair.ss58_address
signature = f"0x{keypair.sign(hotkey).hex()}"
inputs = ScoreModelInputs(
hf_repo_id=config.hf_repo_id,
competition_id=config.competition_id,
hotkey="5FeqmebkCWfepQPgSkrEHRwtpUmHGASF4BNERZDs9pvKFtcD",
block=config.block,
)
# inputs = ScoreModelInputs(
# hf_repo_id="tezuesh/moshi_general",
# competition_id="v1",
# hotkey="5FeqmebkCWfepQPgSkrEHRwtpUmHGASF4BNERZDs9pvKFtcD",
# block=0,
# )
# inputs = ScoreModelInputs(
# hf_repo_id="tezuesh/IBLlama_v1",
# competition_id="o1",
# hotkey="5CVaXUhgrH3KvSpdu9Gh1k44ZcscRfAaS3yudXEZmwxsw52G",
# block=0,
# )
status = "scoring"
print(requests.post(post_url, auth=HTTPBasicAuth(hotkey, signature), json=json.loads(inputs.model_dump_json())).json())
while status == "scoring":
response = requests.get(get_url, auth=HTTPBasicAuth(hotkey, signature)).json()
print(response)
status = response["status"]
time.sleep(5)