-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (25 loc) · 996 Bytes
/
main.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
import os
import requests
import sys
import json
INFERENCE_ADDRESS = os.environ["INFERENCE_API_ADDRESS"]
def process(token_name):
response = requests.get(f"{INFERENCE_ADDRESS}/inference/{token_name}")
content = response.text
return content
if __name__ == "__main__":
# Your code logic with the parsed argument goes here
try:
if len(sys.argv) < 5:
value = json.dumps({"error": f"Not enough arguments provided: {len(sys.argv)}, expected 4 arguments: topic_id, blockHeight, blockHeightEval, default_arg"})
else:
topic_id = sys.argv[1]
blockHeight = sys.argv[2]
blockHeightEval = sys.argv[3]
default_arg = sys.argv[4]
response_inference = process(token_name=default_arg)
response_dict = {"infererValue": response_inference}
value = json.dumps(response_dict)
except Exception as e:
value = json.dumps({"error": {str(e)}})
print(value)