Skip to content

Commit e185527

Browse files
committed
feat(lab-3584): update documentation to fully remove onSubmit and onReview
1 parent 6eca882 commit e185527

File tree

11 files changed

+62
-748
lines changed

11 files changed

+62
-748
lines changed

docs/sdk/plugins.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@ plugin_folder
1919
|__ helper.py
2020
```
2121

22-
The plugin you are going to upload has to contain a `class PluginHandler(PluginCore)` (in the case of the module type plugin it has to be inside `main.py`) that implements two methods for the different types of events:
2322

24-
- `on_submit`
25-
- `on_review`
23+
> **Note**: `on_submit` and `on_review` handlers are deprecated. Please use `on_event` instead. If your plugin was already uploaded with thoses handlers, it will still work. If you want the same behavior as `on_submit` and `on_review`, when you upload your plugin, you can use `event_matcher=["labels.created.submit"]` for `on_submit` and `event_matcher=["labels.created.review"]` for `on_review` events.
2624
27-
These methods have a predefined set of parameters:
2825

29-
- the `label` submitted (a dictionary containing the fields of the GraphQL type [Label](https://api-docs.kili-technology.com/types/objects/label/))
30-
- the `asset_id` of the asset labeled
26+
The plugin you are going to upload has to contain a `class PluginHandler(PluginCore)` (in the case of the module type plugin it has to be inside `main.py`) that implements one method for the different types of events:
27+
28+
- `on_event`
29+
30+
These methods have a predefined set of parameter:
31+
32+
- the `payload` submitted (a dictionary containing the fields for your plugins)
33+
- `payload.event` the name of the event (ex: for submit : `labels.created.submit`, for review `labels.created.review`)
34+
- `payload.label` the label containing the fields of the GraphQL type [Label](https://api-docs.kili-technology.com/types/objects/label/)
3135

3236
You can add custom methods in your class as well.
3337

@@ -53,12 +57,18 @@ class PluginHandler(PluginCore):
5357
def custom_method(self):
5458
# Do something...
5559

56-
def on_review(self, label: Dict, asset_id: str) -> None:
60+
def on_event(self, payload: dict) -> None: # This can replace on_review method
5761
"""Dedicated handler for Review action"""
62+
event = payload.get("event")
63+
64+
if event == 'labels.created.review':
5865
# Do something...
5966

60-
def on_submit(self, label: Dict, asset_id: str) -> None:
67+
def on_event(self, payload: dict) -> None: # This can replace on_submit method
6168
"""Dedicated handler for Submit action"""
69+
event = payload.get("event")
70+
71+
if event == 'labels.created.submit':
6272
# Do something...
6373
```
6474

@@ -85,15 +95,22 @@ def custom_function(label: Dict, logger: Logger):
8595
class PluginHandler(PluginCore):
8696
"""Custom plugin"""
8797

88-
def on_submit(self, label: Dict, asset_id: str) -> None:
98+
def on_event(self, payload: dict) -> None:
8999
"""Dedicated handler for Submit action"""
90-
self.logger.info("On Submit called")
91-
custom_function(label, self.logger)
100+
event = payload.get("event")
101+
if event == 'labels.created.submit':
102+
self.logger.info("On Submit called")
103+
label = payload["label"]
104+
custom_function(label, self.logger)
92105
```
93106

94107
## Model for Plugins
95108

96109
::: kili.services.plugins.model.PluginCore
110+
options:
111+
filters:
112+
- "!^on_review$"
113+
- "!^on_submit$"
97114

98115
## Queries
99116

docs/sdk/tutorials/plugins_development.md

Lines changed: 0 additions & 281 deletions
This file was deleted.

docs/sdk/tutorials/plugins_example.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ This project has one job of bounding box creation with two categories.
9898

9999
With our plugin, we want to make sure that the labelers don't create more than one bounding box of category A.
100100

101-
To iterate on the plugin code, you can refer to the plugins_development.ipynb notebook.
102101

103102
## Step 3: Write the plugin
104103

docs/sdk/tutorials/plugins_library.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
In this section you can find multiple examples of use-cases where our system of plugins can help you in the Kili projects.
66

7-
You can also refer to our [tutorial](./plugins_development.md) to develop your plugin and iterate on it locally, before uploading the final version to Kili.
7+
You can also refer to our [tutorial](./plugins_example.md) to develop your plugin and iterate on it locally, before uploading the final version to Kili.
88

99
For further information concerning the Kili plugins, refer to the [Reference page](../plugins.md)
1010

mkdocs.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ nav:
4444
- PDF Assets: sdk/tutorials/importing_pdf_assets.md
4545
- Rich Text Assets: sdk/tutorials/import_text_assets.md
4646
- Multi-Layer Geospatial Assets: sdk/tutorials/importing_multilayer_geospatial_assets.md
47-
- LLM Static Assets : sdk/tutorials/llm_static.md
47+
- LLM Static Assets: sdk/tutorials/llm_static.md
4848
- Importing Labels:
4949
- Importing Labels: sdk/tutorials/importing_labels.md
5050
- OpenAI NER Pre-annotations: sdk/tutorials/ner_pre_annotations_openai.md
@@ -64,8 +64,7 @@ nav:
6464
- Parsing Labels: sdk/tutorials/label_parsing.md
6565
- LLM Dynamic Projects: sdk/tutorials/llm_dynamic.md
6666
- Setting Up Plugins:
67-
- Developing Plugins: sdk/tutorials/plugins_development.md
68-
- Plugin Example - Programmatic QA: sdk/tutorials/plugins_example.md
67+
- Developing Plugins: sdk/tutorials/plugins_example.md
6968
- Plugins Library: sdk/tutorials/plugins_library.md
7069
- Webhooks: sdk/tutorials/webhooks_example.md
7170
- Integrations:

0 commit comments

Comments
 (0)