zenml-nightly 0.58.2.dev20240624__py3-none-any.whl → 0.58.2.dev20240625__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/client.py +226 -55
- 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/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/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.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/METADATA +1 -1
- {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/RECORD +48 -44
- {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/LICENSE +0 -0
- {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/WHEEL +0 -0
- {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.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
|
|
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):
|
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:
|
zenml/config/docker_settings.py
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
from enum import Enum
|
17
17
|
from typing import Any, Dict, List, Optional, Union
|
18
18
|
|
19
|
-
from pydantic import Field, model_validator
|
19
|
+
from pydantic import BaseModel, Field, model_validator
|
20
20
|
from pydantic_settings import SettingsConfigDict
|
21
21
|
|
22
22
|
from zenml.config.base_settings import BaseSettings
|
@@ -65,6 +65,23 @@ class PythonPackageInstaller(Enum):
|
|
65
65
|
UV = "uv"
|
66
66
|
|
67
67
|
|
68
|
+
class DockerBuildConfig(BaseModel):
|
69
|
+
"""Configuration for a Docker build.
|
70
|
+
|
71
|
+
Attributes:
|
72
|
+
build_options: Additional options that will be passed unmodified to the
|
73
|
+
Docker build call when building an image. You can use this to for
|
74
|
+
example specify build args or a target stage. See
|
75
|
+
https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.build
|
76
|
+
for a full list of available options.
|
77
|
+
dockerignore: Path to a dockerignore file to use when building the
|
78
|
+
Docker image.
|
79
|
+
"""
|
80
|
+
|
81
|
+
build_options: Dict[str, Any] = {}
|
82
|
+
dockerignore: Optional[str] = None
|
83
|
+
|
84
|
+
|
68
85
|
class DockerSettings(BaseSettings):
|
69
86
|
"""Settings for building Docker images to run ZenML pipelines.
|
70
87
|
|
@@ -116,12 +133,9 @@ class DockerSettings(BaseSettings):
|
|
116
133
|
build_context_root: Build context root for the Docker build, only used
|
117
134
|
when the `dockerfile` attribute is set. If this is left empty, the
|
118
135
|
build context will only contain the Dockerfile.
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
args or a target stage. See
|
123
|
-
https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.build
|
124
|
-
for a full list of available options.
|
136
|
+
parent_image_build_config: Configuration for the parent image build.
|
137
|
+
build_options: DEPRECATED, use parent_image_build_config.build_options
|
138
|
+
instead.
|
125
139
|
skip_build: If set to `True`, the parent image will be used directly to
|
126
140
|
run the steps of your pipeline.
|
127
141
|
target_repository: Name of the Docker repository to which the
|
@@ -158,8 +172,8 @@ class DockerSettings(BaseSettings):
|
|
158
172
|
apt_packages: APT packages to install inside the Docker image.
|
159
173
|
environment: Dictionary of environment variables to set inside the
|
160
174
|
Docker image.
|
161
|
-
|
162
|
-
|
175
|
+
build_config: Configuration for the main image build.
|
176
|
+
dockerignore: DEPRECATED, use build_config.dockerignore instead.
|
163
177
|
copy_files: DEPRECATED, use the `source_files` attribute instead.
|
164
178
|
copy_global_config: DEPRECATED/UNUSED.
|
165
179
|
user: If not `None`, will set the user, make it owner of the `/app`
|
@@ -184,6 +198,7 @@ class DockerSettings(BaseSettings):
|
|
184
198
|
dockerfile: Optional[str] = None
|
185
199
|
build_context_root: Optional[str] = None
|
186
200
|
build_options: Dict[str, Any] = {}
|
201
|
+
parent_image_build_config: Optional[DockerBuildConfig] = None
|
187
202
|
skip_build: bool = False
|
188
203
|
target_repository: str = "zenml"
|
189
204
|
python_package_installer: PythonPackageInstaller = (
|
@@ -205,6 +220,7 @@ class DockerSettings(BaseSettings):
|
|
205
220
|
copy_files: bool = True
|
206
221
|
copy_global_config: bool = True
|
207
222
|
user: Optional[str] = None
|
223
|
+
build_config: Optional[DockerBuildConfig] = None
|
208
224
|
|
209
225
|
source_files: SourceFileMode = SourceFileMode.DOWNLOAD_OR_INCLUDE
|
210
226
|
|
zenml/constants.py
CHANGED
@@ -326,7 +326,7 @@ REQUIRES_CUSTOM_RESOURCE_REPORTING = ["pipeline", "pipeline_run"]
|
|
326
326
|
|
327
327
|
# API Endpoint paths:
|
328
328
|
ACTIVATE = "/activate"
|
329
|
-
ACTIONS = "/
|
329
|
+
ACTIONS = "/actions"
|
330
330
|
API = "/api"
|
331
331
|
API_KEYS = "/api_keys"
|
332
332
|
API_KEY_ROTATE = "/rotate"
|
@@ -121,7 +121,7 @@ class BaseEventHub(ABC):
|
|
121
121
|
trigger=trigger.id, event_metadata=event.model_dump()
|
122
122
|
)
|
123
123
|
|
124
|
-
action_config = trigger.
|
124
|
+
action_config = trigger.action.configuration
|
125
125
|
|
126
126
|
trigger_execution = self.zen_store.create_trigger_execution(request)
|
127
127
|
|
@@ -130,16 +130,16 @@ class BaseEventHub(ABC):
|
|
130
130
|
# is associated with the service account configured for the trigger
|
131
131
|
# and has a validity defined by the trigger's authentication window.
|
132
132
|
token = JWTToken(
|
133
|
-
user_id=trigger.service_account.id,
|
133
|
+
user_id=trigger.action.service_account.id,
|
134
134
|
)
|
135
135
|
expires: Optional[datetime] = None
|
136
|
-
if trigger.auth_window:
|
136
|
+
if trigger.action.auth_window:
|
137
137
|
expires = datetime.utcnow() + timedelta(
|
138
|
-
minutes=trigger.auth_window
|
138
|
+
minutes=trigger.action.auth_window
|
139
139
|
)
|
140
140
|
encoded_token = token.encode(expires=expires)
|
141
141
|
auth_context = AuthContext(
|
142
|
-
user=trigger.service_account,
|
142
|
+
user=trigger.action.service_account,
|
143
143
|
access_token=token,
|
144
144
|
encoded_access_token=encoded_token,
|
145
145
|
)
|