diff --git a/kf_utils/dataservice/delete.py b/kf_utils/dataservice/delete.py index 4a8ec30..79fbe67 100644 --- a/kf_utils/dataservice/delete.py +++ b/kf_utils/dataservice/delete.py @@ -2,7 +2,8 @@ from pprint import pformat from urllib.parse import urlparse -from d3b_utils.requests_retry import Session +# from d3b_utils.requests_retry import Session +from requests import Session from kf_utils.dataservice.meta import get_endpoint from kf_utils.dataservice.scrape import yield_kfids diff --git a/kf_utils/dataservice/descendants.py b/kf_utils/dataservice/descendants.py index 6edd6c1..bd38422 100644 --- a/kf_utils/dataservice/descendants.py +++ b/kf_utils/dataservice/descendants.py @@ -325,7 +325,7 @@ def _inner(parent_type, parent_kfids, descendants): if parent_type in done: return done.add(parent_type) - for (child_type, link_on_parent, link_on_child) in descendancy.get( + for child_type, link_on_parent, link_on_child in descendancy.get( parent_type, [] ): if use_api: @@ -387,7 +387,7 @@ def _inner(parent_type, parent_kfids, descendants): for k, v in descendants["genomic_file"].items() if k not in to_remove } - for (child_type, _, _) in descendancy.get(parent_type, []): + for child_type, _, _ in descendancy.get(parent_type, []): if descendants.get(child_type): _inner(child_type, descendants[child_type].keys(), descendants) diff --git a/kf_utils/dataservice/patch.py b/kf_utils/dataservice/patch.py index 5c727c8..0652b9d 100644 --- a/kf_utils/dataservice/patch.py +++ b/kf_utils/dataservice/patch.py @@ -1,6 +1,8 @@ +from pprint import pformat from concurrent.futures import ThreadPoolExecutor, as_completed -from d3b_utils.requests_retry import Session +# from d3b_utils.requests_retry import Session +from requests import Session from kf_utils.dataservice.meta import get_endpoint @@ -15,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: diff --git a/kf_utils/dataservice/scrape.py b/kf_utils/dataservice/scrape.py index a39bad9..422bc47 100755 --- a/kf_utils/dataservice/scrape.py +++ b/kf_utils/dataservice/scrape.py @@ -1,6 +1,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed -from d3b_utils.requests_retry import Session +# from d3b_utils.requests_retry import Session +from requests import Session from kf_utils.dataservice.meta import get_endpoint from tqdm import tqdm @@ -52,7 +53,7 @@ def yield_entities_from_filter(host, endpoint, filters, show_progress=False): pbar.update() yield entity try: - for (key, i) in [("after", 1), ("after_uuid", 2)]: + for key, i in [("after", 1), ("after_uuid", 2)]: which[key] = j["_links"]["next"].split("=")[i].split("&")[0] except KeyError: break diff --git a/kf_utils/dbgap/release.py b/kf_utils/dbgap/release.py index d2f9479..207d95c 100644 --- a/kf_utils/dbgap/release.py +++ b/kf_utils/dbgap/release.py @@ -1,5 +1,7 @@ import xmltodict -from d3b_utils.requests_retry import Session + +# from d3b_utils.requests_retry import Session +from requests import Session from xml.etree import ElementTree # from defusedxml import ElementTree as DefusedET @@ -27,7 +29,8 @@ def get_latest_sample_status(phs_id, required_status="released"): print(f"Querying dbGaP for study {phs_string}") print(f"Manifest URL -> {url}") - data = Session(status_forcelist=(502, 503, 504)).get(url) + # data = Session(status_forcelist=(502, 503, 504)).get(url) + data = Session().get(url) if data.status_code != 200: tried[phs_string] = f"status {data.status_code}" raise Exception(