zenml-nightly 0.84.2.dev20250807__py3-none-any.whl → 0.84.2.dev20250809__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 CHANGED
@@ -1 +1 @@
1
- 0.84.2.dev20250807
1
+ 0.84.2.dev20250809
zenml/steps/base_step.py CHANGED
@@ -271,6 +271,15 @@ class BaseStep:
271
271
  """
272
272
  return inspect.getsource(self.source_object)
273
273
 
274
+ @property
275
+ def source_code_cache_value(self) -> str:
276
+ """The source code cache value of this step.
277
+
278
+ Returns:
279
+ The source code cache value of this step.
280
+ """
281
+ return self.source_code
282
+
274
283
  @property
275
284
  def docstring(self) -> Optional[str]:
276
285
  """The docstring of this step.
@@ -288,9 +297,9 @@ class BaseStep:
288
297
  A dictionary containing the caching parameters
289
298
  """
290
299
  parameters = {
291
- CODE_HASH_PARAMETER_NAME: source_code_utils.get_hashed_source_code(
292
- self.source_object
293
- )
300
+ CODE_HASH_PARAMETER_NAME: hashlib.sha256(
301
+ self.source_code_cache_value.encode("utf-8")
302
+ ).hexdigest()
294
303
  }
295
304
  for name, output in self.configuration.outputs.items():
296
305
  if output.materializer_source:
@@ -13,15 +13,111 @@
13
13
  # permissions and limitations under the License.
14
14
  """Internal BaseStep subclass used by the step decorator."""
15
15
 
16
- from typing import Any
16
+ from typing import Any, Optional
17
17
 
18
18
  from zenml.config.source import Source
19
- from zenml.steps import BaseStep
19
+ from zenml.steps import BaseStep, step
20
+
21
+
22
+ def remove_decorator_from_source_code(
23
+ source_code: str, decorator_name: str
24
+ ) -> str:
25
+ """Remove a decorator from the source code of a function.
26
+
27
+ Args:
28
+ source_code: The source code of the function.
29
+ decorator_name: The name of the decorator.
30
+
31
+ Returns:
32
+ The source code of the function without the decorator.
33
+ """
34
+ import ast
35
+
36
+ # Remove potential indentation from the source code
37
+ source_code_lines = source_code.split("\n")
38
+ if source_code_lines:
39
+ first_line = source_code_lines[0]
40
+ leading_spaces = len(first_line) - len(first_line.lstrip())
41
+ source_code_lines = [
42
+ line[leading_spaces:] if len(line) >= leading_spaces else line
43
+ for line in source_code_lines
44
+ ]
45
+
46
+ module = ast.parse("\n".join(source_code_lines))
47
+ if not module.body or not isinstance(module.body[0], ast.FunctionDef):
48
+ return source_code
49
+
50
+ function_def = module.body[0]
51
+ if not function_def.decorator_list:
52
+ return source_code
53
+
54
+ for decorator in function_def.decorator_list:
55
+ lineno = None
56
+ end_lineno = None
57
+
58
+ if isinstance(decorator, ast.Call) and isinstance(
59
+ decorator.func, ast.Name
60
+ ):
61
+ if decorator.func.id == decorator_name:
62
+ lineno = decorator.lineno
63
+ end_lineno = decorator.end_lineno
64
+ elif isinstance(decorator, ast.Name):
65
+ if decorator.id == decorator_name:
66
+ lineno = decorator.lineno
67
+ end_lineno = decorator.end_lineno
68
+ else:
69
+ continue
70
+
71
+ if lineno is not None and end_lineno is not None:
72
+ # The line numbers are 1-indexed, so we need to
73
+ # subtract 1
74
+ source_code_lines = (
75
+ source_code_lines[: lineno - 1]
76
+ + source_code_lines[end_lineno:]
77
+ )
78
+ source_code = "\n".join(source_code_lines)
79
+ break
80
+
81
+ return source_code
20
82
 
21
83
 
22
84
  class _DecoratedStep(BaseStep):
23
85
  """Internal BaseStep subclass used by the step decorator."""
24
86
 
87
+ def _get_step_decorator_name(self) -> Optional[str]:
88
+ """The name of the step decorator.
89
+
90
+ Returns:
91
+ The name of the step decorator.
92
+ """
93
+ decorator_names = [
94
+ key
95
+ for key, value in self.entrypoint.__globals__.items()
96
+ if value is step
97
+ ]
98
+ if not decorator_names:
99
+ return None
100
+
101
+ return decorator_names[0]
102
+
103
+ @property
104
+ def source_code_cache_value(self) -> str:
105
+ """The source code cache value of this step.
106
+
107
+ Returns:
108
+ The source code cache value of this step.
109
+ """
110
+ try:
111
+ if decorator_name := self._get_step_decorator_name():
112
+ return remove_decorator_from_source_code(
113
+ source_code=self.source_code,
114
+ decorator_name=decorator_name,
115
+ )
116
+ except Exception:
117
+ pass
118
+
119
+ return super().source_code_cache_value
120
+
25
121
  @property
26
122
  def source_object(self) -> Any:
27
123
  """The source object of this step.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: zenml-nightly
