Skip to content

Commit

Permalink
Break up comprehension for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhardcastle committed Dec 10, 2024
1 parent 214841e commit 5fa1bc8
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/aind_session/utils/codeocean_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,27 +689,29 @@ def get_subject_data_assets(
docdb_records = aind_session.utils.docdb_utils.get_subject_docdb_records(
subject_id, ttl_hash=ttl_hash
)
docdb_asset_ids = [
id_
for id_ in aind_session.utils.docdb_utils.extract_codeocean_data_asset_ids_from_docdb_record(
docdb_records
)
]
from_docdb = []
for id_ in docdb_asset_ids:
if id_ in [asset.id for asset in assets]:
continue
try:
get_data_asset_model(id_)
except requests.HTTPError as exc:
if exc.response.status_code == 401:
logger.warning(
f"Not authorized to access data asset ID obtained from DocDB: {subject_id=}, {id_=}"
)
if docdb_records:
docdb_asset_ids = [
id_
for record in docdb_records
for id_ in aind_session.utils.docdb_utils.extract_codeocean_data_asset_ids_from_docdb_record(
record
)
]
for id_ in docdb_asset_ids:
if id_ in [asset.id for asset in assets]:
continue
raise
else:
from_docdb.append(id_)
try:
get_data_asset_model(id_)
except requests.HTTPError as exc:
if exc.response.status_code == 401:
logger.warning(
f"Not authorized to access data asset ID obtained from DocDB: {subject_id=}, {id_=}"
)
continue
raise
else:
from_docdb.append(id_)
assets = assets + tuple(from_docdb)

logger.debug(
Expand Down

0 comments on commit 5fa1bc8

Please sign in to comment.