juanpablomesa commited on
Commit
15c7fb8
·
1 Parent(s): da91a0c

Added logging errors and reduced batch size to 50

Browse files
Files changed (1) hide show
  1. handler.py +4 -1
handler.py CHANGED
@@ -67,6 +67,7 @@ class EndpointHandler:
67
  if response.status_code == 200:
68
  return response.content
69
  else:
 
70
  raise Exception(
71
  f"Failed to download image from {url}. Status code: {response.status_code}"
72
  )
@@ -144,7 +145,7 @@ class EndpointHandler:
144
  "Data must contain 'images_urls' key with a list of images urls."
145
  )
146
 
147
- batch_size = 100
148
  if "batch_size" in data:
149
  batch_size = int(data["batch_size"])
150
  # Download and process the images (just downloading in this example)
@@ -185,6 +186,7 @@ class EndpointHandler:
185
  processed_metadata.append(complete_image_metadata)
186
 
187
  except Exception as e:
 
188
  print(e)
189
  # This should be a list of images as np.arrays
190
  processing_end_time = timeit.default_timer()
@@ -237,6 +239,7 @@ class EndpointHandler:
237
 
238
  except Exception as e:
239
  print(f"Error during Images processing: {str(e)}")
 
240
  return {"embeddings": [], "error": str(e)}
241
 
242
  elif data["process_type"] == "text":
 
67
  if response.status_code == 200:
68
  return response.content
69
  else:
70
+ self.logger.error(f"Error downloading image from :{str(url)}")
71
  raise Exception(
72
  f"Failed to download image from {url}. Status code: {response.status_code}"
73
  )
 
145
  "Data must contain 'images_urls' key with a list of images urls."
146
  )
147
 
148
+ batch_size = 50
149
  if "batch_size" in data:
150
  batch_size = int(data["batch_size"])
151
  # Download and process the images (just downloading in this example)
 
186
  processed_metadata.append(complete_image_metadata)
187
 
188
  except Exception as e:
189
+ self.logger.error(f"Error image processing: {str(e)}")
190
  print(e)
191
  # This should be a list of images as np.arrays
192
  processing_end_time = timeit.default_timer()
 
239
 
240
  except Exception as e:
241
  print(f"Error during Images processing: {str(e)}")
242
+ self.logger.error(f"Error during Images processing: {str(e)}")
243
  return {"embeddings": [], "error": str(e)}
244
 
245
  elif data["process_type"] == "text":