b2u commited on
Commit
e8ef760
·
1 Parent(s): a9b8d74

validating the trigger event

Browse files
Files changed (1) hide show
  1. model.py +12 -9
model.py CHANGED
@@ -180,14 +180,17 @@ Category:"""
180
  return predictions
181
 
182
  def fit(self, event, data, **kwargs):
 
 
 
 
 
183
  """
184
- This method is called each time an annotation is created or updated
185
- You can run your logic here to update the model and persist it to the cache
186
- It is not recommended to perform long-running operations here, as it will block the main thread
187
- Instead, consider running a separate process or a thread (like RQ worker) to perform the training
188
- :param event: event type can be ('ANNOTATION_CREATED', 'ANNOTATION_UPDATED', 'START_TRAINING')
189
- :param data: the payload received from the event (check [Webhook event reference](https://labelstud.io/guide/webhook_reference.html))
190
- """
191
- logger.info("Fit method called but not implemented in this version")
192
- pass
193
 
 
180
  return predictions
181
 
182
  def fit(self, event, data, **kwargs):
183
+ """Handle annotation events from Label Studio
184
+
185
+ Args:
186
+ event (str): Event type ('ANNOTATION_CREATED', 'ANNOTATION_UPDATED', 'START_TRAINING')
187
+ data (dict): Event payload with annotation details
188
  """
189
+ # Log and validate event type
190
+ logger.info(f"Received event: {event}")
191
+
192
+ valid_events = {'ANNOTATION_CREATED', 'ANNOTATION_UPDATED', 'START_TRAINING'}
193
+ if event not in valid_events:
194
+ logger.warning(f"Skip training: event {event} is not supported")
195
+ return
 
 
196