|
205 | 205 | " Custom plugin instance\n", |
206 | 206 | " \"\"\"\n", |
207 | 207 | "\n", |
208 | | - " def on_event(self, payload: dict) -> None:\n", |
| 208 | + " def on_submit(self, label: Dict, asset_id: str) -> None:\n", |
209 | 209 | " \"\"\"\n", |
210 | 210 | " Dedicated handler for Submit action \n", |
211 | 211 | " \"\"\"\n", |
212 | | - " event = payload.get(\"event\")\n", |
| 212 | + " self.logger.info(\"On submit called\")\n", |
213 | 213 | "\n", |
214 | | - " if event == 'labels.created.submit':\n", |
215 | | - " label = payload[\"label\"]\n", |
216 | | - " asset_id = label[\"assetId\"]\n", |
217 | | - " self.logger.info(\"On submit called\")\n", |
| 214 | + " issues_array = check_rules_on_label(label)\n", |
218 | 215 | "\n", |
219 | | - " issues_array = check_rules_on_label(label)\n", |
| 216 | + " project_id = self.project_id\n", |
220 | 217 | "\n", |
221 | | - " project_id = self.project_id\n", |
| 218 | + " if len(issues_array) > 0:\n", |
| 219 | + " print(\"Creating an issue...\")\n", |
222 | 220 | "\n", |
223 | | - " if len(issues_array) > 0:\n", |
224 | | - " print(\"Creating an issue...\")\n", |
| 221 | + " self.kili.create_issues(\n", |
| 222 | + " project_id=project_id,\n", |
| 223 | + " label_id_array=[label['id']] * len(issues_array),\n", |
| 224 | + " text_array=issues_array,\n", |
| 225 | + " )\n", |
225 | 226 | "\n", |
226 | | - " self.kili.create_issues(\n", |
227 | | - " project_id=project_id,\n", |
228 | | - " label_id_array=[label['id']] * len(issues_array),\n", |
229 | | - " text_array=issues_array,\n", |
230 | | - " )\n", |
| 227 | + " print(\"Issue created!\")\n", |
231 | 228 | "\n", |
232 | | - " print(\"Issue created!\")\n", |
233 | | - "\n", |
234 | | - " self.kili.send_back_to_queue(asset_ids=[asset_id])\n", |
| 229 | + " self.kili.send_back_to_queue(asset_ids=[asset_id])\n", |
235 | 230 | "\n", |
236 | 231 | "```" |
237 | 232 | ] |
|
324 | 319 | "from kili.exceptions import GraphQLError\n", |
325 | 320 | "\n", |
326 | 321 | "try:\n", |
327 | | - " kili.upload_plugin(plugin_folder, plugin_name, event_matcher=[\"labels.created.submit\"])\n", |
| 322 | + " kili.upload_plugin(plugin_folder, plugin_name)\n", |
328 | 323 | "except GraphQLError as error:\n", |
329 | 324 | " print(str(error))" |
330 | 325 | ] |
|
364 | 359 | "plugin_name_file = \"Plugin bbox count - file\"\n", |
365 | 360 | "\n", |
366 | 361 | "try:\n", |
367 | | - " kili.upload_plugin(\n", |
368 | | - " str(path_to_plugin), plugin_name_file, event_matcher=[\"labels.created.submit\"]\n", |
369 | | - " )\n", |
| 362 | + " kili.upload_plugin(str(path_to_plugin), plugin_name_file)\n", |
370 | 363 | "except GraphQLError as error:\n", |
371 | 364 | " print(str(error))" |
372 | 365 | ] |
|
0 commit comments