aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-05-22 16:10:49 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-05-22 16:10:52 -0700
commitd8cf02dbdc6848be4de2710e54f4463d702b6e7c (patch)
treebd40d1458397ed5aa539af70551148bb6403f20f /python
parent50023c3a6dbbac3da8cbf444ef5b5e47850394e0 (diff)
downloadfatcat-d8cf02dbdc6848be4de2710e54f4463d702b6e7c.tar.gz
fatcat-d8cf02dbdc6848be4de2710e54f4463d702b6e7c.zip
importers: clarify handling of ApiException
One of these (in ingest importer pipeline) is an actual bug, the others are just changing the syntax to be more explicit/conservative. The ingest importer bug seems to have resulted in some bad file match imports; scale of impact is unknown.
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_tools/importers/common.py12
-rw-r--r--python/fatcat_tools/importers/ingest.py1
-rw-r--r--python/fatcat_tools/importers/pubmed.py1
3 files changed, 10 insertions, 4 deletions
diff --git a/python/fatcat_tools/importers/common.py b/python/fatcat_tools/importers/common.py
index 99c330a6..eafc6546 100644
--- a/python/fatcat_tools/importers/common.py
+++ b/python/fatcat_tools/importers/common.py
@@ -458,7 +458,8 @@ class EntityImporter:
creator_id = rv.ident
except ApiException as ae:
# If anything other than a 404 (not found), something is wrong
- assert ae.status == 404
+ if ae.status != 404:
+ raise ae
self._orcid_id_map[orcid] = creator_id # might be None
return creator_id
@@ -479,7 +480,8 @@ class EntityImporter:
release_id = rv.ident
except ApiException as ae:
# If anything other than a 404 (not found), something is wrong
- assert ae.status == 404
+ if ae.status != 404:
+ raise ae
self._doi_id_map[doi] = release_id # might be None
return release_id
@@ -495,7 +497,8 @@ class EntityImporter:
release_id = rv.ident
except ApiException as ae:
# If anything other than a 404 (not found), something is wrong
- assert ae.status == 404
+ if ae.status != 404:
+ raise ae
self._pmid_id_map[pmid] = release_id # might be None
return release_id
@@ -512,7 +515,8 @@ class EntityImporter:
container_id = rv.ident
except ApiException as ae:
# If anything other than a 404 (not found), something is wrong
- assert ae.status == 404
+ if ae.status != 404:
+ raise ae
self._issnl_id_map[issnl] = container_id # might be None
return container_id
diff --git a/python/fatcat_tools/importers/ingest.py b/python/fatcat_tools/importers/ingest.py
index 7d5211fc..6cf1604b 100644
--- a/python/fatcat_tools/importers/ingest.py
+++ b/python/fatcat_tools/importers/ingest.py
@@ -108,6 +108,7 @@ class IngestFileResultImporter(EntityImporter):
elif err.status == 400:
self.counts['warn-extid-invalid'] += 1
continue
+ raise err
release_ident = release.ident
break
if self.use_glutton_match and not release_ident and row.get('grobid'):
diff --git a/python/fatcat_tools/importers/pubmed.py b/python/fatcat_tools/importers/pubmed.py
index abcb21d9..3d3e3a8c 100644
--- a/python/fatcat_tools/importers/pubmed.py
+++ b/python/fatcat_tools/importers/pubmed.py
@@ -782,6 +782,7 @@ class PubmedImporter(EntityImporter):
# NOTE: API behavior might change in the future?
if "release_edit_editgroup_id_ident_id_key" in err.body:
self.counts['skip-update-conflict'] += 1
+ return False
else:
raise err
finally: