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.
- zenml/VERSION +1 -1
- zenml/actions/base_action.py +177 -174
- zenml/actions/pipeline_run/pipeline_run_action.py +28 -23
- zenml/artifact_stores/base_artifact_store.py +7 -1
- zenml/artifacts/utils.py +13 -10
- zenml/cli/service_connectors.py +1 -0
- zenml/client.py +234 -58
- zenml/config/compiler.py +10 -9
- zenml/config/docker_settings.py +25 -9
- zenml/constants.py +1 -1
- zenml/event_hub/base_event_hub.py +5 -5
- zenml/event_hub/event_hub.py +15 -6
- zenml/event_sources/base_event.py +0 -11
- zenml/event_sources/base_event_source.py +7 -0
- zenml/event_sources/webhooks/base_webhook_event_source.py +1 -4
- zenml/exceptions.py +4 -0
- zenml/hooks/hook_validators.py +2 -3
- zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py +3 -3
- zenml/integrations/mlflow/__init__.py +1 -1
- zenml/integrations/s3/artifact_stores/s3_artifact_store.py +76 -3
- zenml/logging/step_logging.py +54 -51
- zenml/models/__init__.py +17 -0
- zenml/models/v2/core/action.py +276 -0
- zenml/models/v2/core/trigger.py +182 -141
- zenml/new/pipelines/pipeline.py +13 -3
- zenml/new/pipelines/pipeline_decorator.py +1 -2
- zenml/new/pipelines/run_utils.py +1 -12
- zenml/new/steps/step_decorator.py +2 -3
- zenml/pipelines/base_pipeline.py +0 -2
- zenml/pipelines/pipeline_decorator.py +1 -2
- zenml/stack/stack_component.py +4 -0
- zenml/steps/base_step.py +1 -2
- zenml/steps/step_decorator.py +1 -2
- zenml/types.py +10 -1
- zenml/utils/pipeline_docker_image_builder.py +20 -5
- zenml/zen_server/rbac/models.py +1 -0
- zenml/zen_server/rbac/utils.py +22 -1
- zenml/zen_server/routers/actions_endpoints.py +324 -0
- zenml/zen_server/routers/triggers_endpoints.py +30 -158
- zenml/zen_server/zen_server_api.py +2 -0
- zenml/zen_stores/migrations/versions/25155145c545_separate_actions_and_triggers.py +228 -0
- zenml/zen_stores/rest_zen_store.py +103 -4
- zenml/zen_stores/schemas/__init__.py +2 -0
- zenml/zen_stores/schemas/action_schemas.py +192 -0
- zenml/zen_stores/schemas/trigger_schemas.py +43 -50
- zenml/zen_stores/schemas/user_schemas.py +10 -2
- zenml/zen_stores/schemas/workspace_schemas.py +5 -0
- zenml/zen_stores/sql_zen_store.py +240 -30
- zenml/zen_stores/zen_store_interface.py +85 -0
- {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/METADATA +2 -2
- {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/RECORD +54 -50
- {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/LICENSE +0 -0
- {zenml_nightly-0.58.2.dev20240623.dist-info → zenml_nightly-0.58.2.dev20240626.dist-info}/WHEEL +0 -0
- {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.
|
1
|
+
0.58.2.dev20240626
|
zenml/actions/base_action.py
CHANGED
@@ -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
|
243
|
-
"""Process a
|
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
|
-
|
246
|
+
action: Action request.
|
247
247
|
|
248
|
-
|
249
|
-
|
248
|
+
Raises:
|
249
|
+
Exception: If the implementation specific processing before creating
|
250
|
+
the action fails.
|
250
251
|
|
251
|
-
|
252
|
+
Returns:
|
253
|
+
The created action.
|
252
254
|
"""
|
253
255
|
# Validate and instantiate the configuration from the request
|
254
|
-
config = self.validate_action_configuration(
|
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.
|
259
|
+
self._validate_action_request(action=action, config=config)
|
258
260
|
# Serialize the configuration back into the request
|
259
|
-
|
260
|
-
# Create the
|
261
|
-
|
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(
|
266
|
+
config = self.validate_action_configuration(action.configuration)
|
265
267
|
# Call the implementation specific method to process the created
|
266
|
-
#
|
267
|
-
self.
|
268
|
-
|
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.
|
273
|
-
|
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
|
277
|
+
# If the action creation fails, delete the action from
|
280
278
|
# the database
|
281
279
|
logger.exception(
|
282
|
-
f"Failed to create
|
283
|
-
f"Deleting the
|
280
|
+
f"Failed to create action {action_response}. "
|
281
|
+
f"Deleting the action."
|
284
282
|
)
|
285
|
-
self.zen_store.
|
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
|
-
|
287
|
+
action_response.set_configuration(config.model_dump(exclude_none=True))
|
290
288
|
# Return the response to the user
|
291
|
-
return
|
289
|
+
return action_response
|
292
290
|
|
293
|
-
def
|
291
|
+
def update_action(
|
294
292
|
self,
|
295
|
-
|
296
|
-
|
297
|
-
) ->
|
298
|
-
"""Process
|
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
|
-
|
302
|
-
|
299
|
+
action: The action to update.
|
300
|
+
action_update: The update to be applied to the action.
|
303
301
|
|
304
|
-
|
305
|
-
|
302
|
+
Raises:
|
303
|
+
Exception: If the implementation specific processing before updating
|
304
|
+
the action fails.
|
306
305
|
|
307
|
-
|
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(
|
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
|
316
|
+
if action_update.configuration is not None:
|
317
317
|
config_update = self.validate_action_configuration(
|
318
|
-
|
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.
|
323
|
-
|
322
|
+
self._validate_action_update(
|
323
|
+
action=action,
|
324
324
|
config=config,
|
325
|
-
|
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
|
-
|
329
|
+
action_update.configuration = config_update.model_dump(
|
330
|
+
exclude_none=True
|
331
|
+
)
|
330
332
|
|
331
|
-
# Update the
|
332
|
-
|
333
|
-
|
334
|
-
|
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
|
-
|
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.
|
344
|
-
|
345
|
+
self._process_action_update(
|
346
|
+
action=action_response,
|
345
347
|
config=response_config,
|
346
|
-
|
348
|
+
previous_action=action,
|
347
349
|
previous_config=config,
|
348
350
|
)
|
349
|
-
# Add any implementation specific related resources to the
|
351
|
+
# Add any implementation specific related resources to the action
|
350
352
|
# response
|
351
|
-
self.
|
352
|
-
|
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
|
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
|
363
|
-
f"Rolling back the
|
360
|
+
f"Failed to update action {action}. "
|
361
|
+
f"Rolling back the action to the previous state."
|
364
362
|
)
|
365
|
-
self.zen_store.
|
366
|
-
|
367
|
-
|
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
|
-
|
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
|
374
|
+
return action_response
|
377
375
|
|
378
|
-
def
|
376
|
+
def delete_action(
|
379
377
|
self,
|
380
|
-
|
378
|
+
action: ActionResponse,
|
381
379
|
force: bool = False,
|
382
380
|
) -> None:
|
383
|
-
"""Process
|
381
|
+
"""Process action delete request and delete the action in the database.
|
384
382
|
|
385
383
|
Args:
|
386
|
-
|
387
|
-
force: Whether to force delete the
|
388
|
-
even if the
|
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
|
-
|
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(
|
395
|
+
config = self.validate_action_configuration(action.configuration)
|
396
396
|
try:
|
397
397
|
# Call the implementation specific method to process the deleted
|
398
|
-
#
|
399
|
-
self.
|
400
|
-
|
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
|
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
|
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
|
415
|
-
self.zen_store.
|
416
|
-
|
411
|
+
# Delete the action from the database
|
412
|
+
self.zen_store.delete_action(
|
413
|
+
action_id=action.id,
|
417
414
|
)
|
418
415
|
|
419
|
-
def
|
420
|
-
self,
|
421
|
-
) ->
|
422
|
-
"""Process a
|
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
|
-
|
426
|
-
hydrate: Whether to hydrate the
|
422
|
+
action: The action fetched from the database.
|
423
|
+
hydrate: Whether to hydrate the action.
|
427
424
|
|
428
425
|
Returns:
|
429
|
-
The
|
426
|
+
The action.
|
430
427
|
"""
|
431
428
|
if hydrate:
|
432
429
|
# Instantiate the configuration from the response
|
433
|
-
config = self.validate_action_configuration(
|
430
|
+
config = self.validate_action_configuration(action.configuration)
|
434
431
|
# Call the implementation specific method to process the response
|
435
|
-
self.
|
432
|
+
self._process_action_response(action=action, config=config)
|
436
433
|
# Serialize the configuration back into the response
|
437
|
-
|
438
|
-
# Add any implementation specific related resources to the
|
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.
|
441
|
-
|
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
|
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
|
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
|
482
|
-
self,
|
480
|
+
def _validate_action_request(
|
481
|
+
self, action: ActionRequest, config: ActionConfig
|
483
482
|
) -> None:
|
484
|
-
"""Validate
|
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
|
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
|
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
|
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
|
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
|
-
|
504
|
+
action: Action request.
|
506
505
|
config: Action configuration instantiated from the request.
|
507
506
|
"""
|
508
507
|
pass
|
509
508
|
|
510
|
-
def
|
511
|
-
self,
|
509
|
+
def _process_action_request(
|
510
|
+
self, action: ActionResponse, config: ActionConfig
|
512
511
|
) -> None:
|
513
|
-
"""Process
|
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
|
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
|
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
|
526
|
-
fails, the implementation should raise an exception and the
|
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
|
-
|
529
|
+
action: Newly created action
|
531
530
|
config: Action configuration instantiated from the response.
|
532
531
|
"""
|
533
532
|
pass
|
534
533
|
|
535
|
-
def
|
534
|
+
def _validate_action_update(
|
536
535
|
self,
|
537
|
-
|
536
|
+
action: ActionResponse,
|
538
537
|
config: ActionConfig,
|
539
|
-
|
538
|
+
action_update: ActionUpdate,
|
540
539
|
config_update: ActionConfig,
|
541
540
|
) -> None:
|
542
|
-
"""Validate
|
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
|
-
|
547
|
-
|
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
|
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
|
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
|
-
|
562
|
+
action: Original action before the update.
|
564
563
|
config: Action configuration instantiated from the original
|
565
564
|
trigger.
|
566
|
-
|
565
|
+
action_update: Action update request.
|
567
566
|
config_update: Action configuration instantiated from the
|
568
|
-
updated
|
567
|
+
updated action.
|
569
568
|
"""
|
570
569
|
pass
|
571
570
|
|
572
|
-
def
|
571
|
+
def _process_action_update(
|
573
572
|
self,
|
574
|
-
|
573
|
+
action: ActionResponse,
|
575
574
|
config: ActionConfig,
|
576
|
-
|
575
|
+
previous_action: ActionResponse,
|
577
576
|
previous_config: ActionConfig,
|
578
577
|
) -> None:
|
579
|
-
"""Process
|
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
|
-
|
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
|
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
|
590
|
+
resources required for the action update. If any of the
|
592
591
|
provisioning fails, the implementation should raise an exception and the
|
593
|
-
|
592
|
+
action will be rolled back to the previous state in the database.
|
594
593
|
|
595
594
|
Args:
|
596
|
-
|
595
|
+
action: Action after the update.
|
597
596
|
config: Action configuration instantiated from the updated
|
598
|
-
|
599
|
-
|
597
|
+
action.
|
598
|
+
previous_action: Original action before the update.
|
600
599
|
previous_config: Action configuration instantiated from the
|
601
|
-
original
|
600
|
+
original action.
|
602
601
|
"""
|
603
602
|
pass
|
604
603
|
|
605
|
-
def
|
604
|
+
def _process_action_delete(
|
606
605
|
self,
|
607
|
-
|
606
|
+
action: ActionResponse,
|
608
607
|
config: ActionConfig,
|
609
608
|
force: Optional[bool] = False,
|
610
609
|
) -> None:
|
611
|
-
"""Process
|
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
|
-
|
614
|
+
action.
|
616
615
|
|
617
616
|
The implementation should use this method to deprovision any external
|
618
|
-
resources required for the
|
617
|
+
resources required for the action. If any of the deprovisioning
|
619
618
|
fails, the implementation should raise an exception and the
|
620
|
-
|
621
|
-
case the
|
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
|
-
|
624
|
+
action: Action before the deletion.
|
626
625
|
config: Action configuration before the deletion.
|
627
|
-
force: Whether to force deprovision the
|
626
|
+
force: Whether to force deprovision the action.
|
628
627
|
"""
|
629
628
|
pass
|
630
629
|
|
631
|
-
def
|
632
|
-
self,
|
630
|
+
def _process_action_response(
|
631
|
+
self, action: ActionResponse, config: ActionConfig
|
633
632
|
) -> None:
|
634
|
-
"""Process
|
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
|
636
|
+
implementation specific functionality pertaining to how the action
|
638
637
|
response is returned to the user. The implementation may modify the
|
639
|
-
the
|
638
|
+
the action response and/or configuration in place.
|
640
639
|
|
641
|
-
The resulted configuration is serialized back into the
|
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
|
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 `
|
647
|
-
and `
|
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
|
-
|
650
|
+
action: Action response.
|
652
651
|
config: Action configuration instantiated from the response.
|
653
652
|
"""
|
654
653
|
pass
|
655
654
|
|
656
|
-
def
|
657
|
-
self,
|
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
|
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
|
664
|
+
implementation specific related resources to the action response.
|
663
665
|
|
664
|
-
This method is applied to all
|
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 `
|
667
|
-
and `
|
668
|
+
those returned from the `create_action`, `update_action`,
|
669
|
+
and `delete_action` methods.
|
668
670
|
|
669
671
|
Args:
|
670
|
-
|
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
|
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(
|
682
|
+
setattr(action.resources, str(resource_type), resource)
|