@@ -595,13 +595,28 @@ def set_image_paths(self, download_highlight_images: bool, output_file_path: str
595595 highlight_image = get_association (self .annotation , 'guide-photo' )
596596 if highlight_image and (highlight_image ['to_concept' ] == '1 best' or highlight_image ['to_concept' ] == '2 good' ):
597597 self .columns ['HighlightImageFilePath' ] = self .columns ['ImageFilePath' ]
598- if download_highlight_images :
599- res = requests .get (self .columns ['ImageFilePath' ])
600- if res .status_code == 200 :
601- os .chdir (output_file_path )
602- with open (self .columns ['ImageFilePath' ].split ('/' )[- 1 ], 'wb' ) as file :
603- file .write (res .content )
604- else :
598+ if self .columns ['ImageFilePath' ] == NULL_VAL_STRING :
599+ warning_messages .append ([
600+ self .columns ['SampleID' ],
601+ self .annotation ['concept' ],
602+ self .annotation ['observation_uuid' ],
603+ 'guide-photo for this annotation has a to_concept of "1 best" or "2 good", but the annotation has no image references' ,
604+ ])
605+ elif download_highlight_images :
606+ try :
607+ res = requests .get (self .columns ['ImageFilePath' ])
608+ if res .status_code == 200 :
609+ os .chdir (output_file_path )
610+ with open (self .columns ['ImageFilePath' ].split ('/' )[- 1 ], 'wb' ) as file :
611+ file .write (res .content )
612+ else :
613+ warning_messages .append ([
614+ self .columns ['SampleID' ],
615+ self .annotation ['concept' ],
616+ self .annotation ['observation_uuid' ],
617+ 'Error downloading image' ,
618+ ])
619+ except requests .exceptions .ConnectionError :
605620 warning_messages .append ([
606621 self .columns ['SampleID' ],
607622 self .annotation ['concept' ],
0 commit comments