@@ -107,16 +107,26 @@ def convert_short_form_to_iri(match):
107107 'object' : iri_query ,
108108 'direct' : 'false' , # Always use indirect (transitive) queries
109109 'includeDeprecated' : 'false' , # Exclude deprecated terms
110- 'includeEquivalent' : 'true' , # Include equivalent classes
111- 'prefixes' : json .dumps ({
112- "FBbt" : "http://purl.obolibrary.org/obo/FBbt_" ,
113- "RO" : "http://purl.obolibrary.org/obo/RO_" ,
114- "BFO" : "http://purl.obolibrary.org/obo/BFO_"
115- })
110+ 'includeEquivalent' : 'true' # Include equivalent classes
116111 }
117112
118113 # Make HTTP GET request with longer timeout for complex queries (20 minutes for OWL reasoning)
119- response = requests .get (
114+ # Add retry logic for connection resets (common with long-running queries)
115+ from requests .adapters import HTTPAdapter
116+ from urllib3 .util .retry import Retry
117+
118+ session = requests .Session ()
119+ retry_strategy = Retry (
120+ total = 3 , # Total number of retries
121+ backoff_factor = 2 , # Wait 2s, 4s, 8s between retries
122+ status_forcelist = [500 , 502 , 503 , 504 ], # Retry on server errors
123+ allowed_methods = ["GET" ] # Only retry GET requests
124+ )
125+ adapter = HTTPAdapter (max_retries = retry_strategy )
126+ session .mount ("http://" , adapter )
127+ session .mount ("https://" , adapter )
128+
129+ response = session .get (
120130 f"{ self .owlery_endpoint } /subclasses" ,
121131 params = params ,
122132 timeout = 1200
@@ -211,13 +221,7 @@ def convert_short_form_to_iri(match):
211221 params = {
212222 'object' : iri_query ,
213223 'direct' : 'true' if direct else 'false' ,
214- 'includeDeprecated' : 'false' ,
215- 'prefixes' : json .dumps ({
216- "FBbt" : "http://purl.obolibrary.org/obo/FBbt_" ,
217- "RO" : "http://purl.obolibrary.org/obo/RO_" ,
218- "BFO" : "http://purl.obolibrary.org/obo/BFO_" ,
219- "VFB" : "http://virtualflybrain.org/reports/VFB_"
220- })
224+ 'includeDeprecated' : 'false'
221225 }
222226
223227 # Build full URL for debugging
@@ -228,7 +232,22 @@ def convert_short_form_to_iri(match):
228232 print (f"Owlery instances URL: { prepared_request .url } " )
229233
230234 # Make HTTP GET request to instances endpoint (20 minutes for OWL reasoning)
231- response = requests .get (
235+ # Add retry logic for connection resets (common with long-running queries)
236+ from requests .adapters import HTTPAdapter
237+ from urllib3 .util .retry import Retry
238+
239+ session = requests .Session ()
240+ retry_strategy = Retry (
241+ total = 3 , # Total number of retries
242+ backoff_factor = 2 , # Wait 2s, 4s, 8s between retries
243+ status_forcelist = [500 , 502 , 503 , 504 ], # Retry on server errors
244+ allowed_methods = ["GET" ] # Only retry GET requests
245+ )
246+ adapter = HTTPAdapter (max_retries = retry_strategy )
247+ session .mount ("http://" , adapter )
248+ session .mount ("https://" , adapter )
249+
250+ response = session .get (
232251 f"{ self .owlery_endpoint } /instances" ,
233252 params = params ,
234253 timeout = 1200
0 commit comments