3
- Version: 0.84.2.dev20250807
3
+ Version: 0.84.2.dev20250809
4
4
  Summary: ZenML: Write production-ready ML code.
5
5
  License: Apache-2.0
6
6
  Keywords: machine learning,production,pipeline,mlops,devops
@@ -1,5 +1,5 @@
1
1
  zenml/README.md,sha256=827dekbOWAs1BpW7VF1a4d7EbwPbjwccX-2zdXBENZo,1777
2
- zenml/VERSION,sha256=5Qbn3wnWDaFIZJ7bj5KdK188yXmxX25h-ppF-ENK_Q4,19
2
+ zenml/VERSION,sha256=-UGFWian4KhYUNm1pRGgxZco7JYlUnH6eaju2_WoJRc,19
3
3
  zenml/__init__.py,sha256=r7JUg2SVDf_dPhS7iU6vudKusEqK4ics7_jFMZhq0o4,2731
4
4
  zenml/actions/__init__.py,sha256=mrt6wPo73iKRxK754_NqsGyJ3buW7RnVeIGXr1xEw8Y,681
5
5
  zenml/actions/base_action.py,sha256=UcaHev6BTuLDwuswnyaPjdA8AgUqB5xPZ-lRtuvf2FU,25553
@@ -756,8 +756,8 @@ zenml/step_operators/__init__.py,sha256=tqj7fgnQyZubLjwUu4ITwkA-70KMQz4g37agbfF7
756
756
  zenml/step_operators/base_step_operator.py,sha256=ZRnY6lcEHY8xZskrKKdPhgKg2BlEoh2_kb8xCaM2D1g,3522
757
757
  zenml/step_operators/step_operator_entrypoint_configuration.py,sha256=wuQKmEI_ckn1CHHrxWGGdIhQyBFXG01aKC2-2b6Atjo,3690
758
758
  zenml/steps/__init__.py,sha256=KKWFOmCZGLDEikOD2E5YmDA7QHo47uPV37by21WwI0U,1453
759
- zenml/steps/base_step.py,sha256=6mz8ZBn4wd509KcwZeD1qdxQV4BF3wLknMMzn_g3wgg,44390
760
- zenml/steps/decorated_step.py,sha256=C8Ng5PCLc9eql4JF1N345HQ6LyC1qCUdTnysUTeoAJs,1315
759
+ zenml/steps/base_step.py,sha256=HUNNQe3A5DyzEHm4gAbX_NCC2LiKRDI6nrngURW6WdI,44632
760
+ zenml/steps/decorated_step.py,sha256=cr4m7qi525fUc_VTkb7J16dKdUSzc4UA5eyHg8vFWQg,4275
761
761
  zenml/steps/entrypoint_function_utils.py,sha256=H0WIkHpR_R0S9gl_tWr0nX-fcBlYnm8OQ1cimvrw-qo,9555
762
762
  zenml/steps/step_context.py,sha256=sFvVVvEyKmWTrucofor8Cuxv-72jbziVaQY-OlOvFAM,15526
763
763
  zenml/steps/step_decorator.py,sha256=0TKxP_oAVRizjN3JhBZ8ShFd3fSBdVPU2ijytTg1h2U,6506
@@ -1355,8 +1355,8 @@ zenml/zen_stores/secrets_stores/sql_secrets_store.py,sha256=LPFW757WCJLP1S8vrvjs
1355
1355
  zenml/zen_stores/sql_zen_store.py,sha256=-3zeByIUjIvsx3564O2gJ463512QkZl04okL3eB-nJs,491568
1356
1356
  zenml/zen_stores/template_utils.py,sha256=iCXrXpqzVTY7roqop4Eh9J7DmLW6PQeILZexmw_l3b8,10074
1357
1357
  zenml/zen_stores/zen_store_interface.py,sha256=weiSULdI9AsbCE10a5TcwtybX-BJs9hKhjPJnTapWv4,93023
1358
- zenml_nightly-0.84.2.dev20250807.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1359
- zenml_nightly-0.84.2.dev20250807.dist-info/METADATA,sha256=g0HviK0kuLK_THciwuXaQMPDkm8S3qL0hX0GOzmgAvE,24303
1360
- zenml_nightly-0.84.2.dev20250807.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
1361
- zenml_nightly-0.84.2.dev20250807.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1362
- zenml_nightly-0.84.2.dev20250807.dist-info/RECORD,,
1358
+ zenml_nightly-0.84.2.dev20250809.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1359
+ zenml_nightly-0.84.2.dev20250809.dist-info/METADATA,sha256=mcz4Yi9LcDIaBK_WnBRF3xN4SKiMu0SH932nozCUqeE,24303
1360
+ zenml_nightly-0.84.2.dev20250809.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
1361
+ zenml_nightly-0.84.2.dev20250809.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1362
+ zenml_nightly-0.84.2.dev20250809.dist-info/RECORD,,