Skip to content

Commit

Permalink
[r] Fix: AnVIL indexer doesn't follow downstream links from files to …
Browse files Browse the repository at this point in the history
…files (#4761)
  • Loading branch information
nadove-ucsc committed Nov 23, 2022
1 parent 148545f commit d7b4f27
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/azul/plugins/repository/tdr_anvil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _bundle_entity(self, bundle_fqid: SourcedBundleFQID) -> KeyReference:
return bundle_entity

def _consolidate_by_type(self, entities: Keys) -> MutableKeysByType:
result = defaultdict(set)
result = {entity_type: set() for entity_type in self.indexed_columns_by_entity_type}
for e in entities:
result[e.entity_type].add(e.key)
return result
Expand Down Expand Up @@ -259,7 +259,7 @@ def _follow_downstream(self,
) -> Links:
return set.union(
self._downstream_from_biosamples(source, entities['biosample']),
self._downstream_from_files(source, entities['files'])
self._downstream_from_files(source, entities['file'])
)

def _upstream_from_biosamples(self,
Expand Down Expand Up @@ -407,8 +407,8 @@ def _downstream_from_files(self,
rows = self._run_sql(f'''
WITH activities AS (
SELECT
ala.alignmentactivity_id,
'alignmentactivity',
ala.alignmentactivity_id AS activity_id,
'alignmentactivity' AS activity_table,
ala.used_file_id,
ala.generated_file_id
FROM {backtick(self._full_table_name(source, 'alignmentactivity'))} AS ala
Expand All @@ -433,7 +433,7 @@ def _downstream_from_files(self,
KeyReference(key=file_id, entity_type='file')
for file_id in row['generated_file_id']
],
activity=KeyReference(key=row['actvity_id'], entity_type=row['activity_table']))
activity=KeyReference(key=row['activity_id'], entity_type=row['activity_table']))
for row in rows
}

Expand All @@ -442,6 +442,8 @@ def _retrieve_entities(self,
entity_type: EntityType,
keys: AbstractSet[Key],
) -> MutableJSONs:
if not keys:
return []
table_name = self._full_table_name(source, entity_type)
columns = set.union(
self.common_indexed_columns,
Expand Down

0 comments on commit d7b4f27

Please sign in to comment.