Commit d8e95f31 authored by Bruno Chareyre's avatar Bruno Chareyre
Browse files

retry query.get() when failed, instead of failing pipeline

parent e978de05
Pipeline #69504 passed with stages
in 10 minutes and 39 seconds
......@@ -173,8 +173,13 @@ def get_biblio_orcid(name='Chareyre',orcid='0000-0001-8505-8540',N=10,typesLists
type = BRIDGE_TYPES.get(work.get("type")) if BRIDGE_TYPES.get(work.get("type")) is not None else work.get("type")
print("type",type,"found for",name)
if i<N or (type in individual_types and len(individual_types[type])<N) or not type in individual_types:
doc = requests.get('http://pub.orcid.org/'+work['path'],
headers={'Accept':'application/orcid+json'}).json()
while True:
try:
doc = requests.get('http://pub.orcid.org/'+work['path'], headers={'Accept':'application/orcid+json'}).json()
break
except:
print('request failure ... retrying')
continue
if type in individual_types:
if i<N: publis_by_type[type].append(doc)
individual_types[type].append(doc)
......@@ -220,9 +225,9 @@ def get_biblio_orcid(name='Chareyre',orcid='0000-0001-8505-8540',N=10,typesLists
return files
def get_biblio_group_orcid(groupName='geo', N=20, typesLists = [['Articles'],['Articles','Conferences Papers and Books'],['all']]):
def get_biblio_group_orcid(groupName='geo', N=20, typesLists = [['Articles'],['Articles','Conferences and Books'],['all']]):
global test
BRIDGE_TYPES = {"journal-article": "Articles", "conference-paper": "Conferences and Books", "book-chapter": "Conferences Papers and Books", "book": "Conferences and Books"}
BRIDGE_TYPES = {"journal-article": "Articles", "conference-paper": "Conferences Papers and Books", "book-chapter": "Conferences Papers and Books", "book": "Conferences and Books"}
publis_by_type = dict()
group = groups[groupName]
......@@ -237,8 +242,14 @@ def get_biblio_group_orcid(groupName='geo', N=20, typesLists = [['Articles'],['A
type = BRIDGE_TYPES.get(work.get("type")) if BRIDGE_TYPES.get(work.get("type")) is not None else work.get("type")
print(author," : type",type)
doc = requests.get('http://pub.orcid.org/'+work['path'],
headers={'Accept':'application/orcid+json'}).json()
while True:
try:
doc = requests.get('http://pub.orcid.org/'+work['path'], headers={'Accept':'application/orcid+json'}).json()
break
except:
print('request failure ... retrying')
continue
year = doc["publication-date"]["year"]["value"]
try:
key = doc['external-ids']['external-id'][0]['external-id-value']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment