Actions
zenml.actions
Actions allow configuring a given action for later execution.
Modules
base_action
Base implementation of actions.
Classes
ActionConfig
BaseActionFlavor
Bases: BasePluginFlavor
, ABC
Base Action Flavor to register Action Configurations.
get_action_config_schema() -> Dict[str, Any]
classmethod
The config schema for a flavor.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The config schema. |
Source code in src/zenml/actions/base_action.py
61 62 63 64 65 66 67 68 |
|
get_flavor_response_model(hydrate: bool) -> ActionFlavorResponse
classmethod
Convert the Flavor into a Response Model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hydrate
|
bool
|
Whether the model should be hydrated. |
required |
Returns:
Type | Description |
---|---|
ActionFlavorResponse
|
The response model. |
Source code in src/zenml/actions/base_action.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
BaseActionHandler(event_hub: Optional[BaseEventHub] = None)
Bases: BasePlugin
, ABC
Implementation for an action handler.
Event source handler initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_hub
|
Optional[BaseEventHub]
|
Optional event hub to use to initialize the event source
handler. If not set during initialization, it may be set
at a later time by calling |
None
|
Source code in src/zenml/actions/base_action.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
config_class: Type[ActionConfig]
abstractmethod
property
Returns the BasePluginConfig
config.
Returns:
Type | Description |
---|---|
Type[ActionConfig]
|
The configuration. |
event_hub: BaseEventHub
property
Get the event hub used to dispatch events.
Returns:
Type | Description |
---|---|
BaseEventHub
|
The event hub. |
Raises:
Type | Description |
---|---|
RuntimeError
|
if an event hub isn't configured. |
flavor_class: Type[BaseActionFlavor]
abstractmethod
property
Returns the flavor class of the plugin.
Returns:
Type | Description |
---|---|
Type[BaseActionFlavor]
|
The flavor class of the plugin. |
create_action(action: ActionRequest) -> ActionResponse
Process a action request and create the action in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action
|
ActionRequest
|
Action request. |
required |
Raises:
Type | Description |
---|---|
Exception
|
If the implementation specific processing before creating the action fails. |
Returns:
Type | Description |
---|---|
ActionResponse
|
The created action. |
Source code in src/zenml/actions/base_action.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
|
delete_action(action: ActionResponse, force: bool = False) -> None
Process action delete request and delete the action in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action
|
ActionResponse
|
The action to delete. |
required |
force
|
bool
|
Whether to force delete the action from the database even if the action handler fails to delete the event source. |
False
|
Raises:
Type | Description |
---|---|
Exception
|
If the implementation specific processing before deleting the action fails. |
Source code in src/zenml/actions/base_action.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
|
event_hub_callback(config: Dict[str, Any], trigger_execution: TriggerExecutionResponse, auth_context: AuthContext) -> None
Callback to be used by the event hub to dispatch events to the action handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
Dict[str, Any]
|
The action configuration |
required |
trigger_execution
|
TriggerExecutionResponse
|
The trigger execution |
required |
auth_context
|
AuthContext
|
Authentication context with an API token that can be used by external workloads to authenticate with the server during the execution of the action. This API token is associated with the service account that was configured for the trigger that activated the action and has a validity defined by the trigger's authentication window. |
required |
Source code in src/zenml/actions/base_action.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
extract_resources(action_config: ActionConfig, hydrate: bool = False) -> Dict[ResourceType, BaseResponse[Any, Any, Any]]
Extract related resources for this action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action_config
|
ActionConfig
|
Action configuration from which to extract related resources. |
required |
hydrate
|
bool
|
Whether to hydrate the resource models. |
False
|
Returns:
Type | Description |
---|---|
Dict[ResourceType, BaseResponse[Any, Any, Any]]
|
List of resources related to the action. |
Source code in src/zenml/actions/base_action.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
get_action(action: ActionResponse, hydrate: bool = False) -> ActionResponse
Process a action response before it is returned to the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action
|
ActionResponse
|
The action fetched from the database. |
required |
hydrate
|
bool
|
Whether to hydrate the action. |
False
|
Returns:
Type | Description |
---|---|
ActionResponse
|
The action. |
Source code in src/zenml/actions/base_action.py
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
|
run(config: ActionConfig, trigger_execution: TriggerExecutionResponse, auth_context: AuthContext) -> None
abstractmethod
Execute an action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
ActionConfig
|
The action configuration |
required |
trigger_execution
|
TriggerExecutionResponse
|
The trigger execution |
required |
auth_context
|
AuthContext
|
Authentication context with an API token that can be used by external workloads to authenticate with the server during the execution of the action. This API token is associated with the service account that was configured for the trigger that activated the action and has a validity defined by the trigger's authentication window. |
required |
Source code in src/zenml/actions/base_action.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
set_event_hub(event_hub: BaseEventHub) -> None
Configure an event hub for this event source plugin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_hub
|
BaseEventHub
|
Event hub to be used by this event handler to dispatch events. |
required |
Source code in src/zenml/actions/base_action.py
160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
update_action(action: ActionResponse, action_update: ActionUpdate) -> ActionResponse
Process action update and update the action in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action
|
ActionResponse
|
The action to update. |
required |
action_update
|
ActionUpdate
|
The update to be applied to the action. |
required |
Raises:
Type | Description |
---|---|
Exception
|
If the implementation specific processing before updating the action fails. |
Returns:
Type | Description |
---|---|
ActionResponse
|
The updated action. |
Source code in src/zenml/actions/base_action.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
validate_action_configuration(action_config: Dict[str, Any]) -> ActionConfig
Validate and return the action configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action_config
|
Dict[str, Any]
|
The action configuration to validate. |
required |
Returns:
Type | Description |
---|---|
ActionConfig
|
The validated action configuration. |
Raises:
Type | Description |
---|---|
ValueError
|
if the configuration is invalid. |
Source code in src/zenml/actions/base_action.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
|
Functions
pipeline_run
Modules
pipeline_run_action
Example file of what an action Plugin could look like.
PipelineRunActionConfiguration
PipelineRunActionFlavor
PipelineRunActionHandler(event_hub: Optional[BaseEventHub] = None)
Bases: BaseActionHandler
Action handler for running pipelines.
Source code in src/zenml/actions/base_action.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
config_class: Type[PipelineRunActionConfiguration]
property
Returns the BasePluginConfig
config.
Returns:
Type | Description |
---|---|
Type[PipelineRunActionConfiguration]
|
The configuration. |
flavor_class: Type[BaseActionFlavor]
property
Returns the flavor class of the plugin.
Returns:
Type | Description |
---|---|
Type[BaseActionFlavor]
|
The flavor class of the plugin. |
extract_resources(action_config: ActionConfig, hydrate: bool = False) -> Dict[ResourceType, BaseResponse[Any, Any, Any]]
Extract related resources for this action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
action_config
|
ActionConfig
|
Action configuration from which to extract related resources. |
required |
hydrate
|
bool
|
Flag deciding whether to hydrate the resources. |
False
|
Returns:
Type | Description |
---|---|
Dict[ResourceType, BaseResponse[Any, Any, Any]]
|
List of resources related to the action. |
Raises:
Type | Description |
---|---|
ValueError
|
In case the specified template does not exist. |
Source code in src/zenml/actions/pipeline_run/pipeline_run_action.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
run(config: ActionConfig, trigger_execution: TriggerExecutionResponse, auth_context: AuthContext) -> None
Execute an action.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
ActionConfig
|
The action configuration |
required |
trigger_execution
|
TriggerExecutionResponse
|
The trigger execution |
required |
auth_context
|
AuthContext
|
Authentication context with an API token that can be used by external workloads to authenticate with the server during the execution of the action. This API token is associated with the service account that was configured for the trigger that activated the action and has a validity defined by the trigger's authentication window. |
required |
Source code in src/zenml/actions/pipeline_run/pipeline_run_action.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|