Francisco Aranda commited on
Commit
48225dd
1 Parent(s): b888aa1

using raw events for records and responses

Browse files
Files changed (1) hide show
  1. main.py +16 -9
main.py CHANGED
@@ -15,11 +15,15 @@ for webhook in client.webhooks:
15
  webhook.delete()
16
 
17
  # Create a webhook for record events
18
- @rg.webhook_listener(events=["record.created", "record.updated", "record.completed"])
19
- async def record_events(record: rg.Record, **kwargs):
20
- print(f"Received event {kwargs['type']} for record {record.id}")
21
 
22
- incoming_events.put(record)
 
 
 
 
 
 
 
23
 
24
  # Create a webhook for dataset events
25
  @rg.webhook_listener(events=["dataset.created", "dataset.updated", "dataset.published"])
@@ -30,11 +34,14 @@ async def dataset_events(type: str, dataset: rg.Dataset | None = None, **kwargs)
30
 
31
 
32
  # Create a webhook for response events
33
- @rg.webhook_listener(events=["response.created", "response.updated"])
34
- async def response_events(response: rg.UserResponse, **kwargs):
35
- print(f"Received event {kwargs['type']} for response {response.id}")
36
-
37
- incoming_events.put(response)
 
 
 
38
 
39
  @rg.webhook_listener(events=["record.deleted", "dataset.deleted", "response.deleted"])
40
  async def deleted_events(type: str, data: dict, **kwargs):
 
15
  webhook.delete()
16
 
17
  # Create a webhook for record events
 
 
 
18
 
19
+ @rg.webhook_listener(
20
+ events=["record.created", "record.updated", "record.completed"],
21
+ raw_event=True # Using raw events until PR https://github.com/argilla-io/argilla/pull/5500 is merged
22
+ )
23
+ async def record_events(event:dict):
24
+ print("Received event", event)
25
+
26
+ incoming_events.put(event)
27
 
28
  # Create a webhook for dataset events
29
  @rg.webhook_listener(events=["dataset.created", "dataset.updated", "dataset.published"])
 
34
 
35
 
36
  # Create a webhook for response events
37
+ @rg.webhook_listener(
38
+ events=["response.created", "response.updated"],
39
+ raw_event=True # Using raw events until PR https://github.com/argilla-io/argilla/pull/5500 is merged
40
+ )
41
+ async def response_events(event: dict):
42
+ print("Received event", event)
43
+
44
+ incoming_events.put(event)
45
 
46
  @rg.webhook_listener(events=["record.deleted", "dataset.deleted", "response.deleted"])
47
  async def deleted_events(type: str, data: dict, **kwargs):