So, I think this is a general question for working on futures.
If I have a task that looks roughly like this:
def evaluate_combos(A, B):
refs = []
for a in A:
inner_refs = []
for b in B:
inner_refs.append(evaluate.remote(a, b))
refs.append(inner_refs)
return refs
# So, the refs list is an MxN matrix.
matrix_refs = evaluate_combos(a_list, b_list)
best_per_row_ref = np.argmax(matrix_refs, axis=1)
best_per_row = ray.get(best_per_row_ref)
The above makes sense, if the evaluate
function returns something just one thing and it’s numeric. However, if I am returning a dict with multiple things in it, wouldn’t I have to collect all the answers to extract the relevant numeric portion and then take my argmax?
matrix_refs = evaluate_combos(a_list, b_list)
matrix_dicts = [ray.get(matrix_row) for matrix_row in matrix_refs]
rows = []
for each_row in matrix_dicts:
cols = []
for k, v in each_row.items():
if k == 'score':
cols.append(v)
row.append(cols)
matrix = np.array(rows)
best_per_row = np.argmax(matrix, axis=1)
Can I access into the future with a key as if it were a dict? I would think not. But if not, then don’t you have to collect before you do any type of key lookups?