@@ -10,6 +10,12 @@ def setUp(self):
1010 self .vc = SolrTermInfoFetcher ()
1111 self .variable = TestVariable ("my_id" , "my_name" )
1212
13+ def get_term_info_or_skip (self , term_id ):
14+ try :
15+ return self .vc .get_TermInfo ([term_id ], return_dataframe = False , summary = False )[0 ]
16+ except Exception as e :
17+ self .skipTest (f"SOLR server not available: { e } " )
18+
1319 def test_term_info_deserialization (self ):
1420 terminfo_json = """
1521 {"term": {"core": {"iri": "http://purl.obolibrary.org/obo/FBbt_00048514", "symbol": "BM-Taste", "types": ["Entity", "Adult", "Anatomy", "Cell", "Class", "Mechanosensory_system", "Nervous_system", "Neuron", "Sensory_neuron"], "short_form": "FBbt_00048514", "unique_facets": ["Adult", "Mechanosensory_system", "Nervous_system", "Sensory_neuron"], "label": "labial taste bristle mechanosensory neuron"}, "description": ["Any mechanosensory neuron (FBbt:00005919) that has sensory dendrite in some labellar taste bristle (FBbt:00004162)."], "comment": []}, "query": "Get JSON for Neuron Class", "version": "3d2a474", "parents": [{"symbol": "", "iri": "http://purl.obolibrary.org/obo/FBbt_00048508", "types": ["Entity", "Anatomy", "Cell", "Class", "Mechanosensory_system", "Nervous_system", "Neuron", "Sensory_neuron"], "short_form": "FBbt_00048508", "unique_facets": ["Mechanosensory_system", "Nervous_system", "Sensory_neuron"], "label": "mechanosensory neuron of chaeta"}, {"symbol": "", "iri": "http://purl.obolibrary.org/obo/FBbt_00051420", "types": ["Entity", "Adult", "Anatomy", "Cell", "Class", "Mechanosensory_system", "Nervous_system", "Neuron", "Sensory_neuron"], "short_form": "FBbt_00051420", "unique_facets": ["Adult", "Mechanosensory_system", "Nervous_system", "Sensory_neuron"], "label": "adult mechanosensory neuron"}, {"symbol": "", "iri": "http://purl.obolibrary.org/obo/FBbt_00048029", "types": ["Entity", "Adult", "Anatomy", "Cell", "Class", "Nervous_system", "Neuron", "Sensory_neuron"], "short_form": "FBbt_00048029", "unique_facets": ["Adult", "Nervous_system", "Sensory_neuron"], "label": "labellar taste bristle sensory neuron"}], "relationships": [{"relation": {"iri": "http://purl.obolibrary.org/obo/BFO_0000050", "label": "is part of", "type": "part_of"}, "object": {"symbol": "", "iri": "http://purl.obolibrary.org/obo/FBbt_00005892", "types": ["Entity", "Adult", "Anatomy", "Class", "Nervous_system"], "short_form": "FBbt_00005892", "unique_facets": ["Adult", "Nervous_system"], "label": "adult peripheral nervous system"}}], "xrefs": [], "anatomy_channel_image": [], "pub_syn": [{"synonym": {"scope": "has_exact_synonym", "label": "labellar taste bristle mechanosensitive neuron", "type": ""}, "pub": {"core": {"symbol": "", "iri": "http://flybase.org/reports/Unattributed", "types": ["Entity", "Individual", "pub"], "short_form": "Unattributed", "unique_facets": ["pub"], "label": ""}, "FlyBase": "", "PubMed": "", "DOI": ""}}, {"synonym": {"scope": "has_exact_synonym", "label": "labellar taste bristle mechanosensitive neuron", "type": ""}, "pub": {"core": {"symbol": "", "iri": "http://flybase.org/reports/Unattributed", "types": ["Entity", "Individual", "pub"], "short_form": "Unattributed", "unique_facets": ["pub"], "label": ""}, "FlyBase": "", "PubMed": "", "DOI": ""}}, {"synonym": {"scope": "has_exact_synonym", "label": "labial taste bristle mechanosensitive neuron", "type": ""}, "pub": {"core": {"symbol": "", "iri": "http://flybase.org/reports/Unattributed", "types": ["Entity", "Individual", "pub"], "short_form": "Unattributed", "unique_facets": ["pub"], "label": ""}, "FlyBase": "", "PubMed": "", "DOI": ""}}], "def_pubs": [{"core": {"symbol": "", "iri": "http://flybase.org/reports/FBrf0242472", "types": ["Entity", "Individual", "pub"], "short_form": "FBrf0242472", "unique_facets": ["pub"], "label": "Zhou et al., 2019, Sci. Adv. 5(5): eaaw5141"}, "FlyBase": "", "PubMed": "31131327", "DOI": "10.1126/sciadv.aaw5141"}], "targeting_splits": []}
@@ -40,7 +46,7 @@ def test_term_info_deserialization(self):
4046 def test_term_info_deserialization_from_dict (self ):
4147 import pkg_resources
4248 print ("vfb_connect version:" , pkg_resources .get_distribution ("vfb_connect" ).version )
43- vfbTerm = self .vc . get_TermInfo ([ 'FBbt_00048514' ], return_dataframe = False , summary = False )[ 0 ]
49+ vfbTerm = self .get_term_info_or_skip ( 'FBbt_00048514' )
4450 start_time = time .time ()
4551 terminfo = deserialize_term_info_from_dict (vfbTerm )
4652 print ("--- %s seconds ---" % (time .time () - start_time ))
@@ -84,7 +90,7 @@ def test_term_info_deserialization_from_dict(self):
8490 self .assertEqual ("33657409" , labellar_hmsn_entry .pub .PubMed )
8591
8692 def test_term_info_serialization_individual_anatomy (self ):
87- term_info_dict = self .vc . get_TermInfo ([ 'VFB_00010001' ], return_dataframe = False , summary = False )[ 0 ]
93+ term_info_dict = self .get_term_info_or_skip ( 'VFB_00010001' )
8894 print (term_info_dict )
8995 start_time = time .time ()
9096 serialized = process (term_info_dict , self .variable )
@@ -133,7 +139,7 @@ def test_term_info_serialization_individual_anatomy(self):
133139 'reference' : '[VFB_00017894,VFB_00010001]' } in serialized ["thumbnail" ])
134140
135141 def test_term_info_serialization_class (self ):
136- term_info_dict = self .vc . get_TermInfo ([ 'FBbt_00048531' ], return_dataframe = False , summary = False )[ 0 ]
142+ term_info_dict = self .get_term_info_or_skip ( 'FBbt_00048531' )
137143 print (term_info_dict )
138144 start_time = time .time ()
139145 serialized = process (term_info_dict , self .variable )
@@ -176,7 +182,7 @@ def test_term_info_serialization_class(self):
176182 self .assertFalse ("downloads_label" in serialized )
177183
178184 def test_term_info_serialization_neuron_class (self ):
179- term_info_dict = self .vc . get_TermInfo ([ 'FBbt_00048999' ], return_dataframe = False , summary = False )[ 0 ]
185+ term_info_dict = self .get_term_info_or_skip ( 'FBbt_00048999' )
180186 print (term_info_dict )
181187 start_time = time .time ()
182188 serialized = process (term_info_dict , self .variable )
@@ -234,7 +240,7 @@ def test_term_info_serialization_neuron_class(self):
234240 self .assertFalse ("template" in serialized )
235241
236242 def test_term_info_serialization_neuron_class2 (self ):
237- term_info_dict = self .vc . get_TermInfo ([ 'FBbt_00047030' ], return_dataframe = False , summary = False )[ 0 ]
243+ term_info_dict = self .get_term_info_or_skip ( 'FBbt_00047030' )
238244 print (term_info_dict )
239245 start_time = time .time ()
240246 serialized = process (term_info_dict , self .variable )
@@ -303,7 +309,7 @@ def test_term_info_serialization_neuron_class2(self):
303309 self .assertFalse ("template" in serialized )
304310
305311 def test_term_info_serialization_split_class (self ):
306- term_info_dict = self .vc . get_TermInfo ([ 'VFBexp_FBtp0124468FBtp0133404' ], return_dataframe = False , summary = False )[ 0 ]
312+ term_info_dict = self .get_term_info_or_skip ( 'VFBexp_FBtp0124468FBtp0133404' )
307313 print (term_info_dict )
308314 start_time = time .time ()
309315 serialized = process (term_info_dict , self .variable )
@@ -357,7 +363,7 @@ def test_term_info_serialization_split_class(self):
357363 self .assertFalse ("template" in serialized )
358364
359365 def test_term_info_serialization_dataset (self ):
360- term_info_dict = self .vc . get_TermInfo ([ 'Ito2013' ], return_dataframe = False , summary = False )[ 0 ]
366+ term_info_dict = self .get_term_info_or_skip ( 'Ito2013' )
361367 print (term_info_dict )
362368 start_time = time .time ()
363369 serialized = process (term_info_dict , self .variable )
@@ -395,7 +401,7 @@ def test_term_info_serialization_dataset(self):
395401 self .assertTrue ("clone of Ito 2013" in sample_example ["name" ])
396402
397403 def test_term_info_serialization_license (self ):
398- term_info_dict = self .vc . get_TermInfo ([ 'VFBlicense_CC_BY_NC_3_0' ], return_dataframe = False , summary = False )[ 0 ]
404+ term_info_dict = self .get_term_info_or_skip ( 'VFBlicense_CC_BY_NC_3_0' )
399405 print (term_info_dict )
400406 start_time = time .time ()
401407 serialized = process (term_info_dict , self .variable )
@@ -430,7 +436,7 @@ def test_term_info_serialization_license(self):
430436 self .assertFalse ("template" in serialized )
431437
432438 def test_term_info_serialization_template (self ):
433- term_info_dict = self .vc . get_TermInfo ([ 'VFB_00200000' ], return_dataframe = False , summary = False )[ 0 ]
439+ term_info_dict = self .get_term_info_or_skip ( 'VFB_00200000' )
434440 print (term_info_dict )
435441 start_time = time .time ()
436442 serialized = process (term_info_dict , self .variable )
@@ -486,7 +492,7 @@ def test_term_info_serialization_template(self):
486492 self .assertEqual ("[JRC2018UnisexVNC](VFB_00200000)" , serialized ["template" ])
487493
488494 def test_term_info_serialization_pub (self ):
489- term_info_dict = self .vc . get_TermInfo ([ 'FBrf0243986' ], return_dataframe = False , summary = False )[ 0 ]
495+ term_info_dict = self .get_term_info_or_skip ( 'FBrf0243986' )
490496 print (term_info_dict )
491497 start_time = time .time ()
492498 serialized = process (term_info_dict , self .variable )
@@ -531,15 +537,18 @@ def test_term_info_performance(self):
531537 """
532538 import vfbquery as vfb
533539
534- # Test performance for FBbt_00003748 (mushroom body)
535- start_time = time .time ()
536- result_1 = vfb .get_term_info ('FBbt_00003748' )
537- duration_1 = time .time () - start_time
538-
539- # Test performance for VFB_00101567 (individual anatomy)
540- start_time = time .time ()
541- result_2 = vfb .get_term_info ('VFB_00101567' )
542- duration_2 = time .time () - start_time
540+ try :
541+ # Test performance for FBbt_00003748 (mushroom body)
542+ start_time = time .time ()
543+ result_1 = vfb .get_term_info ('FBbt_00003748' )
544+ duration_1 = time .time () - start_time
545+
546+ # Test performance for VFB_00101567 (individual anatomy)
547+ start_time = time .time ()
548+ result_2 = vfb .get_term_info ('VFB_00101567' )
549+ duration_2 = time .time () - start_time
550+ except Exception as e :
551+ self .skipTest (f"SOLR server not available: { e } " )
543552
544553 # Print performance metrics for GitHub Actions logs
545554 print (f"\n " + "=" * 50 )
0 commit comments