Skip to content

Commit

Permalink
Make the serializer use the fields from the header (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
DhanshreeA authored Nov 29, 2024
1 parent 8ee13d3 commit 4496034
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions ersilia/serve/standard_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,21 +263,17 @@ def is_amenable(self, output_data):
return True

def serialize_to_csv(self, input_data, result, output_data):
k = list(result[0].keys())[0]
v = result[0][k]
if type(v) is list:
is_list = True
else:
is_list = False
with open(output_data, "w") as f:
writer = csv.writer(f)
writer.writerow(self.header)
for i_d, r_d in zip(input_data, result):
v = r_d[k]
if not is_list:
r = [i_d["key"], i_d["input"]] + [v]
else:
r = [i_d["key"], i_d["input"]] + v
r = [i_d["key"], i_d["input"]]
for k in self.header[2:]:
v = r_d[k]
if isinstance(v, list):
r+=v
else:
r+=[v]
writer.writerow(r)
return output_data

Expand Down

0 comments on commit 4496034

Please sign in to comment.