zenml-nightly 0.58.2.dev20240623__py3-none-any.whl → 0.58.2.dev20240626__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. zenml/VERSION +1 -1
  2. zenml/actions/base_action.py +177 -174
  3. zenml/actions/pipeline_run/pipeline_run_action.py +28 -23
  4. zenml/artifact_stores/base_artifact_store.py +7 -1
  5. zenml/artifacts/utils.py +13 -10
  6. zenml/cli/service_connectors.py +1 -0
  7. zenml/client.py +234 -58
  8. zenml/config/compiler.py +10 -9
  9. zenml/config/docker_settings.py +25 -9
  10. zenml/constants.py +1 -1
  11. zenml/event_hub/base_event_hub.py +5 -5
  12. zenml/event_hub/event_hub.py +15 -6
  13. zenml/event_sources/base_event.py +0 -11
  14. zenml/event_sources/base_event_source.py +7 -0
  15. zenml/event_sources/webhooks/base_webhook_event_source.py +1 -4
  16. zenml/exceptions.py +4 -0
  17. zenml/hooks/hook_validators.py +2 -3
  18. zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py +3 -3
  19. zenml/integrations/mlflow/__init__.py +1 -1
  20. zenml/integrations/s3/artifact_stores/s3_artifact_store.py +76 -3
  21. zenml/logging/step_logging.py +54 -51
  22. zenml/models/__init__.py +17 -0
  23. zenml/models/v2/core/action.py +276 -0
  24. zenml/models/v2/core/trigger.py +182 -141
  25. zenml/new/pipelines/pipeline.py +13 -3
  26. zenml/new/pipelines/pipeline_decorator.py +1 -2
  27. zenml/new/pipelines/run_utils.py +1 -12
  28. zenml/new/steps/step_decorator.py +2 -3
  29. zenml/pipelines/base_pipeline.py +0 -2
  30. zenml/pipelines/pipeline_decorator.py +1 -2
  31. zenml/stack/stack_component.py +4 -0
  32. zenml/steps/base_step.py +1 -2
  33. zenml/steps/step_decorator.py +1 -2
  34. zenml/types.py +10 -1
  35. zenml/utils/pipeline_docker_image_builder.py +20 -5
  36. zenml/zen_server/rbac/models.py +1 -0
  37. zenml/zen_server/rbac/utils.py +22 -1
  38. zenml/zen_server/routers/actions_endpoints.py +324 -0
  39. zenml/zen_server/routers/triggers_endpoints.py +30 -158
  40. zenml/zen_server/zen_server_api.py +2 -0
  41. zenml/zen_stores/migrations/versions/25155145c545_separate_actions_and_triggers.py +228 -0
  42. zenml/zen_stores/rest_zen_store.py +103 -4
  43. zenml/zen_stores/schemas/__init__.py +2 -0
  44. zenml/zen_stores/schemas/action_schemas.py +192 -0
  45. zenml/zen_stores/schemas/trigger_schemas.py +43 -50
  46. zenml/zen_stores/schemas/user_schemas.py +10 -2
  47. zenml/zen_stores/schemas/workspace_schemas.py +5 -0
  48. zenml/zen_stores/sql_zen_store.py +240 -30
  49. zenml/zen_stores/zen_store_interface.py +85 -0
  50. {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/METADATA +2 -2
  51. {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/RECORD +54 -50
  52. {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/LICENSE +0 -0
  53. {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/WHEEL +0 -0
  54. {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/entry_points.txt +0 -0
zenml/VERSION CHANGED
@@ -1 +1 @@
1
- 0.58.2.dev20240623
1
+ 0.58.2.dev20240626
@@ -23,10 +23,10 @@ from zenml.models import (
23
23
  ActionFlavorResponse,
24
24
  ActionFlavorResponseBody,
25
25
  ActionFlavorResponseMetadata,
26
+ ActionRequest,
27
+ ActionResponse,
28
+ ActionUpdate,
26
29
  TriggerExecutionResponse,
27
- TriggerRequest,
28
- TriggerResponse,
29
- TriggerUpdate,
30
30
  )
31
31
  from zenml.models.v2.base.base import BaseResponse
32
32
  from zenml.plugins.base_plugin_flavor import (
@@ -239,210 +239,207 @@ class BaseActionHandler(BasePlugin, ABC):
239
239
  trigger's authentication window.
240
240
  """
241
241
 
242
- def create_trigger(self, trigger: TriggerRequest) -> TriggerResponse:
243
- """Process a trigger request and create the trigger in the database.
242
+ def create_action(self, action: ActionRequest) -> ActionResponse:
243
+ """Process a action request and create the action in the database.
244
244
 
245
245
  Args:
246
- trigger: Trigger request.
246
+ action: Action request.
247
247
 
248
- Returns:
249
- The created trigger.
248
+ Raises:
249
+ Exception: If the implementation specific processing before creating
250
+ the action fails.
250
251
 
251
- # noqa: DAR401
252
+ Returns:
253
+ The created action.
252
254
  """
253
255
  # Validate and instantiate the configuration from the request
254
- config = self.validate_action_configuration(trigger.action)
256
+ config = self.validate_action_configuration(action.configuration)
255
257
  # Call the implementation specific method to validate the request
256
258
  # before it is sent to the database
257
- self._validate_trigger_request(trigger=trigger, config=config)
259
+ self._validate_action_request(action=action, config=config)
258
260
  # Serialize the configuration back into the request
259
- trigger.action = config.model_dump(exclude_none=True)
260
- # Create the trigger in the database
261
- trigger_response = self.zen_store.create_trigger(trigger=trigger)
261
+ action.configuration = config.model_dump(exclude_none=True)
262
+ # Create the action in the database
263
+ action_response = self.zen_store.create_action(action=action)
262
264
  try:
263
265
  # Instantiate the configuration from the response
264
- config = self.validate_action_configuration(trigger.action)
266
+ config = self.validate_action_configuration(action.configuration)
265
267
  # Call the implementation specific method to process the created
266
- # trigger
267
- self._process_trigger_request(
268
- trigger=trigger_response, config=config
269
- )
270
- # Add any implementation specific related resources to the trigger
268
+ # action
269
+ self._process_action_request(action=action_response, config=config)
270
+ # Add any implementation specific related resources to the action
271
271
  # response
272
- self._populate_trigger_response_resources(
273
- trigger=trigger_response, config=config
272
+ self._populate_action_response_resources(
273
+ action=action_response,
274
+ config=config,
274
275
  )
275
- # Activate the trigger in the event hub to effectively start
276
- # dispatching events to the action handler
277
- self.event_hub.activate_trigger(trigger=trigger_response)
278
276
  except Exception:
279
- # If the trigger creation fails, delete the trigger from
277
+ # If the action creation fails, delete the action from
280
278
  # the database
281
279
  logger.exception(
282
- f"Failed to create trigger {trigger_response}. "
283
- f"Deleting the trigger."
280
+ f"Failed to create action {action_response}. "
281
+ f"Deleting the action."
284
282
  )
285
- self.zen_store.delete_trigger(trigger_id=trigger_response.id)
283
+ self.zen_store.delete_action(action_id=action_response.id)
286
284
  raise
287
285
 
288
286
  # Serialize the configuration back into the response
289
- trigger_response.set_action(config.model_dump(exclude_none=True))
287
+ action_response.set_configuration(config.model_dump(exclude_none=True))
290
288
  # Return the response to the user
291
- return trigger_response
289
+ return action_response
292
290
 
293
- def update_trigger(
291
+ def update_action(
294
292
  self,
295
- trigger: TriggerResponse,
296
- trigger_update: TriggerUpdate,
297
- ) -> TriggerResponse:
298
- """Process a trigger update request and update the trigger in the database.
293
+ action: ActionResponse,
294
+ action_update: ActionUpdate,
295
+ ) -> ActionResponse:
296
+ """Process action update and update the action in the database.
299
297
 
300
298
  Args:
301
- trigger: The trigger to update.
302
- trigger_update: The update to be applied to the trigger.
299
+ action: The action to update.
300
+ action_update: The update to be applied to the action.
303
301
 
304
- Returns:
305
- The updated trigger.
302
+ Raises:
303
+ Exception: If the implementation specific processing before updating
304
+ the action fails.
306
305
 
307
- # noqa: DAR401
306
+ Returns:
307
+ The updated action.
308
308
  """
309
309
  # Validate and instantiate the configuration from the original event
310
310
  # source
311
- config = self.validate_action_configuration(trigger.action)
311
+ config = self.validate_action_configuration(action.configuration)
312
312
  # Validate and instantiate the configuration from the update request
313
313
  # NOTE: if supplied, the configuration update is a full replacement
314
314
  # of the original configuration
315
315
  config_update = config
316
- if trigger_update.action is not None:
316
+ if action_update.configuration is not None:
317
317
  config_update = self.validate_action_configuration(
318
- trigger_update.action
318
+ action_update.configuration
319
319
  )
320
320
  # Call the implementation specific method to validate the update request
321
321
  # before it is sent to the database
322
- self._validate_trigger_update(
323
- trigger=trigger,
322
+ self._validate_action_update(
323
+ action=action,
324
324
  config=config,
325
- trigger_update=trigger_update,
325
+ action_update=action_update,
326
326
  config_update=config_update,
327
327
  )
328
328
  # Serialize the configuration update back into the update request
329
- trigger_update.action = config_update.model_dump(exclude_none=True)
329
+ action_update.configuration = config_update.model_dump(
330
+ exclude_none=True
331
+ )
330
332
 
331
- # Update the trigger in the database
332
- trigger_response = self.zen_store.update_trigger(
333
- trigger_id=trigger.id,
334
- trigger_update=trigger_update,
333
+ # Update the action in the database
334
+ action_response = self.zen_store.update_action(
335
+ action_id=action.id,
336
+ action_update=action_update,
335
337
  )
336
338
  try:
337
339
  # Instantiate the configuration from the response
338
340
  response_config = self.validate_action_configuration(
339
- trigger_response.action
341
+ action_response.configuration
340
342
  )
341
343
  # Call the implementation specific method to process the update
342
344
  # request before it is sent to the database
343
- self._process_trigger_update(
344
- trigger=trigger_response,
345
+ self._process_action_update(
346
+ action=action_response,
345
347
  config=response_config,
346
- previous_trigger=trigger,
348
+ previous_action=action,
347
349
  previous_config=config,
348
350
  )
349
- # Add any implementation specific related resources to the trigger
351
+ # Add any implementation specific related resources to the action
350
352
  # response
351
- self._populate_trigger_response_resources(
352
- trigger=trigger_response, config=response_config
353
+ self._populate_action_response_resources(
354
+ action=action_response, config=response_config
353
355
  )
354
- # Deactivate the previous trigger and activate the updated trigger
355
- # in the event hub
356
- self.event_hub.deactivate_trigger(trigger=trigger)
357
- self.event_hub.activate_trigger(trigger=trigger_response)
358
356
  except Exception:
359
- # If the trigger update fails, roll back the trigger in
357
+ # If the action update fails, roll back the action in
360
358
  # the database to the original state
361
359
  logger.exception(
362
- f"Failed to update trigger {trigger}. "
363
- f"Rolling back the trigger to the previous state."
360
+ f"Failed to update action {action}. "
361
+ f"Rolling back the action to the previous state."
364
362
  )
365
- self.zen_store.update_trigger(
366
- trigger_id=trigger.id,
367
- trigger_update=TriggerUpdate.from_response(trigger),
363
+ self.zen_store.update_action(
364
+ action_id=action.id,
365
+ action_update=ActionUpdate.from_response(action),
368
366
  )
369
367
  raise
370
368
 
371
369
  # Serialize the configuration back into the response
372
- trigger_response.set_action(
370
+ action_response.set_configuration(
373
371
  response_config.model_dump(exclude_none=True)
374
372
  )
375
373
  # Return the response to the user
376
- return trigger_response
374
+ return action_response
377
375
 
378
- def delete_trigger(
376
+ def delete_action(
379
377
  self,
380
- trigger: TriggerResponse,
378
+ action: ActionResponse,
381
379
  force: bool = False,
382
380
  ) -> None:
383
- """Process a trigger delete request and delete the trigger in the database.
381
+ """Process action delete request and delete the action in the database.
384
382
 
385
383
  Args:
386
- trigger: The trigger to delete.
387
- force: Whether to force delete the trigger from the database
388
- even if the trigger handler fails to delete the event
384
+ action: The action to delete.
385
+ force: Whether to force delete the action from the database
386
+ even if the action handler fails to delete the event
389
387
  source.
390
388
 
391
- # noqa: DAR401
389
+ Raises:
390
+ Exception: If the implementation specific processing before deleting
391
+ the action fails.
392
392
  """
393
393
  # Validate and instantiate the configuration from the original event
394
394
  # source
395
- config = self.validate_action_configuration(trigger.action)
395
+ config = self.validate_action_configuration(action.configuration)
396
396
  try:
397
397
  # Call the implementation specific method to process the deleted
398
- # trigger before it is deleted from the database
399
- self._process_trigger_delete(
400
- trigger=trigger,
398
+ # action before it is deleted from the database
399
+ self._process_action_delete(
400
+ action=action,
401
401
  config=config,
402
402
  force=force,
403
403
  )
404
404
  except Exception:
405
- logger.exception(f"Failed to delete trigger {trigger}. ")
405
+ logger.exception(f"Failed to delete action {action}. ")
406
406
  if not force:
407
407
  raise
408
408
 
409
- logger.warning(f"Force deleting trigger {trigger}.")
410
-
411
- # Deactivate the trigger in the event hub
412
- self.event_hub.deactivate_trigger(trigger=trigger)
409
+ logger.warning(f"Force deleting action {action}.")
413
410
 
414
- # Delete the trigger from the database
415
- self.zen_store.delete_trigger(
416
- trigger_id=trigger.id,
411
+ # Delete the action from the database
412
+ self.zen_store.delete_action(
413
+ action_id=action.id,
417
414
  )
418
415
 
419
- def get_trigger(
420
- self, trigger: TriggerResponse, hydrate: bool = False
421
- ) -> TriggerResponse:
422
- """Process a trigger response before it is returned to the user.
416
+ def get_action(
417
+ self, action: ActionResponse, hydrate: bool = False
418
+ ) -> ActionResponse:
419
+ """Process a action response before it is returned to the user.
423
420
 
424
421
  Args:
425
- trigger: The trigger fetched from the database.
426
- hydrate: Whether to hydrate the trigger.
422
+ action: The action fetched from the database.
423
+ hydrate: Whether to hydrate the action.
427
424
 
428
425
  Returns:
429
- The trigger.
426
+ The action.
430
427
  """
431
428
  if hydrate:
432
429
  # Instantiate the configuration from the response
433
- config = self.validate_action_configuration(trigger.action)
430
+ config = self.validate_action_configuration(action.configuration)
434
431
  # Call the implementation specific method to process the response
435
- self._process_trigger_response(trigger=trigger, config=config)
432
+ self._process_action_response(action=action, config=config)
436
433
  # Serialize the configuration back into the response
437
- trigger.set_action(config.model_dump(exclude_none=True))
438
- # Add any implementation specific related resources to the trigger
434
+ action.set_configuration(config.model_dump(exclude_none=True))
435
+ # Add any implementation specific related resources to the action
439
436
  # response
440
- self._populate_trigger_response_resources(
441
- trigger=trigger, config=config
437
+ self._populate_action_response_resources(
438
+ action=action, config=config
442
439
  )
443
440
 
444
441
  # Return the response to the user
445
- return trigger
442
+ return action
446
443
 
447
444
  def validate_action_configuration(
448
445
  self, action_config: Dict[str, Any]
@@ -450,7 +447,7 @@ class BaseActionHandler(BasePlugin, ABC):
450
447
  """Validate and return the action configuration.
451
448
 
452
449
  Args:
453
- action_config: The actino configuration to validate.
450
+ action_config: The action configuration to validate.
454
451
 
455
452
  Returns:
456
453
  The validated action configuration.
@@ -466,214 +463,220 @@ class BaseActionHandler(BasePlugin, ABC):
466
463
  def extract_resources(
467
464
  self,
468
465
  action_config: ActionConfig,
466
+ hydrate: bool = False,
469
467
  ) -> Dict[ResourceType, BaseResponse[Any, Any, Any]]:
470
468
  """Extract related resources for this action.
471
469
 
472
470
  Args:
473
471
  action_config: Action configuration from which to extract related
474
472
  resources.
473
+ hydrate: Whether to hydrate the resource models.
475
474
 
476
475
  Returns:
477
476
  List of resources related to the action.
478
477
  """
479
478
  return {}
480
479
 
481
- def _validate_trigger_request(
482
- self, trigger: TriggerRequest, config: ActionConfig
480
+ def _validate_action_request(
481
+ self, action: ActionRequest, config: ActionConfig
483
482
  ) -> None:
484
- """Validate a trigger request before it is created in the database.
483
+ """Validate an action request before it is created in the database.
485
484
 
486
485
  Concrete action handlers should override this method to add
487
486
  implementation specific functionality pertaining to the validation of
488
- a new trigger. The implementation may also modify the trigger
487
+ a new action. The implementation may also modify the action
489
488
  request and/or configuration in place to apply implementation specific
490
489
  changes before the request is stored in the database.
491
490
 
492
491
  If validation is required, the implementation should raise a
493
492
  ValueError if the configuration is invalid. If any exceptions are raised
494
- during the validation, the trigger will not be created in the
493
+ during the validation, the action will not be created in the
495
494
  database.
496
495
 
497
- The resulted action configuration is serialized back into the trigger
496
+ The resulted action configuration is serialized back into the action
498
497
  request before it is stored in the database.
499
498
 
500
499
  The implementation should not use this method to provision any external
501
- resources, as the trigger may not be created in the database if
500
+ resources, as the action may not be created in the database if
502
501
  the database level validation fails.
503
502
 
504
503
  Args:
505
- trigger: Trigger request.
504
+ action: Action request.
506
505
  config: Action configuration instantiated from the request.
507
506
  """
508
507
  pass
509
508
 
510
- def _process_trigger_request(
511
- self, trigger: TriggerResponse, config: ActionConfig
509
+ def _process_action_request(
510
+ self, action: ActionResponse, config: ActionConfig
512
511
  ) -> None:
513
- """Process a trigger request after it is created in the database.
512
+ """Process an action request after it is created in the database.
514
513
 
515
514
  Concrete action handlers should override this method to add
516
515
  implementation specific functionality pertaining to the creation of
517
- a new trigger. The implementation may also modify the trigger
516
+ a new action. The implementation may also modify the action
518
517
  response and/or configuration in place to apply implementation specific
519
518
  changes before the response is returned to the user.
520
519
 
521
- The resulted configuration is serialized back into the trigger
520
+ The resulted configuration is serialized back into the action
522
521
  response before it is returned to the user.
523
522
 
524
523
  The implementation should use this method to provision any external
525
- resources required for the trigger. If any of the provisioning
526
- fails, the implementation should raise an exception and the trigger
524
+ resources required for the action. If any of the provisioning
525
+ fails, the implementation should raise an exception and the action
527
526
  will be deleted from the database.
528
527
 
529
528
  Args:
530
- trigger: Newly created trigger
529
+ action: Newly created action
531
530
  config: Action configuration instantiated from the response.
532
531
  """
533
532
  pass
534
533
 
535
- def _validate_trigger_update(
534
+ def _validate_action_update(
536
535
  self,
537
- trigger: TriggerResponse,
536
+ action: ActionResponse,
538
537
  config: ActionConfig,
539
- trigger_update: TriggerUpdate,
538
+ action_update: ActionUpdate,
540
539
  config_update: ActionConfig,
541
540
  ) -> None:
542
- """Validate a trigger update before it is reflected in the database.
541
+ """Validate an action update before it is reflected in the database.
543
542
 
544
543
  Concrete action handlers should override this method to add
545
544
  implementation specific functionality pertaining to validation of an
546
- trigger update request. The implementation may also modify the
547
- trigger update and/or configuration update in place to apply
545
+ action update request. The implementation may also modify the
546
+ action update and/or configuration update in place to apply
548
547
  implementation specific changes.
549
548
 
550
549
  If validation is required, the implementation should raise a
551
550
  ValueError if the configuration update is invalid. If any exceptions are
552
- raised during the validation, the trigger will not be updated in
551
+ raised during the validation, the action will not be updated in
553
552
  the database.
554
553
 
555
554
  The resulted configuration update is serialized back into the event
556
555
  source update before it is stored in the database.
557
556
 
558
557
  The implementation should not use this method to provision any external
559
- resources, as the trigger may not be updated in the database if
558
+ resources, as the action may not be updated in the database if
560
559
  the database level validation fails.
561
560
 
562
561
  Args:
563
- trigger: Original trigger before the update.
562
+ action: Original action before the update.
564
563
  config: Action configuration instantiated from the original
565
564
  trigger.
566
- trigger_update: Trigger update request.
565
+ action_update: Action update request.
567
566
  config_update: Action configuration instantiated from the
568
- updated trigger.
567
+ updated action.
569
568
  """
570
569
  pass
571
570
 
572
- def _process_trigger_update(
571
+ def _process_action_update(
573
572
  self,
574
- trigger: TriggerResponse,
573
+ action: ActionResponse,
575
574
  config: ActionConfig,
576
- previous_trigger: TriggerResponse,
575
+ previous_action: ActionResponse,
577
576
  previous_config: ActionConfig,
578
577
  ) -> None:
579
- """Process a trigger after it is updated in the database.
578
+ """Process an action after it is updated in the database.
580
579
 
581
580
  Concrete action handlers should override this method to add
582
581
  implementation specific functionality pertaining to updating an existing
583
- trigger. The implementation may also modify the trigger
582
+ action. The implementation may also modify the action
584
583
  and/or configuration in place to apply implementation specific
585
584
  changes before the response is returned to the user.
586
585
 
587
- The resulted configuration is serialized back into the trigger
586
+ The resulted configuration is serialized back into the action
588
587
  response before it is returned to the user.
589
588
 
590
589
  The implementation should use this method to provision any external
591
- resources required for the trigger update. If any of the
590
+ resources required for the action update. If any of the
592
591
  provisioning fails, the implementation should raise an exception and the
593
- trigger will be rolled back to the previous state in the database.
592
+ action will be rolled back to the previous state in the database.
594
593
 
595
594
  Args:
596
- trigger: Trigger after the update.
595
+ action: Action after the update.
597
596
  config: Action configuration instantiated from the updated
598
- trigger.
599
- previous_trigger: Original trigger before the update.
597
+ action.
598
+ previous_action: Original action before the update.
600
599
  previous_config: Action configuration instantiated from the
601
- original trigger.
600
+ original action.
602
601
  """
603
602
  pass
604
603
 
605
- def _process_trigger_delete(
604
+ def _process_action_delete(
606
605
  self,
607
- trigger: TriggerResponse,
606
+ action: ActionResponse,
608
607
  config: ActionConfig,
609
608
  force: Optional[bool] = False,
610
609
  ) -> None:
611
- """Process a trigger before it is deleted from the database.
610
+ """Process an action before it is deleted from the database.
612
611
 
613
612
  Concrete action handlers should override this method to add
614
613
  implementation specific functionality pertaining to the deletion of an
615
- trigger.
614
+ action.
616
615
 
617
616
  The implementation should use this method to deprovision any external
618
- resources required for the trigger. If any of the deprovisioning
617
+ resources required for the action. If any of the deprovisioning
619
618
  fails, the implementation should raise an exception and the
620
- trigger will kept in the database (unless force is True, in which
621
- case the trigger will be deleted from the database regardless of
619
+ action will kept in the database (unless force is True, in which
620
+ case the action will be deleted from the database regardless of
622
621
  any deprovisioning failures).
623
622
 
624
623
  Args:
625
- trigger: Trigger before the deletion.
624
+ action: Action before the deletion.
626
625
  config: Action configuration before the deletion.
627
- force: Whether to force deprovision the trigger.
626
+ force: Whether to force deprovision the action.
628
627
  """
629
628
  pass
630
629
 
631
- def _process_trigger_response(
632
- self, trigger: TriggerResponse, config: ActionConfig
630
+ def _process_action_response(
631
+ self, action: ActionResponse, config: ActionConfig
633
632
  ) -> None:
634
- """Process a trigger response before it is returned to the user.
633
+ """Process an action response before it is returned to the user.
635
634
 
636
635
  Concrete action handlers should override this method to add
637
- implementation specific functionality pertaining to how the trigger
636
+ implementation specific functionality pertaining to how the action
638
637
  response is returned to the user. The implementation may modify the
639
- the trigger response and/or configuration in place.
638
+ the action response and/or configuration in place.
640
639
 
641
- The resulted configuration is serialized back into the trigger
640
+ The resulted configuration is serialized back into the action
642
641
  response before it is returned to the user.
643
642
 
644
- This method is applied to all trigger responses fetched from the
643
+ This method is applied to all action responses fetched from the
645
644
  database before they are returned to the user, with the exception of
646
- those returned from the `create_trigger`, `update_trigger`,
647
- and `delete_trigger` methods, which have their own specific
645
+ those returned from the `create_action`, `update_action`,
646
+ and `delete_action` methods, which have their own specific
648
647
  processing methods.
649
648
 
650
649
  Args:
651
- trigger: Trigger response.
650
+ action: Action response.
652
651
  config: Action configuration instantiated from the response.
653
652
  """
654
653
  pass
655
654
 
656
- def _populate_trigger_response_resources(
657
- self, trigger: TriggerResponse, config: ActionConfig
655
+ def _populate_action_response_resources(
656
+ self,
657
+ action: ActionResponse,
658
+ config: ActionConfig,
659
+ hydrate: bool = False,
658
660
  ) -> None:
659
- """Populate related resources for the trigger response.
661
+ """Populate related resources for the action response.
660
662
 
661
663
  Concrete action handlers should override this method to add
662
- implementation specific related resources to the trigger response.
664
+ implementation specific related resources to the action response.
663
665
 
664
- This method is applied to all trigger responses fetched from the
666
+ This method is applied to all action responses fetched from the
665
667
  database before they are returned to the user, including
666
- those returned from the `create_trigger`, `update_trigger`,
667
- and `delete_trigger` methods.
668
+ those returned from the `create_action`, `update_action`,
669
+ and `delete_action` methods.
668
670
 
669
671
  Args:
670
- trigger: Trigger response.
672
+ action: Action response.
671
673
  config: Action configuration instantiated from the response.
674
+ hydrate: Whether to hydrate the resource models.
672
675
  """
673
- if trigger.resources is None:
676
+ if action.resources is None:
674
677
  # We only populate the resources if the resources field is already
675
678
  # set by the database by means of hydration.
676
679
  return
677
- extract_resources = self.extract_resources(config)
680
+ extract_resources = self.extract_resources(config, hydrate=hydrate)
678
681
  for resource_type, resource in extract_resources.items():
679
- setattr(trigger.resources, str(resource_type), resource)
682
+ setattr(action.resources, str(resource_type), resource)