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
@@ -24,20 +24,21 @@ from zenml.actions.base_action import (
|
|
24
24
|
from zenml.config.global_config import GlobalConfiguration
|
25
25
|
from zenml.config.pipeline_run_configuration import PipelineRunConfiguration
|
26
26
|
from zenml.enums import PluginSubType
|
27
|
+
from zenml.logger import get_logger
|
27
28
|
from zenml.models import (
|
29
|
+
ActionRequest,
|
30
|
+
ActionResponse,
|
31
|
+
ActionUpdate,
|
28
32
|
TriggerExecutionResponse,
|
29
|
-
TriggerRequest,
|
30
|
-
TriggerResponse,
|
31
|
-
TriggerUpdate,
|
32
33
|
)
|
33
34
|
from zenml.models.v2.base.base import BaseResponse
|
34
35
|
from zenml.zen_server.auth import AuthContext
|
35
36
|
from zenml.zen_server.pipeline_deployment.utils import run_pipeline
|
36
|
-
from zenml.zen_server.rbac.models import
|
37
|
-
ResourceType,
|
38
|
-
)
|
37
|
+
from zenml.zen_server.rbac.models import ResourceType
|
39
38
|
from zenml.zen_server.utils import server_config
|
40
39
|
|
40
|
+
logger = get_logger(__name__)
|
41
|
+
|
41
42
|
# -------------------- Configuration Models ----------------------------------
|
42
43
|
|
43
44
|
|
@@ -95,7 +96,7 @@ class PipelineRunActionHandler(BaseActionHandler):
|
|
95
96
|
assert isinstance(config, PipelineRunActionConfiguration)
|
96
97
|
|
97
98
|
deployment = zen_store().get_deployment(config.pipeline_deployment_id)
|
98
|
-
|
99
|
+
logger.debug("Running deployment:", deployment)
|
99
100
|
run_pipeline(
|
100
101
|
deployment=deployment,
|
101
102
|
run_config=config.run_config,
|
@@ -121,13 +122,13 @@ class PipelineRunActionHandler(BaseActionHandler):
|
|
121
122
|
except KeyError:
|
122
123
|
raise ValueError(f"No deployment found with id {deployment_id}.")
|
123
124
|
|
124
|
-
def
|
125
|
-
self,
|
125
|
+
def _validate_action_request(
|
126
|
+
self, action: ActionRequest, config: ActionConfig
|
126
127
|
) -> None:
|
127
|
-
"""Validate
|
128
|
+
"""Validate an action request before it is created in the database.
|
128
129
|
|
129
130
|
Args:
|
130
|
-
|
131
|
+
action: Action request.
|
131
132
|
config: Action configuration instantiated from the request.
|
132
133
|
"""
|
133
134
|
assert isinstance(config, PipelineRunActionConfiguration)
|
@@ -135,25 +136,25 @@ class PipelineRunActionHandler(BaseActionHandler):
|
|
135
136
|
self._validate_configuration(config)
|
136
137
|
|
137
138
|
# If an expiration window is not set, we set it to the default value
|
138
|
-
if
|
139
|
-
|
139
|
+
if action.auth_window is None:
|
140
|
+
action.auth_window = server_config().pipeline_run_auth_window
|
140
141
|
|
141
|
-
def
|
142
|
+
def _validate_action_update(
|
142
143
|
self,
|
143
|
-
|
144
|
+
action: ActionResponse,
|
144
145
|
config: ActionConfig,
|
145
|
-
|
146
|
+
action_update: ActionUpdate,
|
146
147
|
config_update: ActionConfig,
|
147
148
|
) -> None:
|
148
|
-
"""Validate
|
149
|
+
"""Validate an action update before it is reflected in the database.
|
149
150
|
|
150
151
|
Args:
|
151
|
-
|
152
|
+
action: Original action before the update.
|
152
153
|
config: Action configuration instantiated from the original
|
153
|
-
|
154
|
-
|
154
|
+
action.
|
155
|
+
action_update: Action update request.
|
155
156
|
config_update: Action configuration instantiated from the
|
156
|
-
updated
|
157
|
+
updated action.
|
157
158
|
"""
|
158
159
|
assert isinstance(config, PipelineRunActionConfiguration)
|
159
160
|
|
@@ -162,12 +163,14 @@ class PipelineRunActionHandler(BaseActionHandler):
|
|
162
163
|
def extract_resources(
|
163
164
|
self,
|
164
165
|
action_config: ActionConfig,
|
166
|
+
hydrate: bool = False,
|
165
167
|
) -> Dict[ResourceType, BaseResponse[Any, Any, Any]]:
|
166
168
|
"""Extract related resources for this action.
|
167
169
|
|
168
170
|
Args:
|
169
171
|
action_config: Action configuration from which to extract related
|
170
172
|
resources.
|
173
|
+
hydrate: Flag deciding whether to hydrate the resources.
|
171
174
|
|
172
175
|
Returns:
|
173
176
|
List of resources related to the action.
|
@@ -181,7 +184,9 @@ class PipelineRunActionHandler(BaseActionHandler):
|
|
181
184
|
zen_store = GlobalConfiguration().zen_store
|
182
185
|
|
183
186
|
try:
|
184
|
-
deployment = zen_store.get_deployment(
|
187
|
+
deployment = zen_store.get_deployment(
|
188
|
+
deployment_id=deployment_id, hydrate=hydrate
|
189
|
+
)
|
185
190
|
except KeyError:
|
186
191
|
raise ValueError(f"No deployment found with id {deployment_id}.")
|
187
192
|
|
@@ -191,7 +196,7 @@ class PipelineRunActionHandler(BaseActionHandler):
|
|
191
196
|
|
192
197
|
if deployment.pipeline is not None:
|
193
198
|
pipeline = zen_store.get_pipeline(
|
194
|
-
pipeline_id=deployment.pipeline.id
|
199
|
+
pipeline_id=deployment.pipeline.id, hydrate=hydrate
|
195
200
|
)
|
196
201
|
resources[ResourceType.PIPELINE] = pipeline
|
197
202
|
|
@@ -14,6 +14,7 @@
|
|
14
14
|
"""The base interface to extend the ZenML artifact store."""
|
15
15
|
|
16
16
|
import inspect
|
17
|
+
import os
|
17
18
|
import textwrap
|
18
19
|
from abc import abstractmethod
|
19
20
|
from pathlib import Path
|
@@ -34,6 +35,7 @@ from typing import (
|
|
34
35
|
|
35
36
|
from pydantic import model_validator
|
36
37
|
|
38
|
+
from zenml.constants import ENV_ZENML_SERVER
|
37
39
|
from zenml.enums import StackComponentType
|
38
40
|
from zenml.exceptions import ArtifactStoreInterfaceError
|
39
41
|
from zenml.io import fileio
|
@@ -433,7 +435,11 @@ class BaseArtifactStore(StackComponent):
|
|
433
435
|
**kwargs: The keyword arguments to pass to the Pydantic object.
|
434
436
|
"""
|
435
437
|
super(BaseArtifactStore, self).__init__(*args, **kwargs)
|
436
|
-
|
438
|
+
|
439
|
+
# If running in a ZenML server environment, we don't register
|
440
|
+
# the filesystems. We always use the artifact stores directly.
|
441
|
+
if ENV_ZENML_SERVER not in os.environ:
|
442
|
+
self._register()
|
437
443
|
|
438
444
|
def _register(self) -> None:
|
439
445
|
"""Create and register a filesystem within the filesystem registry."""
|
zenml/artifacts/utils.py
CHANGED
@@ -436,18 +436,21 @@ def load_artifact_visualization(
|
|
436
436
|
artifact_store = _load_artifact_store(
|
437
437
|
artifact_store_id=artifact.artifact_store_id, zen_store=zen_store
|
438
438
|
)
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
439
|
+
try:
|
440
|
+
mode = "rb" if visualization.type == VisualizationType.IMAGE else "r"
|
441
|
+
value = _load_file_from_artifact_store(
|
442
|
+
uri=visualization.uri,
|
443
|
+
artifact_store=artifact_store,
|
444
|
+
mode=mode,
|
445
|
+
)
|
445
446
|
|
446
|
-
|
447
|
-
|
448
|
-
|
447
|
+
# Encode image visualizations if requested
|
448
|
+
if visualization.type == VisualizationType.IMAGE and encode_image:
|
449
|
+
value = base64.b64encode(bytes(value))
|
449
450
|
|
450
|
-
|
451
|
+
return LoadedVisualization(type=visualization.type, value=value)
|
452
|
+
finally:
|
453
|
+
artifact_store.cleanup()
|
451
454
|
|
452
455
|
|
453
456
|
def load_artifact_from_response(artifact: "ArtifactVersionResponse") -> Any:
|
zenml/cli/service_connectors.py
CHANGED
zenml/client.py
CHANGED
@@ -82,6 +82,10 @@ from zenml.exceptions import (
|
|
82
82
|
from zenml.io import fileio
|
83
83
|
from zenml.logger import get_logger
|
84
84
|
from zenml.models import (
|
85
|
+
ActionFilter,
|
86
|
+
ActionRequest,
|
87
|
+
ActionResponse,
|
88
|
+
ActionUpdate,
|
85
89
|
APIKeyFilter,
|
86
90
|
APIKeyRequest,
|
87
91
|
APIKeyResponse,
|
@@ -201,7 +205,7 @@ if TYPE_CHECKING:
|
|
201
205
|
logger = get_logger(__name__)
|
202
206
|
|
203
207
|
AnyResponse = TypeVar("AnyResponse", bound=BaseIdentifiedResponse) # type: ignore[type-arg]
|
204
|
-
|
208
|
+
F = TypeVar("F", bound=Callable[..., Any])
|
205
209
|
|
206
210
|
|
207
211
|
class ClientConfiguration(FileSyncModel):
|
@@ -307,11 +311,11 @@ class ClientMetaClass(ABCMeta):
|
|
307
311
|
return cls._global_client
|
308
312
|
|
309
313
|
|
310
|
-
def _fail_for_sql_zen_store(method:
|
311
|
-
"""Decorator for
|
314
|
+
def _fail_for_sql_zen_store(method: F) -> F:
|
315
|
+
"""Decorator for methods that are not allowed with a SQLZenStore.
|
312
316
|
|
313
317
|
Args:
|
314
|
-
method: The method
|
318
|
+
method: The method to decorate.
|
315
319
|
|
316
320
|
Returns:
|
317
321
|
The decorated method.
|
@@ -327,7 +331,7 @@ def _fail_for_sql_zen_store(method: Callable[..., T]) -> Callable[..., T]:
|
|
327
331
|
)
|
328
332
|
return method(self, *args, **kwargs)
|
329
333
|
|
330
|
-
return wrapper
|
334
|
+
return cast(F, wrapper)
|
331
335
|
|
332
336
|
|
333
337
|
@evaluate_all_lazy_load_args_in_client_methods
|
@@ -2754,18 +2758,18 @@ class Client(metaclass=ClientMetaClass):
|
|
2754
2758
|
self,
|
2755
2759
|
name: str,
|
2756
2760
|
configuration: Dict[str, Any],
|
2757
|
-
description: str,
|
2758
2761
|
flavor: str,
|
2759
2762
|
event_source_subtype: PluginSubType,
|
2763
|
+
description: str = "",
|
2760
2764
|
) -> EventSourceResponse:
|
2761
|
-
"""Registers
|
2765
|
+
"""Registers an event source.
|
2762
2766
|
|
2763
2767
|
Args:
|
2764
|
-
name: The name of the
|
2765
|
-
configuration: Configuration for this event source
|
2766
|
-
|
2767
|
-
|
2768
|
-
|
2768
|
+
name: The name of the event source to create.
|
2769
|
+
configuration: Configuration for this event source.
|
2770
|
+
flavor: The flavor of event source.
|
2771
|
+
event_source_subtype: The event source subtype.
|
2772
|
+
description: The description of the event source.
|
2769
2773
|
|
2770
2774
|
Returns:
|
2771
2775
|
The model of the registered event source.
|
@@ -2935,52 +2939,218 @@ class Client(metaclass=ClientMetaClass):
|
|
2935
2939
|
self.zen_store.delete_event_source(event_source_id=event_source.id)
|
2936
2940
|
logger.info("Deleted event_source with name '%s'.", event_source.name)
|
2937
2941
|
|
2942
|
+
# --------------------------------- Actions -------------------------
|
2943
|
+
|
2944
|
+
@_fail_for_sql_zen_store
|
2945
|
+
def create_action(
|
2946
|
+
self,
|
2947
|
+
name: str,
|
2948
|
+
flavor: str,
|
2949
|
+
action_type: PluginSubType,
|
2950
|
+
configuration: Dict[str, Any],
|
2951
|
+
service_account_id: UUID,
|
2952
|
+
auth_window: Optional[int] = None,
|
2953
|
+
description: str = "",
|
2954
|
+
) -> ActionResponse:
|
2955
|
+
"""Create an action.
|
2956
|
+
|
2957
|
+
Args:
|
2958
|
+
name: The name of the action.
|
2959
|
+
flavor: The flavor of the action,
|
2960
|
+
action_type: The action subtype.
|
2961
|
+
configuration: The action configuration.
|
2962
|
+
service_account_id: The service account that is used to execute the
|
2963
|
+
action.
|
2964
|
+
auth_window: The time window in minutes for which the service
|
2965
|
+
account is authorized to execute the action. Set this to 0 to
|
2966
|
+
authorize the service account indefinitely (not recommended).
|
2967
|
+
description: The description of the action.
|
2968
|
+
|
2969
|
+
Returns:
|
2970
|
+
The created action
|
2971
|
+
"""
|
2972
|
+
action = ActionRequest(
|
2973
|
+
name=name,
|
2974
|
+
description=description,
|
2975
|
+
flavor=flavor,
|
2976
|
+
plugin_subtype=action_type,
|
2977
|
+
configuration=configuration,
|
2978
|
+
service_account_id=service_account_id,
|
2979
|
+
auth_window=auth_window,
|
2980
|
+
user=self.active_user.id,
|
2981
|
+
workspace=self.active_workspace.id,
|
2982
|
+
)
|
2983
|
+
|
2984
|
+
return self.zen_store.create_action(action=action)
|
2985
|
+
|
2986
|
+
@_fail_for_sql_zen_store
|
2987
|
+
def get_action(
|
2988
|
+
self,
|
2989
|
+
name_id_or_prefix: Union[UUID, str],
|
2990
|
+
allow_name_prefix_match: bool = True,
|
2991
|
+
hydrate: bool = True,
|
2992
|
+
) -> ActionResponse:
|
2993
|
+
"""Get an action by name, ID or prefix.
|
2994
|
+
|
2995
|
+
Args:
|
2996
|
+
name_id_or_prefix: The name, ID or prefix of the action.
|
2997
|
+
allow_name_prefix_match: If True, allow matching by name prefix.
|
2998
|
+
hydrate: Flag deciding whether to hydrate the output model(s)
|
2999
|
+
by including metadata fields in the response.
|
3000
|
+
|
3001
|
+
Returns:
|
3002
|
+
The action.
|
3003
|
+
"""
|
3004
|
+
return self._get_entity_by_id_or_name_or_prefix(
|
3005
|
+
get_method=self.zen_store.get_action,
|
3006
|
+
list_method=self.list_actions,
|
3007
|
+
name_id_or_prefix=name_id_or_prefix,
|
3008
|
+
allow_name_prefix_match=allow_name_prefix_match,
|
3009
|
+
hydrate=hydrate,
|
3010
|
+
)
|
3011
|
+
|
3012
|
+
@_fail_for_sql_zen_store
|
3013
|
+
def list_actions(
|
3014
|
+
self,
|
3015
|
+
sort_by: str = "created",
|
3016
|
+
page: int = PAGINATION_STARTING_PAGE,
|
3017
|
+
size: int = PAGE_SIZE_DEFAULT,
|
3018
|
+
logical_operator: LogicalOperators = LogicalOperators.AND,
|
3019
|
+
id: Optional[Union[UUID, str]] = None,
|
3020
|
+
created: Optional[datetime] = None,
|
3021
|
+
updated: Optional[datetime] = None,
|
3022
|
+
name: Optional[str] = None,
|
3023
|
+
flavor: Optional[str] = None,
|
3024
|
+
action_type: Optional[str] = None,
|
3025
|
+
workspace_id: Optional[Union[str, UUID]] = None,
|
3026
|
+
user_id: Optional[Union[str, UUID]] = None,
|
3027
|
+
hydrate: bool = False,
|
3028
|
+
) -> Page[ActionResponse]:
|
3029
|
+
"""List actions.
|
3030
|
+
|
3031
|
+
Args:
|
3032
|
+
sort_by: The column to sort by
|
3033
|
+
page: The page of items
|
3034
|
+
size: The maximum size of all pages
|
3035
|
+
logical_operator: Which logical operator to use [and, or]
|
3036
|
+
id: Use the id of the action to filter by.
|
3037
|
+
created: Use to filter by time of creation
|
3038
|
+
updated: Use the last updated date for filtering
|
3039
|
+
workspace_id: The id of the workspace to filter by.
|
3040
|
+
user_id: The id of the user to filter by.
|
3041
|
+
name: The name of the action to filter by.
|
3042
|
+
flavor: The flavor of the action to filter by.
|
3043
|
+
action_type: The type of the action to filter by.
|
3044
|
+
hydrate: Flag deciding whether to hydrate the output model(s)
|
3045
|
+
by including metadata fields in the response.
|
3046
|
+
|
3047
|
+
Returns:
|
3048
|
+
A page of actions.
|
3049
|
+
"""
|
3050
|
+
filter_model = ActionFilter(
|
3051
|
+
page=page,
|
3052
|
+
size=size,
|
3053
|
+
sort_by=sort_by,
|
3054
|
+
logical_operator=logical_operator,
|
3055
|
+
workspace_id=workspace_id,
|
3056
|
+
user_id=user_id,
|
3057
|
+
name=name,
|
3058
|
+
id=id,
|
3059
|
+
flavor=flavor,
|
3060
|
+
plugin_subtype=action_type,
|
3061
|
+
created=created,
|
3062
|
+
updated=updated,
|
3063
|
+
)
|
3064
|
+
filter_model.set_scope_workspace(self.active_workspace.id)
|
3065
|
+
return self.zen_store.list_actions(filter_model, hydrate=hydrate)
|
3066
|
+
|
3067
|
+
@_fail_for_sql_zen_store
|
3068
|
+
def update_action(
|
3069
|
+
self,
|
3070
|
+
name_id_or_prefix: Union[UUID, str],
|
3071
|
+
name: Optional[str] = None,
|
3072
|
+
description: Optional[str] = None,
|
3073
|
+
configuration: Optional[Dict[str, Any]] = None,
|
3074
|
+
service_account_id: Optional[UUID] = None,
|
3075
|
+
auth_window: Optional[int] = None,
|
3076
|
+
) -> ActionResponse:
|
3077
|
+
"""Update an action.
|
3078
|
+
|
3079
|
+
Args:
|
3080
|
+
name_id_or_prefix: The name, id or prefix of the action to update.
|
3081
|
+
name: The new name of the action.
|
3082
|
+
description: The new description of the action.
|
3083
|
+
configuration: The new configuration of the action.
|
3084
|
+
service_account_id: The new service account that is used to execute
|
3085
|
+
the action.
|
3086
|
+
auth_window: The new time window in minutes for which the service
|
3087
|
+
account is authorized to execute the action. Set this to 0 to
|
3088
|
+
authorize the service account indefinitely (not recommended).
|
3089
|
+
|
3090
|
+
Returns:
|
3091
|
+
The updated action.
|
3092
|
+
"""
|
3093
|
+
action = self.get_action(
|
3094
|
+
name_id_or_prefix=name_id_or_prefix, allow_name_prefix_match=False
|
3095
|
+
)
|
3096
|
+
|
3097
|
+
update_model = ActionUpdate(
|
3098
|
+
name=name,
|
3099
|
+
description=description,
|
3100
|
+
configuration=configuration,
|
3101
|
+
service_account_id=service_account_id,
|
3102
|
+
auth_window=auth_window,
|
3103
|
+
)
|
3104
|
+
|
3105
|
+
return self.zen_store.update_action(
|
3106
|
+
action_id=action.id,
|
3107
|
+
action_update=update_model,
|
3108
|
+
)
|
3109
|
+
|
3110
|
+
@_fail_for_sql_zen_store
|
3111
|
+
def delete_action(self, name_id_or_prefix: Union[str, UUID]) -> None:
|
3112
|
+
"""Delete an action.
|
3113
|
+
|
3114
|
+
Args:
|
3115
|
+
name_id_or_prefix: The name, id or prefix id of the action
|
3116
|
+
to delete.
|
3117
|
+
"""
|
3118
|
+
action = self.get_action(
|
3119
|
+
name_id_or_prefix=name_id_or_prefix, allow_name_prefix_match=False
|
3120
|
+
)
|
3121
|
+
|
3122
|
+
self.zen_store.delete_action(action_id=action.id)
|
3123
|
+
logger.info("Deleted action with name '%s'.", action.name)
|
3124
|
+
|
2938
3125
|
# --------------------------------- Triggers -------------------------
|
2939
3126
|
|
2940
3127
|
@_fail_for_sql_zen_store
|
2941
3128
|
def create_trigger(
|
2942
3129
|
self,
|
2943
3130
|
name: str,
|
2944
|
-
description: str,
|
2945
3131
|
event_source_id: UUID,
|
2946
3132
|
event_filter: Dict[str, Any],
|
2947
|
-
|
2948
|
-
|
2949
|
-
action_subtype: PluginSubType,
|
2950
|
-
service_account: Union[str, UUID],
|
2951
|
-
auth_window: Optional[int] = None,
|
3133
|
+
action_id: UUID,
|
3134
|
+
description: str = "",
|
2952
3135
|
) -> TriggerResponse:
|
2953
3136
|
"""Registers a trigger.
|
2954
3137
|
|
2955
3138
|
Args:
|
2956
3139
|
name: The name of the trigger to create.
|
2957
|
-
description: The description of the trigger
|
2958
3140
|
event_source_id: The id of the event source id
|
2959
3141
|
event_filter: The event filter
|
2960
|
-
|
2961
|
-
|
2962
|
-
action_subtype: The action subtype
|
2963
|
-
service_account: The service account
|
2964
|
-
auth_window: The auth window
|
3142
|
+
action_id: The ID of the action that should be triggered.
|
3143
|
+
description: The description of the trigger
|
2965
3144
|
|
2966
3145
|
Returns:
|
2967
|
-
The
|
3146
|
+
The created trigger.
|
2968
3147
|
"""
|
2969
|
-
# Fetch the service account
|
2970
|
-
service_account_model = self.get_service_account(
|
2971
|
-
name_id_or_prefix=service_account, allow_name_prefix_match=False
|
2972
|
-
)
|
2973
|
-
|
2974
3148
|
trigger = TriggerRequest(
|
2975
3149
|
name=name,
|
2976
3150
|
description=description,
|
2977
3151
|
event_source_id=event_source_id,
|
2978
3152
|
event_filter=event_filter,
|
2979
|
-
|
2980
|
-
action_flavor=action_flavor,
|
2981
|
-
action_subtype=action_subtype,
|
2982
|
-
service_account_id=service_account_model.id,
|
2983
|
-
auth_window=auth_window,
|
3153
|
+
action_id=action_id,
|
2984
3154
|
user=self.active_user.id,
|
2985
3155
|
workspace=self.active_workspace.id,
|
2986
3156
|
)
|
@@ -2994,10 +3164,10 @@ class Client(metaclass=ClientMetaClass):
|
|
2994
3164
|
allow_name_prefix_match: bool = True,
|
2995
3165
|
hydrate: bool = True,
|
2996
3166
|
) -> TriggerResponse:
|
2997
|
-
"""Get a
|
3167
|
+
"""Get a trigger by name, ID or prefix.
|
2998
3168
|
|
2999
3169
|
Args:
|
3000
|
-
name_id_or_prefix: The name, ID or prefix of the
|
3170
|
+
name_id_or_prefix: The name, ID or prefix of the trigger.
|
3001
3171
|
allow_name_prefix_match: If True, allow matching by name prefix.
|
3002
3172
|
hydrate: Flag deciding whether to hydrate the output model(s)
|
3003
3173
|
by including metadata fields in the response.
|
@@ -3025,6 +3195,11 @@ class Client(metaclass=ClientMetaClass):
|
|
3025
3195
|
updated: Optional[datetime] = None,
|
3026
3196
|
name: Optional[str] = None,
|
3027
3197
|
event_source_id: Optional[UUID] = None,
|
3198
|
+
action_id: Optional[UUID] = None,
|
3199
|
+
event_source_flavor: Optional[str] = None,
|
3200
|
+
event_source_subtype: Optional[str] = None,
|
3201
|
+
action_flavor: Optional[str] = None,
|
3202
|
+
action_subtype: Optional[str] = None,
|
3028
3203
|
workspace_id: Optional[Union[str, UUID]] = None,
|
3029
3204
|
user_id: Optional[Union[str, UUID]] = None,
|
3030
3205
|
hydrate: bool = False,
|
@@ -3042,7 +3217,14 @@ class Client(metaclass=ClientMetaClass):
|
|
3042
3217
|
workspace_id: The id of the workspace to filter by.
|
3043
3218
|
user_id: The id of the user to filter by.
|
3044
3219
|
name: The name of the trigger to filter by.
|
3045
|
-
event_source_id: The event source associated with the
|
3220
|
+
event_source_id: The event source associated with the trigger.
|
3221
|
+
action_id: The action associated with the trigger.
|
3222
|
+
event_source_flavor: Flavor of the event source associated with the
|
3223
|
+
trigger.
|
3224
|
+
event_source_subtype: Type of the event source associated with the
|
3225
|
+
trigger.
|
3226
|
+
action_flavor: Flavor of the action associated with the trigger.
|
3227
|
+
action_subtype: Type of the action associated with the trigger.
|
3046
3228
|
hydrate: Flag deciding whether to hydrate the output model(s)
|
3047
3229
|
by including metadata fields in the response.
|
3048
3230
|
|
@@ -3058,6 +3240,11 @@ class Client(metaclass=ClientMetaClass):
|
|
3058
3240
|
user_id=user_id,
|
3059
3241
|
name=name,
|
3060
3242
|
event_source_id=event_source_id,
|
3243
|
+
action_id=action_id,
|
3244
|
+
event_source_flavor=event_source_flavor,
|
3245
|
+
event_source_subtype=event_source_subtype,
|
3246
|
+
action_flavor=action_flavor,
|
3247
|
+
action_subtype=action_subtype,
|
3061
3248
|
id=id,
|
3062
3249
|
created=created,
|
3063
3250
|
updated=updated,
|
@@ -3074,10 +3261,7 @@ class Client(metaclass=ClientMetaClass):
|
|
3074
3261
|
name: Optional[str] = None,
|
3075
3262
|
description: Optional[str] = None,
|
3076
3263
|
event_filter: Optional[Dict[str, Any]] = None,
|
3077
|
-
action: Optional[Dict[str, Any]] = None,
|
3078
3264
|
is_active: Optional[bool] = None,
|
3079
|
-
service_account: Optional[Union[str, UUID]] = None,
|
3080
|
-
auth_window: Optional[int] = None,
|
3081
3265
|
) -> TriggerResponse:
|
3082
3266
|
"""Updates a trigger.
|
3083
3267
|
|
@@ -3086,11 +3270,7 @@ class Client(metaclass=ClientMetaClass):
|
|
3086
3270
|
name: the new name of the trigger.
|
3087
3271
|
description: the new description of the trigger.
|
3088
3272
|
event_filter: The event filter configuration.
|
3089
|
-
|
3090
|
-
is_active: Optional[bool] = Allows for activation/deactivating the
|
3091
|
-
event source
|
3092
|
-
service_account: The service account
|
3093
|
-
auth_window: The auth window
|
3273
|
+
is_active: Whether the trigger is active or not.
|
3094
3274
|
|
3095
3275
|
Returns:
|
3096
3276
|
The model of the updated trigger.
|
@@ -3108,17 +3288,8 @@ class Client(metaclass=ClientMetaClass):
|
|
3108
3288
|
name=name,
|
3109
3289
|
description=description,
|
3110
3290
|
event_filter=event_filter,
|
3111
|
-
action=action,
|
3112
3291
|
is_active=is_active,
|
3113
|
-
auth_window=auth_window,
|
3114
3292
|
)
|
3115
|
-
if service_account:
|
3116
|
-
# Fetch the service account
|
3117
|
-
service_account_model = self.get_service_account(
|
3118
|
-
name_id_or_prefix=service_account,
|
3119
|
-
allow_name_prefix_match=False,
|
3120
|
-
)
|
3121
|
-
update_model.service_account_id = service_account_model.id
|
3122
3293
|
|
3123
3294
|
if name:
|
3124
3295
|
if self.list_triggers(name=name):
|
@@ -5495,6 +5666,7 @@ class Client(metaclass=ClientMetaClass):
|
|
5495
5666
|
name_id_or_prefix=name_id_or_prefix,
|
5496
5667
|
resource_type=resource_type,
|
5497
5668
|
resource_id=resource_id,
|
5669
|
+
verify=False,
|
5498
5670
|
)
|
5499
5671
|
|
5500
5672
|
connector_client.configure_local_client(
|
@@ -5508,6 +5680,7 @@ class Client(metaclass=ClientMetaClass):
|
|
5508
5680
|
name_id_or_prefix: Union[UUID, str],
|
5509
5681
|
resource_type: Optional[str] = None,
|
5510
5682
|
resource_id: Optional[str] = None,
|
5683
|
+
verify: bool = False,
|
5511
5684
|
) -> "ServiceConnector":
|
5512
5685
|
"""Get the client side of a service connector instance to use with a local client.
|
5513
5686
|
|
@@ -5523,6 +5696,8 @@ class Client(metaclass=ClientMetaClass):
|
|
5523
5696
|
equivalent to the one requested, a `ValueError` exception is
|
5524
5697
|
raised. May be omitted for connectors and resource types that do
|
5525
5698
|
not support multiple resource instances.
|
5699
|
+
verify: Whether to verify that the service connector configuration
|
5700
|
+
and credentials can be used to gain access to the resource.
|
5526
5701
|
|
5527
5702
|
Returns:
|
5528
5703
|
The client side of the indicated service connector instance that can
|
@@ -5560,9 +5735,10 @@ class Client(metaclass=ClientMetaClass):
|
|
5560
5735
|
)
|
5561
5736
|
)
|
5562
5737
|
|
5563
|
-
|
5564
|
-
|
5565
|
-
|
5738
|
+
if verify:
|
5739
|
+
# Verify the connector client on the local machine, because the
|
5740
|
+
# server-side implementation may not be able to do so
|
5741
|
+
connector_client.verify()
|
5566
5742
|
else:
|
5567
5743
|
connector_instance = (
|
5568
5744
|
service_connector_registry.instantiate_connector(
|
zenml/config/compiler.py
CHANGED
@@ -192,10 +192,6 @@ class Compiler:
|
|
192
192
|
Args:
|
193
193
|
pipeline: The pipeline to configure.
|
194
194
|
config: The run configurations.
|
195
|
-
|
196
|
-
Raises:
|
197
|
-
KeyError: If the run configuration contains options for a
|
198
|
-
non-existent step.
|
199
195
|
"""
|
200
196
|
with pipeline.__suppress_configure_warnings__():
|
201
197
|
pipeline.configure(
|
@@ -209,11 +205,16 @@ class Compiler:
|
|
209
205
|
parameters=config.parameters,
|
210
206
|
)
|
211
207
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
208
|
+
invalid_step_configs = set(config.steps) - set(pipeline.invocations)
|
209
|
+
if invalid_step_configs:
|
210
|
+
logger.warning(
|
211
|
+
f"Configuration for step invocations {invalid_step_configs} "
|
212
|
+
"cannot be applied to any pipeline step invocations, "
|
213
|
+
"ignoring..."
|
214
|
+
)
|
215
|
+
|
216
|
+
for key in invalid_step_configs:
|
217
|
+
config.steps.pop(key)
|
217
218
|
|
218
219
|
# Override `enable_cache` of all steps if set at run level
|
219
220
|
if config.enable_cache is not None:
|