Skip to content

Commit

Permalink
update client in accordance with API updates
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Dec 11, 2023
1 parent f692e1c commit c8ae748
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions alfalfa_client/alfalfa_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _request(self, endpoint: str, method="POST", parameters=None) -> requests.Re
else:
response = requests.request(method=method, url=self.url + endpoint)

if response.status_code == 400:
if response.status_code == 400 or response.status_code == 500:
try:
body = response.json()
raise AlfalfaAPIException(body["error"])
Expand Down Expand Up @@ -270,11 +270,11 @@ def set_inputs(self, run_id: str, inputs: dict) -> None:
:param run_id: id of run
:param inputs: dictionary of point names and input values"""
point_writes = []
point_writes = {}
for name, value in inputs.items():
id = self._get_point_translation(run_id, name)
if id:
point_writes.append({'id': id, 'value': value})
point_writes[id] = value
self._request(f"runs/{run_id}/points/values", method="PUT", parameters={'points': point_writes})

def get_outputs(self, run_id: str) -> dict:
Expand All @@ -286,12 +286,9 @@ def get_outputs(self, run_id: str) -> dict:
parameters={ "pointTypes": ["OUTPUT", "BIDIRECTIONAL"]})
response_body = response.json()["payload"]
outputs = {}
for point in response_body:
name = self._get_point_translation(run_id, point["id"])
if "value" in point.keys():
outputs[name] = point["value"]
else:
outputs[name] = None
for point, value in response_body.items():
name = self._get_point_translation(run_id, point)
outputs[name] = value

return outputs

Expand Down

0 comments on commit c8ae748

Please sign in to comment.