Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kf_utils/dataservice/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions kf_utils/dataservice/descendants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
13 changes: 10 additions & 3 deletions kf_utils/dataservice/patch.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions kf_utils/dataservice/scrape.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions kf_utils/dbgap/release.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down