File size: 1,096 Bytes
5973eb4 | 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 | """Check actual HTTP endpoint execution, including reported device."""
import argparse
import json
import urllib.request
p = argparse.ArgumentParser()
p.add_argument('--backend', default='cpu-reference')
p.add_argument('--url', default='http://127.0.0.1:8080')
a = p.parse_args()
def request(path, data=None):
body = json.dumps(data).encode() if data is not None else None
req = urllib.request.Request(a.url+path, data=body,
headers={'Content-Type': 'application/json'} if body else {})
with urllib.request.urlopen(req, timeout=600) as resp:
assert resp.status == 200
return json.load(resp)
health = request('/health')
assert health['status'] == 'ok', health
assert health['backend'] == a.backend, health
info = request('/v1/model')
assert info['architecture'] == 'falcon_h1'
assert info['backend'] == a.backend
assert len(request('/v1/logits', {'input_ids': [1,2,3]})['logits']) == 64
assert len(request('/v1/generate', {'input_ids': [1,2], 'max_new_tokens':2})['output_ids']) == 4
print('PASS:', a.backend, 'health, model, logits, generate via HTTP')
|