-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3970677
commit ef3e0ba
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import argparse | ||
import umbridge | ||
import random | ||
import time | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
|
||
# Read URL from command line argument | ||
parser = argparse.ArgumentParser(description='Parallel evaluations via UM-Bridge.') | ||
parser.add_argument('url', metavar='url', type=str, | ||
help='the URL at which the model is running, for example http://localhost:4242') | ||
args = parser.parse_args() | ||
print(f"Connecting to URL {args.url}") | ||
|
||
# Connect to model server | ||
model = umbridge.HTTPModel(args.url, "forward") | ||
|
||
def evaluate_model(number): | ||
# Define parameter for evaluation | ||
parameters = [[number for _ in range(model.get_input_sizes()[0])]] | ||
# Evaluate model | ||
model_output = model(parameters) | ||
print(model_output) | ||
return model_output | ||
|
||
# Number of evaluations to perform | ||
num_evaluations = 100 | ||
|
||
# Run evaluations in parallel | ||
# Use max_workers to define the maximum number of threads | ||
with ThreadPoolExecutor(max_workers = 6) as executor: | ||
results = list(executor.map(evaluate_model, range(1, num_evaluations + 1))) |