Skip to content

Commit

Permalink
fix some rare transform errors
Browse files Browse the repository at this point in the history
OneOfLink and TryLink were updated to only catch TransformErrors (a
while ago, see #732000) and apparently a couple transformers have subtle
bugs as a result that only now showed up when re-ingesting old data on
staging -- hooray!
  • Loading branch information
aaxelb committed Jan 11, 2021
1 parent f0723c3 commit fd2bc4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions share/transformers/gov_pubmedcentral_pmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class Extra:
)

def get_article_type(self, article_type):
return {
article_type_map = {
# 'abstract'
# 'addendum'
# 'announcement'
Expand Down Expand Up @@ -306,7 +306,11 @@ def get_article_type(self, article_type):
'retraction': 'retraction',
'review-article': 'article',
# 'systematic-review'
}[article_type]
}
try:
return article_type_map[article_type]
except KeyError:
raise TransformError

def guess_type_from_related(self, related):
if not isinstance(related, list):
Expand Down
2 changes: 1 addition & 1 deletion share/transformers/org_datacite.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class FunderRelation(Parser):
schema = 'Funder'

agent = tools.Delegate(FunderAgent, ctx)
awards = tools.Map(tools.Delegate(ThroughAwards), tools.Try(tools.RunPython('get_award', ctx)))
awards = tools.Map(tools.Delegate(ThroughAwards), tools.Try(tools.RunPython('get_award', ctx), exceptions=(KeyError,)))

def get_award(self, obj):
obj['awardURI']
Expand Down

0 comments on commit fd2bc4e

Please sign in to comment.