Skip to content

Commit

Permalink
🔊 More details in patch message
Browse files Browse the repository at this point in the history
  • Loading branch information
znatty22 committed Sep 26, 2023
1 parent 389054f commit 5bf83bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kf_utils/dataservice/patch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pprint import pformat
from concurrent.futures import ThreadPoolExecutor, as_completed

# from d3b_utils.requests_retry import Session
Expand All @@ -16,10 +17,15 @@ def send_patches(host, patches):
host = host.strip("/")

def do_patch(url, patch):
msg = f"Patched {url} with {patch}"
resp = Session().patch(url, json=patch)
if not resp.ok:
raise Exception(f"{resp.status_code} -- {msg} -- {resp.json()}")
msg = f"Patched {url} with {patch}"
raise Exception(
f"{resp.status_code} -- {msg} -- Response:\n{resp.text}"
)
else:
msg = f"Patched {url} with {patch}. Response:\n{pformat(resp.json())}"

return msg

with ThreadPoolExecutor() as tpex:
Expand Down

0 comments on commit 5bf83bf

Please sign in to comment.