Skip to content

Commit

Permalink
fixup! [a r] Index dataset description from Terra API (#5547)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Nov 7, 2023
1 parent 7834873 commit 8de3bfb
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/azul/plugins/metadata/anvil/indexer/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
from azul import (
JSON,
)
from azul.collections import (
deep_dict_merge,
)
from azul.indexer import (
BundleFQID,
BundlePartition,
)
from azul.indexer.aggregate import (
Expand Down Expand Up @@ -70,6 +72,10 @@
DonorAggregator,
FileAggregator,
)
from azul.plugins.repository.tdr_anvil import (
AnvilBundleFQID,
BundleEntityType,
)
from azul.strings import (
pluralize,
)
Expand Down Expand Up @@ -423,12 +429,25 @@ def inner_entity_id(cls, entity_type: EntityType, entity: JSON) -> EntityID:
def reconcile_inner_entities(cls,
entity_type: EntityType,
*,
this: tuple[JSON, BundleFQID],
that: tuple[JSON, BundleFQID]
) -> tuple[JSON, BundleFQID]:
this: tuple[JSON, AnvilBundleFQID],
that: tuple[JSON, AnvilBundleFQID]
) -> tuple[JSON, AnvilBundleFQID]:
this_entity, this_bundle = this
that_entity, that_bundle = that
return that if that_bundle.version > this_bundle.version else this
if this_bundle.version < that_bundle.version:
return that
else:
if this_entity.keys() == that_entity.keys():
return this
else:
assert entity_type == 'datasets', entity_type
this_is_duos = this_bundle.entity_type is BundleEntityType.duos
that_is_duos = that_bundle.entity_type is BundleEntityType.duos
assert this_is_duos != that_is_duos, (this_bundle, that_bundle)
return (
deep_dict_merge((this_entity, that_entity)),
that_bundle if this_is_duos else this_bundle
)


class ActivityTransformer(BaseTransformer):
Expand Down

0 comments on commit 8de3bfb

Please sign in to comment.