zenml-nightly 0.68.1.dev20241102__py3-none-any.whl → 0.68.1.dev20241104__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.68.1.dev20241102
1
+ 0.68.1.dev20241104
@@ -26,7 +26,8 @@ class LangchainIntegration(Integration):
26
26
 
27
27
  NAME = LANGCHAIN
28
28
  REQUIREMENTS = [
29
- "langchain==0.0.325",
29
+ "langchain==0.3.0",
30
+ "langchain-community",
30
31
  "pyyaml>=6.0.1",
31
32
  "tenacity!=8.4.0", # https://github.com/jd/tenacity/issues/471
32
33
  ]
@@ -24,11 +24,37 @@ from zenml.materializers.cloudpickle_materializer import (
24
24
  if TYPE_CHECKING and sys.version_info < (3, 8):
25
25
  OpenAIEmbeddings = Any
26
26
  else:
27
- from langchain.embeddings import OpenAIEmbeddings
27
+ from langchain_community.embeddings import (
28
+ OpenAIEmbeddings,
29
+ )
28
30
 
29
31
 
30
32
  class LangchainOpenaiEmbeddingMaterializer(CloudpickleMaterializer):
31
- """Handle langchain OpenAI embedding objects."""
33
+ """Materializer for Langchain OpenAI Embeddings."""
32
34
 
33
35
  ASSOCIATED_ARTIFACT_TYPE: ClassVar[ArtifactType] = ArtifactType.MODEL
34
36
  ASSOCIATED_TYPES: ClassVar[Tuple[Type[Any], ...]] = (OpenAIEmbeddings,)
37
+
38
+ def save(self, embeddings: Any) -> None:
39
+ """Saves the embeddings model after clearing non-picklable clients.
40
+
41
+ Args:
42
+ embeddings: The embeddings model to save.
43
+ """
44
+ # Clear the clients which will be recreated on load
45
+ embeddings.client = None
46
+ embeddings.async_client = None
47
+
48
+ # Use the parent class's save implementation which uses cloudpickle
49
+ super().save(embeddings)
50
+
51
+ def load(self, data_type: Type[Any]) -> Any:
52
+ """Loads the embeddings model and lets it recreate clients when needed.
53
+
54
+ Args:
55
+ data_type: The type of the data to load.
56
+
57
+ Returns:
58
+ The loaded embeddings model.
59
+ """
60
+ return super().load(data_type)
@@ -21,7 +21,7 @@ class OpenAIIntegration(Integration):
21
21
  """Definition of OpenAI integration for ZenML."""
22
22
 
23
23
  NAME = OPEN_AI
24
- REQUIREMENTS = ["openai>=0.27.0,<1.0.0"]
24
+ REQUIREMENTS = ["openai>=1.0.0"]
25
25
 
26
26
 
27
27
  OpenAIIntegration.check_installation()
@@ -15,8 +15,9 @@
15
15
 
16
16
  import io
17
17
  import sys
18
+ from typing import Optional
18
19
 
19
- import openai
20
+ from openai import OpenAI
20
21
  from rich.console import Console
21
22
 
22
23
  from zenml import get_step_context
@@ -38,6 +39,8 @@ def openai_alerter_failure_hook_helper(
38
39
  Args:
39
40
  exception: The exception that was raised.
40
41
  model_name: The OpenAI model to use for the chatbot.
42
+
43
+ This implementation uses the OpenAI v1 SDK with automatic retries and backoff.
41
44
  """
42
45
  client = Client()
43
46
  context = get_step_context()
@@ -47,12 +50,15 @@ def openai_alerter_failure_hook_helper(
47
50
  openai_secret = client.get_secret(
48
51
  "openai", allow_partial_name_match=False
49
52
  )
50
- openai_api_key = openai_secret.secret_values.get("api_key")
53
+ openai_api_key: Optional[str] = openai_secret.secret_values.get(
54
+ "api_key"
55
+ )
51
56
  except (KeyError, NotImplementedError):
52
57
  openai_api_key = None
53
58
 
54
59
  alerter = client.active_stack.alerter
55
60
  if alerter and openai_api_key:
61
+ # Capture rich traceback
56
62
  output_captured = io.StringIO()
57
63
  original_stdout = sys.stdout
58
64
  sys.stdout = output_captured
@@ -62,25 +68,44 @@ def openai_alerter_failure_hook_helper(
62
68
  sys.stdout = original_stdout
63
69
  rich_traceback = output_captured.getvalue()
64
70
 
65
- response = openai.ChatCompletion.create( # type: ignore
71
+ # Initialize OpenAI client with timeout and retry settings
72
+ openai_client = OpenAI(
73
+ api_key=openai_api_key,
74
+ max_retries=3, # Will retry 3 times with exponential backoff
75
+ timeout=60.0, # 60 second timeout
76
+ )
77
+
78
+ # Create chat completion using the new client pattern
79
+ response = openai_client.chat.completions.create(
66
80
  model=model_name,
67
81
  messages=[
68
82
  {
69
83
  "role": "user",
70
- "content": f"This is an error message (following an exception of type '{type(exception)}') I encountered while executing a ZenML step. Please suggest ways I might fix the problem. Feel free to give code snippets as examples, and note that your response will be piped to a Slack bot so make sure the formatting is appropriate: {exception} -- {rich_traceback}. Thank you!",
84
+ "content": f"This is an error message (following an exception of type '{type(exception)}') "
85
+ f"I encountered while executing a ZenML step. Please suggest ways I might fix the problem. "
86
+ f"Feel free to give code snippets as examples, and note that your response will be piped "
87
+ f"to a Slack bot so make sure the formatting is appropriate: {exception} -- {rich_traceback}. "
88
+ f"Thank you!",
71
89
  }
72
90
  ],
73
91
  )
74
- suggestion = response["choices"][0]["message"]["content"]
75
- message = "*Failure Hook Notification! Step failed!*" + "\n\n"
76
- message += f"Run name: `{context.pipeline_run.name}`" + "\n"
77
- message += f"Step name: `{context.step_run.name}`" + "\n"
78
- message += f"Parameters: `{context.step_run.config.parameters}`" + "\n"
79
- message += f"Exception: `({type(exception)}) {exception}`" + "\n\n"
80
- message += (
81
- f"*OpenAI ChatGPT's suggestion (model = `{model_name}`) on how to fix it:*\n `{suggestion}`"
82
- + "\n"
92
+
93
+ suggestion = response.choices[0].message.content
94
+
95
+ # Format the alert message
96
+ message = "\n".join(
97
+ [
98
+ "*Failure Hook Notification! Step failed!*",
99
+ "",
100
+ f"Run name: `{context.pipeline_run.name}`",
101
+ f"Step name: `{context.step_run.name}`",
102
+ f"Parameters: `{context.step_run.config.parameters}`",
103
+ f"Exception: `({type(exception)}) {exception}`",
104
+ "",
105
+ f"*OpenAI ChatGPT's suggestion (model = `{model_name}`) on how to fix it:*\n `{suggestion}`",
106
+ ]
83
107
  )
108
+
84
109
  alerter.post(message)
85
110
  elif not openai_api_key:
86
111
  logger.warning(
@@ -111,4 +136,4 @@ def openai_gpt4_alerter_failure_hook(
111
136
  Args:
112
137
  exception: The exception that was raised.
113
138
  """
114
- openai_alerter_failure_hook_helper(exception, "gpt-4")
139
+ openai_alerter_failure_hook_helper(exception, "gpt-4o")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zenml-nightly
3
- Version: 0.68.1.dev20241102
3
+ Version: 0.68.1.dev20241104
4
4
  Summary: ZenML: Write production-ready ML code.
5
5
  Home-page: https://zenml.io
6
6
  License: Apache-2.0
@@ -6,7 +6,7 @@ RELEASE_NOTES.md,sha256=oShLQurhMKncKnc_y7tiasEfgy1aCOOjxdpax-MlGI8,381641
6
6
  ROADMAP.md,sha256=hiLSmr16BH8Dfx7SaQM4JcXCGCVl6mFZPFAwJeDTrJU,407
7
7
  SECURITY.md,sha256=9DepA8y03yvCZLHEfcXLTDH4lUyKHquAdukBsccNN7c,682
8
8
  zenml/README.md,sha256=827dekbOWAs1BpW7VF1a4d7EbwPbjwccX-2zdXBENZo,1777
9
- zenml/VERSION,sha256=AbM1Y6d4EFqFXURbKaJgDYyhaW23iaOymlBafKZs-GA,19
9
+ zenml/VERSION,sha256=1S2siAIhM1zXNEGpC70GGCJ14D8KOlXLMXluWW4LEQI,19
10
10
  zenml/__init__.py,sha256=XhLh9kV87ErcivCctQJaTtUOjl6kugT3pVyqqLKzBP8,2058
11
11
  zenml/actions/__init__.py,sha256=mrt6wPo73iKRxK754_NqsGyJ3buW7RnVeIGXr1xEw8Y,681
12
12
  zenml/actions/base_action.py,sha256=UcaHev6BTuLDwuswnyaPjdA8AgUqB5xPZ-lRtuvf2FU,25553
@@ -358,10 +358,10 @@ zenml/integrations/label_studio/label_config_generators/label_config_generators.
358
358
  zenml/integrations/label_studio/label_studio_utils.py,sha256=NelKDXCoEIF37-xh7rffHeuHEwWvkfshR5w5f6HuBII,3316
359
359
  zenml/integrations/label_studio/steps/__init__.py,sha256=SQ-6oyRtqHDsU-QjOdvtd-cD8plsW40Dwl5SZnWtbbA,895
360
360
  zenml/integrations/label_studio/steps/label_studio_standard_steps.py,sha256=k7UTFzDZBTdV0NbVtRKMqQo-gURvdSMtjtHoFfiIWgs,8695
361
- zenml/integrations/langchain/__init__.py,sha256=GIxyxtrxvaeWYs-uVO3qg1pGVsMWPsOmMFTFa-Hw1V0,1382
361
+ zenml/integrations/langchain/__init__.py,sha256=Qzsw8brka_N2QFQj3iUKEClHVVH-UMsHCCLAq1tpk24,1411
362
362
  zenml/integrations/langchain/materializers/__init__.py,sha256=ouU6MDX_gZc0FVgNK8xO6F7B2XOEikrevQEZpdYyaOM,1037
363
363
  zenml/integrations/langchain/materializers/document_materializer.py,sha256=86-V8ADkT0laE8ZvQyj8v9EbxHeeQ9PbiQq06OhMmdo,2287
364
- zenml/integrations/langchain/materializers/openai_embedding_materializer.py,sha256=WLErmqNJU5gmc-EqMEsIOAdrpyZPB62th9r4Xx0g-Ao,1294
364
+ zenml/integrations/langchain/materializers/openai_embedding_materializer.py,sha256=LXqsU4X-t6NKed7Y8BSVZY2IU7wu0fkO8NlVEM2kibc,2077
365
365
  zenml/integrations/langchain/materializers/vector_store_materializer.py,sha256=HQZxrJLtm_dCNZH5FeF6_4YfQRKu-mais6_uzSIEaLs,1273
366
366
  zenml/integrations/lightgbm/__init__.py,sha256=6WwTSY7teUMj4Ru0e7xLCl6MR3CtelW7RHgtLdWadag,1162
367
367
  zenml/integrations/lightgbm/materializers/__init__.py,sha256=9tUTAisuFmR2-B4E-3l23Ab_sy8Jw6AAKUkG3pnd6ZI,929
@@ -409,9 +409,9 @@ zenml/integrations/neural_prophet/materializers/neural_prophet_materializer.py,s
409
409
  zenml/integrations/numpy/__init__.py,sha256=McWmP5C0LNd03GtTrq5KOiKh9JUBhwhX8rmJlUnyR34,1105
410
410
  zenml/integrations/numpy/materializers/__init__.py,sha256=txwv8We-dLehTWqY-eDYx40njg4Ld8eQrs1O0MZiiIk,766
411
411
  zenml/integrations/numpy/materializers/numpy_materializer.py,sha256=rNIcoZkU6JZcqEc6yt3x3yHvmmWnLAfKy74hLxKXbM8,8477
412
- zenml/integrations/openai/__init__.py,sha256=Zi9LaUe6sElglthZQ4iuqjO34v5DWZoltj387uPZTCs,966
412
+ zenml/integrations/openai/__init__.py,sha256=cKPFCz_cTnJLQ-crdgpWQlHEZnVVeK5_SyRue2bvCXY,958
413
413
  zenml/integrations/openai/hooks/__init__.py,sha256=8VfiVOyIrjya9G_VK5GPEqq9G5i9w5u4ngf-Oo_oHT4,811
414
- zenml/integrations/openai/hooks/open_ai_failure_hook.py,sha256=t1nRghWpsGPd89XDDOjK5gRTJSdk6mkVmGpX0vUhaos,4046
414
+ zenml/integrations/openai/hooks/open_ai_failure_hook.py,sha256=tQe-dUO7_w24ABfN96TZ7Zc2inJMI5u9sdE8gBxrDyM,4702
415
415
  zenml/integrations/pandas/__init__.py,sha256=Rt4BJUlZk-Td2m9l7cLkbAv4vL2Z2YULTqWoICGoU6s,1114
416
416
  zenml/integrations/pandas/materializers/__init__.py,sha256=LcN6iO4vZKTMFp1eRF5njIu-UwqMsonms3T4ObFTtbk,770
417
417
  zenml/integrations/pandas/materializers/pandas_materializer.py,sha256=kr4kVLluvytiqvYMS8JtwmcGQW6cMJxnsSbX1XMKo6c,7077
@@ -1245,8 +1245,8 @@ zenml/zen_stores/secrets_stores/sql_secrets_store.py,sha256=Bq1djrUP9saoD7vECjS7
1245
1245
  zenml/zen_stores/sql_zen_store.py,sha256=n5LWV-VBX2cfLDNQDk1F_xBCIklEs8Tug54Iafr7_YU,402789
1246
1246
  zenml/zen_stores/template_utils.py,sha256=EKYBgmDLTS_PSMWaIO5yvHPLiQvMqHcsAe6NUCrv-i4,9068
1247
1247
  zenml/zen_stores/zen_store_interface.py,sha256=kzR_i8vHjULld3MquSaMorcab8lJk1e9RZquw1VXjHY,93510
1248
- zenml_nightly-0.68.1.dev20241102.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1249
- zenml_nightly-0.68.1.dev20241102.dist-info/METADATA,sha256=LhbrA4XrEyAnxujeG4ljZld_SVwUF3iDUErDVtl8GcY,21208
1250
- zenml_nightly-0.68.1.dev20241102.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
1251
- zenml_nightly-0.68.1.dev20241102.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1252
- zenml_nightly-0.68.1.dev20241102.dist-info/RECORD,,
1248
+ zenml_nightly-0.68.1.dev20241104.dist-info/LICENSE,sha256=wbnfEnXnafPbqwANHkV6LUsPKOtdpsd-SNw37rogLtc,11359
1249
+ zenml_nightly-0.68.1.dev20241104.dist-info/METADATA,sha256=YQvhWfYfiU7EdqKTJv97zWsJOhWPmdI-fu92C77Yoc8,21208
1250
+ zenml_nightly-0.68.1.dev20241104.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
1251
+ zenml_nightly-0.68.1.dev20241104.dist-info/entry_points.txt,sha256=QK3ETQE0YswAM2mWypNMOv8TLtr7EjnqAFq1br_jEFE,43
1252
+ zenml_nightly-0.68.1.dev20241104.dist-info/RECORD,,