Skip to content

Commit

Permalink
Change how the inputs were handled in the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
chun9l committed May 22, 2024
1 parent c3f7e62 commit b16916a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions testing/protocol_conformity_1.0/test_model_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@ def test_evaluate(model_url, input_value):
inputSizesJSON = requests.post(f'{model_url}/InputSizes', json=input_model_name).json()

inputParams = {"input": [], "name": model_name, "config": {}}
input_value_len = getattr(input_value, '__len__', lambda:1)()
for i in range(0,len(inputSizesJSON["inputSizes"])):
assert input_value_len == 1 or input_value_len == inputSizesJSON["inputSizes"][i]
if input_value_len == 1:
inputParams["input"].append([input_value] * inputSizesJSON["inputSizes"][i])
for i in range(0, len(inputSizesJSON["inputSizes"])):
inputSizesJSON_i = inputSizesJSON["inputSizes"][i]
inputSizesJSON_len = len(inputSizesJSON["inputSizes"])
# Handles the case for one input vector
if hasattr(input_value, '__len__') and inputSizesJSON_len == 1:
assert len(input_value) == inputSizesJSON_i
inputParams["input"].append(input_value)
# The case where there are multiple input vector
elif hasattr(input_value, '__len__') and inputSizesJSON_len != 1:
assert len(input_value[i]) == inputSizesJSON_i
inputParams["input"].append(input_value[i])
# Single number entered, will be expanded if sizes unmatched
else:
inputParams["input"].append([input_value][i])
inputParams["input"].append([input_value] * inputSizesJSON_i)
assert len(inputParams["input"][i]) == inputSizesJSON_i

resp = requests.post(f'{model_url}/Evaluate', headers={}, data=json.dumps(inputParams,indent=4))

Expand Down

0 comments on commit b16916a

Please sign in to comment.