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.
Files changed (48) hide show
  1. zenml/VERSION +1 -1
  2. zenml/actions/base_action.py +177 -174
  3. zenml/actions/pipeline_run/pipeline_run_action.py +28 -23
  4. zenml/client.py +226 -55
  5. zenml/config/compiler.py +10 -9
  6. zenml/config/docker_settings.py +25 -9
  7. zenml/constants.py +1 -1
  8. zenml/event_hub/base_event_hub.py +5 -5
  9. zenml/event_hub/event_hub.py +15 -6
  10. zenml/event_sources/base_event.py +0 -11
  11. zenml/event_sources/base_event_source.py +7 -0
  12. zenml/event_sources/webhooks/base_webhook_event_source.py +1 -4
  13. zenml/exceptions.py +4 -0
  14. zenml/hooks/hook_validators.py +2 -3
  15. zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py +3 -3
  16. zenml/integrations/mlflow/__init__.py +1 -1
  17. zenml/models/__init__.py +17 -0
  18. zenml/models/v2/core/action.py +276 -0
  19. zenml/models/v2/core/trigger.py +182 -141
  20. zenml/new/pipelines/pipeline.py +13 -3
  21. zenml/new/pipelines/pipeline_decorator.py +1 -2
  22. zenml/new/pipelines/run_utils.py +1 -12
  23. zenml/new/steps/step_decorator.py +2 -3
  24. zenml/pipelines/base_pipeline.py +0 -2
  25. zenml/pipelines/pipeline_decorator.py +1 -2
  26. zenml/steps/base_step.py +1 -2
  27. zenml/steps/step_decorator.py +1 -2
  28. zenml/types.py +10 -1
  29. zenml/utils/pipeline_docker_image_builder.py +20 -5
  30. zenml/zen_server/rbac/models.py +1 -0
  31. zenml/zen_server/rbac/utils.py +22 -1
  32. zenml/zen_server/routers/actions_endpoints.py +324 -0
  33. zenml/zen_server/routers/triggers_endpoints.py +30 -158
  34. zenml/zen_server/zen_server_api.py +2 -0
  35. zenml/zen_stores/migrations/versions/25155145c545_separate_actions_and_triggers.py +228 -0
  36. zenml/zen_stores/rest_zen_store.py +103 -4
  37. zenml/zen_stores/schemas/__init__.py +2 -0
  38. zenml/zen_stores/schemas/action_schemas.py +192 -0
  39. zenml/zen_stores/schemas/trigger_schemas.py +43 -50
  40. zenml/zen_stores/schemas/user_schemas.py +10 -2
  41. zenml/zen_stores/schemas/workspace_schemas.py +5 -0
  42. zenml/zen_stores/sql_zen_store.py +240 -30
  43. zenml/zen_stores/zen_store_interface.py +85 -0
  44. {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/METADATA +1 -1
  45. {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/RECORD +48 -44
  46. {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/LICENSE +0 -0
  47. {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/WHEEL +0 -0
  48. {zenml_nightly-0.58.2.dev20240624.dist-info → zenml_nightly-0.58.2.dev20240625.dist-info}/entry_points.txt +0 -0
@@ -13,15 +13,14 @@
13
13
  # permissions and limitations under the License.
14
14
  """Collection of all models concerning triggers."""
15
15
 
16
- import copy
17
- from typing import TYPE_CHECKING, Any, Dict, Optional, Union
16
+ from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union
18
17
  from uuid import UUID
19
18
 
20
- from pydantic import BaseModel, Field
19
+ from pydantic import Field, model_validator
21
20
 
21
+ from zenml.config.schedule import Schedule
22
22
  from zenml.constants import STR_FIELD_MAX_LENGTH
23
- from zenml.enums import PluginSubType
24
- from zenml.models.v2.base.base import BaseZenModel
23
+ from zenml.models.v2.base.base import BaseUpdate
25
24
  from zenml.models.v2.base.page import Page
26
25
  from zenml.models.v2.base.scoped import (
27
26
  WorkspaceScopedFilter,
@@ -32,138 +31,129 @@ from zenml.models.v2.base.scoped import (
32
31
  WorkspaceScopedResponseResources,
33
32
  )
34
33
  from zenml.models.v2.core.trigger_execution import TriggerExecutionResponse
35
- from zenml.models.v2.core.user import UserResponse
36
34
 
37
35
  if TYPE_CHECKING:
36
+ from sqlalchemy.sql.elements import ColumnElement
37
+
38
+ from zenml.models.v2.core.action import (
39
+ ActionResponse,
40
+ )
38
41
  from zenml.models.v2.core.event_source import EventSourceResponse
39
42
 
40
- # ------------------ Base Model ------------------
43
+
44
+ # ------------------ Request Model ------------------
41
45
 
42
46
 
43
- class TriggerBase(BaseModel):
44
- """Base model for triggers."""
47
+ class TriggerRequest(WorkspaceScopedRequest):
48
+ """Model for creating a new trigger."""
45
49
 
46
50
  name: str = Field(
47
- title="The name of the Trigger.", max_length=STR_FIELD_MAX_LENGTH
51
+ title="The name of the trigger.", max_length=STR_FIELD_MAX_LENGTH
48
52
  )
49
53
  description: str = Field(
50
54
  default="",
51
55
  title="The description of the trigger",
52
56
  max_length=STR_FIELD_MAX_LENGTH,
53
57
  )
54
- event_source_id: UUID = Field(
55
- title="The event source that activates this trigger.",
56
- )
57
- event_filter: Dict[str, Any] = Field(
58
- title="Filter applied to events that activate this trigger.",
59
- )
60
-
61
- action: Dict[str, Any] = Field(
62
- title="The configuration for the action that is executed by this "
63
- "trigger.",
64
- )
65
- action_flavor: str = Field(
66
- title="The flavor of the action that is executed by this trigger.",
67
- max_length=STR_FIELD_MAX_LENGTH,
58
+ action_id: UUID = Field(
59
+ title="The action that is executed by this trigger.",
68
60
  )
69
- action_subtype: PluginSubType = Field(
70
- title="The subtype of the action that is executed by this trigger.",
61
+ schedule: Optional[Schedule] = Field(
62
+ default=None,
63
+ title="The schedule for the trigger. Either a schedule or an event "
64
+ "source is required.",
71
65
  )
72
- service_account_id: UUID = Field(
73
- title="The service account that is used to execute the action.",
66
+ event_source_id: Optional[UUID] = Field(
67
+ default=None,
68
+ title="The event source that activates this trigger. Either a schedule "
69
+ "or an event source is required.",
74
70
  )
75
- auth_window: Optional[int] = Field(
71
+ event_filter: Optional[Dict[str, Any]] = Field(
76
72
  default=None,
77
- title="The time window in minutes for which the service account is "
78
- "authorized to execute the action. Set this to 0 to authorize the "
79
- "service account indefinitely (not recommended). If not set, a "
80
- "default value defined for each individual action type is used.",
73
+ title="Filter applied to events that activate this trigger. Only "
74
+ "set if the trigger is activated by an event source.",
81
75
  )
82
76
 
77
+ @model_validator(mode="after")
78
+ def _validate_schedule_or_event_source(self) -> "TriggerRequest":
79
+ """Validate that either a schedule or an event source is provided.
83
80
 
84
- # ------------------ Request Model ------------------
85
- class TriggerRequest(TriggerBase, WorkspaceScopedRequest):
86
- """Model for creating a new Trigger."""
81
+ Returns:
82
+ The validated request.
83
+
84
+ Raises:
85
+ ValueError: If neither a schedule nor an event source is provided,
86
+ or if both are provided.
87
+ """
88
+ if not self.schedule and not self.event_source_id:
89
+ raise ValueError(
90
+ "Either a schedule or an event source is required."
91
+ )
92
+
93
+ if self.schedule and self.event_source_id:
94
+ raise ValueError("Only a schedule or an event source is allowed.")
95
+
96
+ return self
87
97
 
88
98
 
89
99
  # ------------------ Update Model ------------------
90
100
 
91
101
 
92
- class TriggerUpdate(BaseZenModel):
102
+ class TriggerUpdate(BaseUpdate):
93
103
  """Update model for triggers."""
94
104
 
95
105
  name: Optional[str] = Field(
96
106
  default=None,
97
- title="The new name for the Trigger.",
107
+ title="The new name for the trigger.",
98
108
  max_length=STR_FIELD_MAX_LENGTH,
99
109
  )
100
110
  description: Optional[str] = Field(
101
111
  default=None,
102
- title="The new description for the trigger",
112
+ title="The new description for the trigger.",
103
113
  max_length=STR_FIELD_MAX_LENGTH,
104
114
  )
105
115
  event_filter: Optional[Dict[str, Any]] = Field(
106
116
  default=None,
107
- title="New filter applied to events that activate this trigger.",
117
+ title="New filter applied to events that activate this trigger. Only "
118
+ "valid if the trigger is already configured to be activated by an "
119
+ "event source.",
108
120
  )
109
- action: Optional[Dict[str, Any]] = Field(
121
+ schedule: Optional[Schedule] = Field(
110
122
  default=None,
111
- title="The new configuration for the action that is executed by this "
112
- "trigger.",
123
+ title="The updated schedule for the trigger. Only valid if the trigger "
124
+ "is already configured to be activated by a schedule.",
113
125
  )
114
126
  is_active: Optional[bool] = Field(
115
127
  default=None,
116
128
  title="The new status of the trigger.",
117
129
  )
118
- service_account_id: Optional[UUID] = Field(
119
- default=None,
120
- title="The service account that is used to execute the action.",
121
- )
122
- auth_window: Optional[int] = Field(
123
- default=None,
124
- title="The time window in minutes for which the service account is "
125
- "authorized to execute the action. Set this to 0 to authorize the "
126
- "service account indefinitely (not recommended). If not set, a "
127
- "default value defined for each individual action type is used.",
128
- )
129
-
130
- @classmethod
131
- def from_response(cls, response: "TriggerResponse") -> "TriggerUpdate":
132
- """Create an update model from a response model.
133
-
134
- Args:
135
- response: The response model to create the update model from.
136
-
137
- Returns:
138
- The update model.
139
- """
140
- return TriggerUpdate(
141
- name=response.name,
142
- description=response.description,
143
- action=copy.deepcopy(response.action),
144
- event_filter=copy.deepcopy(response.event_filter),
145
- is_active=response.is_active,
146
- service_account_id=response.get_resources().service_account.id,
147
- )
148
130
 
149
131
 
150
132
  # ------------------ Response Model ------------------
151
133
 
152
134
 
153
135
  class TriggerResponseBody(WorkspaceScopedResponseBody):
154
- """ResponseBody for triggers."""
136
+ """Response body for triggers."""
155
137
 
156
- event_source_flavor: str = Field(
157
- title="The flavor of the event source that activates this trigger.",
158
- max_length=STR_FIELD_MAX_LENGTH,
159
- )
160
138
  action_flavor: str = Field(
161
139
  title="The flavor of the action that is executed by this trigger.",
162
140
  max_length=STR_FIELD_MAX_LENGTH,
163
141
  )
164
- action_subtype: PluginSubType = Field(
142
+ action_subtype: str = Field(
165
143
  title="The subtype of the action that is executed by this trigger.",
166
144
  )
145
+ event_source_flavor: Optional[str] = Field(
146
+ default=None,
147
+ title="The flavor of the event source that activates this trigger. Not "
148
+ "set if the trigger is activated by a schedule.",
149
+ max_length=STR_FIELD_MAX_LENGTH,
150
+ )
151
+ event_source_subtype: Optional[str] = Field(
152
+ default=None,
153
+ title="The subtype of the event source that activates this trigger. "
154
+ "Not set if the trigger is activated by a schedule.",
155
+ max_length=STR_FIELD_MAX_LENGTH,
156
+ )
167
157
  is_active: bool = Field(
168
158
  title="Whether the trigger is active.",
169
159
  )
@@ -172,33 +162,33 @@ class TriggerResponseBody(WorkspaceScopedResponseBody):
172
162
  class TriggerResponseMetadata(WorkspaceScopedResponseMetadata):
173
163
  """Response metadata for triggers."""
174
164
 
175
- event_filter: Dict[str, Any] = Field(
176
- title="The event that activates this trigger.",
177
- )
178
- action: Dict[str, Any] = Field(
179
- title="The action that is executed by this trigger.",
180
- )
181
165
  description: str = Field(
182
166
  default="",
183
- title="The description of the trigger",
167
+ title="The description of the trigger.",
184
168
  max_length=STR_FIELD_MAX_LENGTH,
185
169
  )
186
- auth_window: int = Field(
187
- title="The time window in minutes for which the service account is "
188
- "authorized to execute the action. Set this to 0 to authorize the "
189
- "service account indefinitely (not recommended). If not set, a "
190
- "default value defined for each individual action type is used.",
170
+ event_filter: Optional[Dict[str, Any]] = Field(
171
+ default=None,
172
+ title="The event that activates this trigger. Not set if the trigger "
173
+ "is activated by a schedule.",
174
+ )
175
+ schedule: Optional[Schedule] = Field(
176
+ default=None,
177
+ title="The schedule that activates this trigger. Not set if the "
178
+ "trigger is activated by an event source.",
191
179
  )
192
180
 
193
181
 
194
182
  class TriggerResponseResources(WorkspaceScopedResponseResources):
195
183
  """Class for all resource models associated with the trigger entity."""
196
184
 
197
- event_source: "EventSourceResponse" = Field(
198
- title="The event source that activates this trigger.",
185
+ action: "ActionResponse" = Field(
186
+ title="The action that is executed by this trigger.",
199
187
  )
200
- service_account: UserResponse = Field(
201
- title="The service account that is used to execute the action.",
188
+ event_source: Optional["EventSourceResponse"] = Field(
189
+ default=None,
190
+ title="The event source that activates this trigger. Not set if the "
191
+ "trigger is activated by a schedule.",
202
192
  )
203
193
  executions: Page[TriggerExecutionResponse] = Field(
204
194
  title="The executions of this trigger.",
@@ -213,7 +203,7 @@ class TriggerResponse(
213
203
  """Response model for models."""
214
204
 
215
205
  name: str = Field(
216
- title="The name of the model",
206
+ title="The name of the trigger",
217
207
  max_length=STR_FIELD_MAX_LENGTH,
218
208
  )
219
209
 
@@ -227,15 +217,6 @@ class TriggerResponse(
227
217
 
228
218
  return Client().zen_store.get_trigger(self.id)
229
219
 
230
- @property
231
- def event_source_flavor(self) -> str:
232
- """The `event_source_flavor` property.
233
-
234
- Returns:
235
- the value of the property.
236
- """
237
- return self.get_body().event_source_flavor
238
-
239
220
  @property
240
221
  def action_flavor(self) -> str:
241
222
  """The `action_flavor` property.
@@ -246,7 +227,7 @@ class TriggerResponse(
246
227
  return self.get_body().action_flavor
247
228
 
248
229
  @property
249
- def action_subtype(self) -> PluginSubType:
230
+ def action_subtype(self) -> str:
250
231
  """The `action_subtype` property.
251
232
 
252
233
  Returns:
@@ -255,48 +236,40 @@ class TriggerResponse(
255
236
  return self.get_body().action_subtype
256
237
 
257
238
  @property
258
- def is_active(self) -> bool:
259
- """The `is_active` property.
239
+ def event_source_flavor(self) -> Optional[str]:
240
+ """The `event_source_flavor` property.
260
241
 
261
242
  Returns:
262
243
  the value of the property.
263
244
  """
264
- return self.get_body().is_active
245
+ return self.get_body().event_source_flavor
265
246
 
266
247
  @property
267
- def event_filter(self) -> Dict[str, Any]:
268
- """The `event_filter` property.
248
+ def event_source_subtype(self) -> Optional[str]:
249
+ """The `event_source_subtype` property.
269
250
 
270
251
  Returns:
271
252
  the value of the property.
272
253
  """
273
- return self.get_metadata().event_filter
254
+ return self.get_body().event_source_subtype
274
255
 
275
256
  @property
276
- def action(self) -> Dict[str, Any]:
277
- """The `action` property.
257
+ def is_active(self) -> bool:
258
+ """The `is_active` property.
278
259
 
279
260
  Returns:
280
261
  the value of the property.
281
262
  """
282
- return self.get_metadata().action
283
-
284
- def set_action(self, action: Dict[str, Any]) -> None:
285
- """Set the `action` property.
286
-
287
- Args:
288
- action: The value to set.
289
- """
290
- self.get_metadata().action = action
263
+ return self.get_body().is_active
291
264
 
292
265
  @property
293
- def event_source(self) -> "EventSourceResponse":
294
- """The `event_source` property.
266
+ def event_filter(self) -> Optional[Dict[str, Any]]:
267
+ """The `event_filter` property.
295
268
 
296
269
  Returns:
297
270
  the value of the property.
298
271
  """
299
- return self.get_resources().event_source
272
+ return self.get_metadata().event_filter
300
273
 
301
274
  @property
302
275
  def description(self) -> str:
@@ -308,37 +281,59 @@ class TriggerResponse(
308
281
  return self.get_metadata().description
309
282
 
310
283
  @property
311
- def service_account(self) -> UserResponse:
312
- """The `service_account` property.
284
+ def action(self) -> "ActionResponse":
285
+ """The `action` property.
313
286
 
314
287
  Returns:
315
288
  the value of the property.
316
289
  """
317
- return self.get_resources().service_account
290
+ return self.get_resources().action
318
291
 
319
292
  @property
320
- def auth_window(self) -> int:
321
- """The `auth_window` property.
293
+ def event_source(self) -> Optional["EventSourceResponse"]:
294
+ """The `event_source` property.
322
295
 
323
296
  Returns:
324
297
  the value of the property.
325
298
  """
326
- return self.get_metadata().auth_window
299
+ return self.get_resources().event_source
300
+
301
+ @property
302
+ def executions(self) -> Page[TriggerExecutionResponse]:
303
+ """The `event_source` property.
304
+
305
+ Returns:
306
+ the value of the property.
307
+ """
308
+ return self.get_resources().executions
327
309
 
328
310
 
329
311
  # ------------------ Filter Model ------------------
330
312
 
331
313
 
332
314
  class TriggerFilter(WorkspaceScopedFilter):
333
- """Model to enable advanced filtering of all TriggerModels."""
315
+ """Model to enable advanced filtering of all triggers."""
316
+
317
+ FILTER_EXCLUDE_FIELDS: ClassVar[List[str]] = [
318
+ *WorkspaceScopedFilter.FILTER_EXCLUDE_FIELDS,
319
+ "action_flavor",
320
+ "action_subtype",
321
+ "event_source_flavor",
322
+ "event_source_subtype",
323
+ ]
334
324
 
335
325
  name: Optional[str] = Field(
336
326
  default=None,
337
- description="Name of the trigger",
327
+ description="Name of the trigger.",
338
328
  )
339
329
  event_source_id: Optional[Union[UUID, str]] = Field(
340
330
  default=None,
341
- description="By the event source this trigger is attached to.",
331
+ description="The event source this trigger is attached to.",
332
+ union_mode="left_to_right",
333
+ )
334
+ action_id: Optional[Union[UUID, str]] = Field(
335
+ default=None,
336
+ description="The action this trigger is attached to.",
342
337
  union_mode="left_to_right",
343
338
  )
344
339
  is_active: Optional[bool] = Field(
@@ -353,13 +348,59 @@ class TriggerFilter(WorkspaceScopedFilter):
353
348
  default=None,
354
349
  title="The subtype of the action that is executed by this trigger.",
355
350
  )
356
- # TODO: Ignore these in normal filter and handle in sqlzenstore
357
- resource_id: Optional[Union[UUID, str]] = Field(
351
+ event_source_flavor: Optional[str] = Field(
358
352
  default=None,
359
- description="By the resource this trigger references.",
360
- union_mode="left_to_right",
353
+ title="The flavor of the event source that activates this trigger.",
361
354
  )
362
- resource_type: Optional[str] = Field(
355
+ event_source_subtype: Optional[str] = Field(
363
356
  default=None,
364
- description="By the resource type this trigger references.",
357
+ title="The subtype of the event source that activates this trigger.",
365
358
  )
359
+
360
+ def get_custom_filters(
361
+ self,
362
+ ) -> List["ColumnElement[bool]"]:
363
+ """Get custom filters.
364
+
365
+ Returns:
366
+ A list of custom filters.
367
+ """
368
+ from sqlmodel import and_
369
+
370
+ from zenml.zen_stores.schemas import (
371
+ ActionSchema,
372
+ EventSourceSchema,
373
+ TriggerSchema,
374
+ )
375
+
376
+ custom_filters = super().get_custom_filters()
377
+
378
+ if self.event_source_flavor:
379
+ event_source_flavor_filter = and_(
380
+ EventSourceSchema.id == TriggerSchema.event_source_id,
381
+ EventSourceSchema.flavor == self.event_source_flavor,
382
+ )
383
+ custom_filters.append(event_source_flavor_filter)
384
+
385
+ if self.event_source_subtype:
386
+ event_source_subtype_filter = and_(
387
+ EventSourceSchema.id == TriggerSchema.event_source_id,
388
+ EventSourceSchema.plugin_subtype == self.event_source_subtype,
389
+ )
390
+ custom_filters.append(event_source_subtype_filter)
391
+
392
+ if self.action_flavor:
393
+ action_flavor_filter = and_(
394
+ ActionSchema.id == TriggerSchema.action_id,
395
+ ActionSchema.flavor == self.action_flavor,
396
+ )
397
+ custom_filters.append(action_flavor_filter)
398
+
399
+ if self.action_subtype:
400
+ action_subtype_filter = and_(
401
+ ActionSchema.id == TriggerSchema.action_id,
402
+ ActionSchema.plugin_subtype == self.action_subtype,
403
+ )
404
+ custom_filters.append(action_subtype_filter)
405
+
406
+ return custom_filters
@@ -19,7 +19,6 @@ import inspect
19
19
  from contextlib import contextmanager
20
20
  from datetime import datetime
21
21
  from pathlib import Path
22
- from types import FunctionType
23
22
  from typing import (
24
23
  TYPE_CHECKING,
25
24
  Any,
@@ -98,11 +97,11 @@ if TYPE_CHECKING:
98
97
  from zenml.config.source import Source
99
98
  from zenml.model.lazy_load import ModelVersionDataLazyLoader
100
99
  from zenml.model.model import Model
100
+ from zenml.types import HookSpecification
101
101
 
102
102
  StepConfigurationUpdateOrDict = Union[
103
103
  Dict[str, Any], StepConfigurationUpdate
104
104
  ]
105
- HookSpecification = Union[str, "Source", FunctionType]
106
105
 
107
106
  logger = get_logger(__name__)
108
107
 
@@ -1307,6 +1306,7 @@ To avoid this consider setting pipeline parameters only in one place (config or
1307
1306
  step_configurations: Optional[
1308
1307
  Mapping[str, "StepConfigurationUpdateOrDict"]
1309
1308
  ] = None,
1309
+ steps: Optional[Mapping[str, "StepConfigurationUpdateOrDict"]] = None,
1310
1310
  config_path: Optional[str] = None,
1311
1311
  unlisted: bool = False,
1312
1312
  prevent_build_reuse: bool = False,
@@ -1319,6 +1319,9 @@ To avoid this consider setting pipeline parameters only in one place (config or
1319
1319
  schedule: Optional schedule to use for the run.
1320
1320
  build: Optional build to use for the run.
1321
1321
  step_configurations: Configurations for steps of the pipeline.
1322
+ steps: Configurations for steps of the pipeline. This is equivalent
1323
+ to `step_configurations`, and will be ignored if
1324
+ `step_configurations` is set as well.
1322
1325
  config_path: Path to a yaml configuration file. This file will
1323
1326
  be parsed as a
1324
1327
  `zenml.config.pipeline_configurations.PipelineRunConfiguration`
@@ -1334,6 +1337,13 @@ To avoid this consider setting pipeline parameters only in one place (config or
1334
1337
  Returns:
1335
1338
  The copied pipeline instance.
1336
1339
  """
1340
+ if steps and step_configurations:
1341
+ logger.warning(
1342
+ "Step configurations were passed using both the "
1343
+ "`step_configurations` and `steps` keywords, ignoring the "
1344
+ "values passed using the `steps` keyword."
1345
+ )
1346
+
1337
1347
  pipeline_copy = self.copy()
1338
1348
 
1339
1349
  pipeline_copy._parse_config_file(
@@ -1353,7 +1363,7 @@ To avoid this consider setting pipeline parameters only in one place (config or
1353
1363
  "run_name": run_name,
1354
1364
  "schedule": schedule,
1355
1365
  "build": build,
1356
- "step_configurations": step_configurations,
1366
+ "step_configurations": step_configurations or steps,
1357
1367
  "config_path": config_path,
1358
1368
  "unlisted": unlisted,
1359
1369
  "prevent_build_reuse": prevent_build_reuse,
@@ -13,7 +13,6 @@
13
13
  # permissions and limitations under the License.
14
14
  """ZenML pipeline decorator definition."""
15
15
 
16
- from types import FunctionType
17
16
  from typing import (
18
17
  TYPE_CHECKING,
19
18
  Any,
@@ -31,8 +30,8 @@ if TYPE_CHECKING:
31
30
  from zenml.config.base_settings import SettingsOrDict
32
31
  from zenml.model.model import Model
33
32
  from zenml.new.pipelines.pipeline import Pipeline
33
+ from zenml.types import HookSpecification
34
34
 
35
- HookSpecification = Union[str, FunctionType]
36
35
  F = TypeVar("F", bound=Callable[..., None])
37
36
 
38
37
  logger = get_logger(__name__)
@@ -3,16 +3,7 @@
3
3
  import time
4
4
  from collections import defaultdict
5
5
  from datetime import datetime
6
- from types import FunctionType
7
- from typing import (
8
- TYPE_CHECKING,
9
- Any,
10
- Dict,
11
- Optional,
12
- Set,
13
- Tuple,
14
- Union,
15
- )
6
+ from typing import TYPE_CHECKING, Any, Dict, Optional, Set, Tuple, Union
16
7
  from uuid import UUID
17
8
 
18
9
  from zenml import constants
@@ -36,13 +27,11 @@ from zenml.utils import cloud_utils
36
27
  from zenml.zen_stores.base_zen_store import BaseZenStore
37
28
 
38
29
  if TYPE_CHECKING:
39
- from zenml.config.source import Source
40
30
  from zenml.model.model import Model
41
31
 
42
32
  StepConfigurationUpdateOrDict = Union[
43
33
  Dict[str, Any], StepConfigurationUpdate
44
34
  ]
45
- HookSpecification = Union[str, "Source", FunctionType]
46
35
 
47
36
  logger = get_logger(__name__)
48
37
 
@@ -30,17 +30,16 @@ from typing import (
30
30
  from zenml.logger import get_logger
31
31
 
32
32
  if TYPE_CHECKING:
33
- from types import FunctionType
34
-
35
33
  from zenml.config.base_settings import SettingsOrDict
36
34
  from zenml.config.retry_config import StepRetryConfig
37
35
  from zenml.config.source import Source
38
36
  from zenml.materializers.base_materializer import BaseMaterializer
39
37
  from zenml.model.model import Model
40
38
  from zenml.steps import BaseStep
39
+ from zenml.types import HookSpecification
41
40
 
42
41
  MaterializerClassOrSource = Union[str, Source, Type[BaseMaterializer]]
43
- HookSpecification = Union[str, Source, FunctionType]
42
+
44
43
  OutputMaterializersSpecification = Union[
45
44
  MaterializerClassOrSource,
46
45
  Sequence[MaterializerClassOrSource],
@@ -15,7 +15,6 @@
15
15
 
16
16
  import inspect
17
17
  from abc import ABC, abstractmethod
18
- from types import FunctionType
19
18
  from typing import TYPE_CHECKING, Any, ClassVar, Dict, Mapping, Optional, Union
20
19
  from uuid import UUID
21
20
 
@@ -35,7 +34,6 @@ if TYPE_CHECKING:
35
34
  StepConfigurationUpdateOrDict = Union[
36
35
  Dict[str, Any], StepConfigurationUpdate
37
36
  ]
38
- HookSpecification = Union[str, FunctionType]
39
37
 
40
38
  logger = get_logger(__name__)
41
39
 
@@ -13,7 +13,6 @@
13
13
  # permissions and limitations under the License.
14
14
  """Legacy ZenML pipeline decorator definition."""
15
15
 
16
- from types import FunctionType
17
16
  from typing import (
18
17
  TYPE_CHECKING,
19
18
  Any,
@@ -46,8 +45,8 @@ from zenml.pipelines.base_pipeline import (
46
45
 
47
46
  if TYPE_CHECKING:
48
47
  from zenml.config.base_settings import SettingsOrDict
48
+ from zenml.types import HookSpecification
49
49
 
50
- HookSpecification = Union[str, FunctionType]
51
50
 
52
51
  logger = get_logger(__name__)
53
52