Skip to content

Commit

Permalink
Refactor get_duos() to return the DUOS ID
Browse files Browse the repository at this point in the history
  • Loading branch information
dsotirho-ucsc committed Nov 27, 2024
1 parent 7ea685b commit 94f2099
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/azul/plugins/repository/tdr_anvil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,11 @@ def _supplementary_bundle(self, bundle_fqid: TDRAnvilBundleFQID) -> TDRAnvilBund

def _duos_bundle(self, bundle_fqid: TDRAnvilBundleFQID) -> TDRAnvilBundle:
assert not bundle_fqid.is_batched, bundle_fqid
duos_info = self.tdr.get_duos(bundle_fqid.source)
description = None if duos_info is None else duos_info.get('studyDescription')
duos_id, duos_info = self.tdr.get_duos(bundle_fqid.source)
if duos_info is None:
description = None
else:
description = duos_info.get('studyDescription')
ref, row = self._get_dataset(bundle_fqid.source.spec)
expected_entity_id = change_version(bundle_fqid.uuid,
self.bundle_uuid_version,
Expand Down
15 changes: 11 additions & 4 deletions src/azul/terra.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,19 +646,26 @@ def for_registered_user(cls, authentication: OAuth2) -> 'TDRClient':
def drs_client(self) -> DRSClient:
return DRSClient(http_client=self._http_client)

def get_duos(self, source: TDRSourceRef) -> Optional[MutableJSON]:
def get_duos(self,
source: TDRSourceRef
) -> tuple[str | None, MutableJSON | None]:
response = self._retrieve_source(source)
try:
duos_id = response['duosFirecloudGroup']['duosId']
except (KeyError, TypeError):
log.warning('No DUOS ID available for %r', source.spec)
return None
return None, None
else:
url = self._duos_endpoint('dataset', 'registration', duos_id)
response = self._request('GET', url)
if response.status == 404:
log.warning('No DUOS dataset registration with ID %r from %r',
duos_id, source.spec)
return None
return None, None
else:
return self._check_response(url, response)
response = self._check_response(url, response)
assert response['consentGroups']
for consent_group in response['consentGroups']:
assert duos_id == consent_group['datasetIdentifier'], \
(duos_id, consent_group['datasetIdentifier'])
return duos_id, response

0 comments on commit 94f2099

Please sign in to comment.