weave-haystack 1.0.0__tar.gz → 3.0.0__tar.gz
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.
- weave_haystack-3.0.0/CHANGELOG.md +36 -0
- weave_haystack-3.0.0/PKG-INFO +39 -0
- weave_haystack-3.0.0/README.md +15 -0
- weave_haystack-3.0.0/pydoc/config_docusaurus.yml +29 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/pyproject.toml +8 -14
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/components/connectors/weave/weave_connector.py +9 -14
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/tracing/weave/tracer.py +13 -19
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/tests/test_tracer.py +2 -6
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/tests/test_weave_connector.py +29 -5
- weave_haystack-1.0.0/CHANGELOG.md +0 -9
- weave_haystack-1.0.0/PKG-INFO +0 -99
- weave_haystack-1.0.0/README.md +0 -74
- weave_haystack-1.0.0/pydoc/config.yml +0 -30
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/.gitignore +0 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/LICENSE.txt +0 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/example/README.md +0 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/example/hybrid_retrieval.py +0 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/components/connectors/py.typed +0 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/components/connectors/weave/__init__.py +0 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/tracing/py.typed +0 -0
- {weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/tracing/weave/__init__.py +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [integrations/weights_and_biases_weave-v2.0.0] - 2025-09-16
|
|
4
|
+
|
|
5
|
+
### 🐛 Bug Fixes
|
|
6
|
+
|
|
7
|
+
- Weave - pin gql (#2198)
|
|
8
|
+
|
|
9
|
+
### 🚜 Refactor
|
|
10
|
+
|
|
11
|
+
- [**breaking**] Weave - update patching support and unpin gql (#2272)
|
|
12
|
+
|
|
13
|
+
### 🧹 Chores
|
|
14
|
+
|
|
15
|
+
- Standardize readmes - part 2 (#2205)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [integrations/weights_and_biases_weave-v1.0.0] - 2025-07-01
|
|
19
|
+
|
|
20
|
+
### 🐛 Bug Fixes
|
|
21
|
+
|
|
22
|
+
- [**breaking**] Weave - move Connector, fix types, add py.typed (#2038)
|
|
23
|
+
|
|
24
|
+
### 🧹 Chores
|
|
25
|
+
|
|
26
|
+
- Align core-integrations Hatch scripts (#1898)
|
|
27
|
+
- Remove black (#1985)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [integrations/weights_and_biases_weave-v0.0.1] - 2025-03-28
|
|
31
|
+
|
|
32
|
+
### 🚜 Refactor
|
|
33
|
+
|
|
34
|
+
- Renaming the project/package to weights_biases_weave (#1565)
|
|
35
|
+
|
|
36
|
+
<!-- generated by git-cliff -->
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: weave-haystack
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: An integration of Weights & Biases Weave tracer with Haystack
|
|
5
|
+
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
|
|
6
|
+
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/weave/README.md
|
|
7
|
+
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
8
|
+
Author-email: deepset GmbH <info@deepset.ai>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: haystack-ai>=2.22.0
|
|
22
|
+
Requires-Dist: weave>=0.52.7
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# weave-haystack
|
|
26
|
+
|
|
27
|
+
[](https://pypi.org/project/weave-haystack)
|
|
28
|
+
[](https://pypi.org/project/weave-haystack)
|
|
29
|
+
|
|
30
|
+
- [Integration page](https://haystack.deepset.ai/integrations/weights-and-bias-tracer)
|
|
31
|
+
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/weave/CHANGELOG.md)
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
38
|
+
|
|
39
|
+
To run integration tests locally, you need to export the `WANDB_API_KEY` environment variable.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# weave-haystack
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/weave-haystack)
|
|
4
|
+
[](https://pypi.org/project/weave-haystack)
|
|
5
|
+
|
|
6
|
+
- [Integration page](https://haystack.deepset.ai/integrations/weights-and-bias-tracer)
|
|
7
|
+
- [Changelog](https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/weave/CHANGELOG.md)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Contributing
|
|
12
|
+
|
|
13
|
+
Refer to the general [Contribution Guidelines](https://github.com/deepset-ai/haystack-core-integrations/blob/main/CONTRIBUTING.md).
|
|
14
|
+
|
|
15
|
+
To run integration tests locally, you need to export the `WANDB_API_KEY` environment variable.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
loaders:
|
|
2
|
+
- ignore_when_discovered:
|
|
3
|
+
- __init__
|
|
4
|
+
modules:
|
|
5
|
+
- haystack_integrations.components.connectors.weave.weave_connector
|
|
6
|
+
- haystack_integrations.tracing.weave.tracer
|
|
7
|
+
search_path:
|
|
8
|
+
- ../src
|
|
9
|
+
type: haystack_pydoc_tools.loaders.CustomPythonLoader
|
|
10
|
+
processors:
|
|
11
|
+
- do_not_filter_modules: false
|
|
12
|
+
documented_only: true
|
|
13
|
+
expression: null
|
|
14
|
+
skip_empty_modules: true
|
|
15
|
+
type: filter
|
|
16
|
+
- type: smart
|
|
17
|
+
- type: crossref
|
|
18
|
+
renderer:
|
|
19
|
+
description: Weights & Bias integration for Haystack
|
|
20
|
+
id: integrations-weights-bias
|
|
21
|
+
markdown:
|
|
22
|
+
add_member_class_prefix: false
|
|
23
|
+
add_method_class_prefix: true
|
|
24
|
+
classdef_code_block: false
|
|
25
|
+
descriptive_class_title: false
|
|
26
|
+
descriptive_module_title: true
|
|
27
|
+
filename: weights_and_bias.md
|
|
28
|
+
title: weights and bias
|
|
29
|
+
type: haystack_pydoc_tools.renderers.DocusaurusRenderer
|
|
@@ -7,7 +7,7 @@ name = "weave-haystack"
|
|
|
7
7
|
dynamic = ["version"]
|
|
8
8
|
description = "An integration of Weights & Biases Weave tracer with Haystack"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
11
|
license = "Apache-2.0"
|
|
12
12
|
keywords = []
|
|
13
13
|
authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
|
|
@@ -15,7 +15,6 @@ classifiers = [
|
|
|
15
15
|
"License :: OSI Approved :: Apache Software License",
|
|
16
16
|
"Development Status :: 4 - Beta",
|
|
17
17
|
"Programming Language :: Python",
|
|
18
|
-
"Programming Language :: Python :: 3.9",
|
|
19
18
|
"Programming Language :: Python :: 3.10",
|
|
20
19
|
"Programming Language :: Python :: 3.11",
|
|
21
20
|
"Programming Language :: Python :: 3.12",
|
|
@@ -23,11 +22,11 @@ classifiers = [
|
|
|
23
22
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
23
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
25
24
|
]
|
|
26
|
-
dependencies = ["haystack-ai", "weave>=0.
|
|
25
|
+
dependencies = ["haystack-ai>=2.22.0", "weave>=0.52.7"]
|
|
27
26
|
|
|
28
27
|
[project.urls]
|
|
29
28
|
Source = "https://github.com/deepset-ai/haystack-core-integrations"
|
|
30
|
-
Documentation = "https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/
|
|
29
|
+
Documentation = "https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/weave/README.md"
|
|
31
30
|
Issues = "https://github.com/deepset-ai/haystack-core-integrations/issues"
|
|
32
31
|
|
|
33
32
|
[tool.hatch.build.targets.wheel]
|
|
@@ -35,18 +34,18 @@ packages = ["src/haystack_integrations"]
|
|
|
35
34
|
|
|
36
35
|
[tool.hatch.version]
|
|
37
36
|
source = "vcs"
|
|
38
|
-
tag-pattern = 'integrations\/
|
|
37
|
+
tag-pattern = 'integrations\/weave-v(?P<version>.*)'
|
|
39
38
|
|
|
40
39
|
[tool.hatch.version.raw-options]
|
|
41
40
|
root = "../.."
|
|
42
|
-
git_describe_command = 'git describe --tags --match="integrations/
|
|
41
|
+
git_describe_command = 'git describe --tags --match="integrations/weave-v[0-9]*"'
|
|
43
42
|
|
|
44
43
|
[tool.hatch.envs.default]
|
|
45
44
|
installer = "uv"
|
|
46
45
|
dependencies = ["haystack-pydoc-tools", "ruff"]
|
|
47
46
|
[tool.hatch.envs.default.scripts]
|
|
48
|
-
docs = ["pydoc-markdown pydoc/
|
|
49
|
-
fmt = "ruff check --fix {args}
|
|
47
|
+
docs = ["pydoc-markdown pydoc/config_docusaurus.yml"]
|
|
48
|
+
fmt = "ruff check --fix {args}; ruff format {args}"
|
|
50
49
|
fmt-check = "ruff check {args} && ruff format --check {args}"
|
|
51
50
|
|
|
52
51
|
[tool.hatch.envs.test]
|
|
@@ -63,7 +62,7 @@ dependencies = [
|
|
|
63
62
|
unit = 'pytest -m "not integration" {args:tests}'
|
|
64
63
|
integration = 'pytest -m "integration" {args:tests}'
|
|
65
64
|
all = 'pytest {args:tests}'
|
|
66
|
-
cov-retry = '
|
|
65
|
+
cov-retry = 'pytest --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x {args:tests}'
|
|
67
66
|
types = """mypy -p haystack_integrations.components.connectors.weave \
|
|
68
67
|
-p haystack_integrations.tracing.weave {args}"""
|
|
69
68
|
|
|
@@ -74,7 +73,6 @@ check_untyped_defs = true
|
|
|
74
73
|
disallow_incomplete_defs = true
|
|
75
74
|
|
|
76
75
|
[tool.ruff]
|
|
77
|
-
target-version = "py39"
|
|
78
76
|
line-length = 120
|
|
79
77
|
|
|
80
78
|
[tool.ruff.lint]
|
|
@@ -121,10 +119,6 @@ ignore = [
|
|
|
121
119
|
"PLR0913",
|
|
122
120
|
"PLR0915",
|
|
123
121
|
]
|
|
124
|
-
unfixable = [
|
|
125
|
-
# Don't touch unused imports
|
|
126
|
-
"F401",
|
|
127
|
-
]
|
|
128
122
|
|
|
129
123
|
[tool.ruff.lint.isort]
|
|
130
124
|
known-first-party = ["haystack_integrations"]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
3
|
from haystack import component, default_from_dict, default_to_dict, logging, tracing
|
|
4
4
|
|
|
5
5
|
from haystack_integrations.tracing.weave import WeaveTracer
|
|
6
|
-
from weave.trace.
|
|
6
|
+
from weave.trace.settings import UserSettings
|
|
7
7
|
|
|
8
8
|
logger = logging.getLogger(__name__)
|
|
9
9
|
|
|
@@ -71,7 +71,7 @@ class WeaveConnector:
|
|
|
71
71
|
|
|
72
72
|
"""
|
|
73
73
|
|
|
74
|
-
def __init__(self, pipeline_name: str, weave_init_kwargs:
|
|
74
|
+
def __init__(self, pipeline_name: str, weave_init_kwargs: dict[str, Any] | None = None) -> None:
|
|
75
75
|
"""
|
|
76
76
|
Initialize WeaveConnector.
|
|
77
77
|
|
|
@@ -80,7 +80,7 @@ class WeaveConnector:
|
|
|
80
80
|
"""
|
|
81
81
|
self.pipeline_name = pipeline_name
|
|
82
82
|
self.weave_init_kwargs = weave_init_kwargs or {}
|
|
83
|
-
self.tracer:
|
|
83
|
+
self.tracer: WeaveTracer | None = None
|
|
84
84
|
|
|
85
85
|
def warm_up(self) -> None:
|
|
86
86
|
"""Initialize the WeaveTracer."""
|
|
@@ -101,9 +101,9 @@ class WeaveConnector:
|
|
|
101
101
|
Dictionary with all the necessary information to recreate this component.
|
|
102
102
|
"""
|
|
103
103
|
weave_init_kwargs = self.weave_init_kwargs.copy()
|
|
104
|
-
|
|
105
|
-
if isinstance(
|
|
106
|
-
weave_init_kwargs["
|
|
104
|
+
settings = weave_init_kwargs.get("settings", None)
|
|
105
|
+
if isinstance(settings, UserSettings):
|
|
106
|
+
weave_init_kwargs["settings"] = settings.model_dump(mode="json", exclude_defaults=True)
|
|
107
107
|
|
|
108
108
|
return default_to_dict(self, pipeline_name=self.pipeline_name, weave_init_kwargs=weave_init_kwargs)
|
|
109
109
|
|
|
@@ -116,12 +116,7 @@ class WeaveConnector:
|
|
|
116
116
|
:returns:
|
|
117
117
|
Deserialized component.
|
|
118
118
|
"""
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.get("weave_init_kwargs", {})
|
|
122
|
-
.get("autopatch_settings", None)
|
|
123
|
-
):
|
|
124
|
-
parsed_settings = AutopatchSettings.model_validate(autopatch_settings)
|
|
125
|
-
data["init_parameters"]["weave_init_kwargs"]["autopatch_settings"] = parsed_settings
|
|
119
|
+
# Weave's API accepts both dict and UserSettings objects for `settings`,
|
|
120
|
+
# so we can pass the raw settings dict directly without deserializing it
|
|
126
121
|
|
|
127
122
|
return default_from_dict(cls, data)
|
{weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/tracing/weave/tracer.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import contextlib
|
|
2
2
|
import os
|
|
3
3
|
from collections.abc import Iterator
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
from haystack import logging
|
|
7
7
|
from haystack.tracing import Span, Tracer
|
|
@@ -22,9 +22,7 @@ class WeaveSpan(Span):
|
|
|
22
22
|
that describe the operation.
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
|
-
def __init__(
|
|
26
|
-
self, call: Optional[Call] = None, parent: Optional[Call] = None, operation: Optional[str] = None
|
|
27
|
-
) -> None:
|
|
25
|
+
def __init__(self, call: Call | None = None, parent: Call | None = None, operation: str | None = None) -> None:
|
|
28
26
|
self._call = call
|
|
29
27
|
self._parent = parent
|
|
30
28
|
self._operation = operation
|
|
@@ -86,12 +84,10 @@ class WeaveTracer(Tracer):
|
|
|
86
84
|
)
|
|
87
85
|
|
|
88
86
|
self._client = weave.init(project_name, **weave_init_kwargs)
|
|
89
|
-
self._current_span:
|
|
87
|
+
self._current_span: WeaveSpan | None = None
|
|
90
88
|
|
|
91
89
|
@staticmethod
|
|
92
|
-
def create_call(
|
|
93
|
-
attributes: dict, client: WeaveClient, parent_span: Union[WeaveSpan, None], operation_name: str
|
|
94
|
-
) -> Call:
|
|
90
|
+
def create_call(attributes: dict, client: WeaveClient, parent_span: WeaveSpan | None, operation_name: str) -> Call:
|
|
95
91
|
comp_name = attributes.pop("haystack.component.name", "")
|
|
96
92
|
comp_type = attributes.pop("haystack.component.type", "")
|
|
97
93
|
comp_input = attributes.pop("haystack.component.input", {})
|
|
@@ -104,18 +100,16 @@ class WeaveTracer(Tracer):
|
|
|
104
100
|
)
|
|
105
101
|
return call
|
|
106
102
|
|
|
107
|
-
def current_span(self) ->
|
|
103
|
+
def current_span(self) -> Span | None:
|
|
108
104
|
"""Get the current active span."""
|
|
109
105
|
return self._current_span
|
|
110
106
|
|
|
111
107
|
@staticmethod
|
|
112
|
-
def _create_component_span(parent_span:
|
|
108
|
+
def _create_component_span(parent_span: WeaveSpan | None, operation_name: str) -> WeaveSpan:
|
|
113
109
|
"""Create a span for component runs with deferred call creation."""
|
|
114
110
|
return WeaveSpan(parent=parent_span.raw_span() if parent_span else None, operation=operation_name)
|
|
115
111
|
|
|
116
|
-
def _create_regular_span(
|
|
117
|
-
self, operation_name: str, tags: Optional[dict], parent_span: Optional[WeaveSpan]
|
|
118
|
-
) -> WeaveSpan:
|
|
112
|
+
def _create_regular_span(self, operation_name: str, tags: dict | None, parent_span: WeaveSpan | None) -> WeaveSpan:
|
|
119
113
|
"""Create a span for regular operations with immediate call creation."""
|
|
120
114
|
call = self._client.create_call(
|
|
121
115
|
op=operation_name,
|
|
@@ -124,7 +118,7 @@ class WeaveTracer(Tracer):
|
|
|
124
118
|
)
|
|
125
119
|
return WeaveSpan(call=call)
|
|
126
120
|
|
|
127
|
-
def _finish_component_call(self, span: WeaveSpan, parent_span:
|
|
121
|
+
def _finish_component_call(self, span: WeaveSpan, parent_span: WeaveSpan | None, operation_name: str) -> None:
|
|
128
122
|
"""Create and finish call for component runs."""
|
|
129
123
|
attributes = span.get_attributes()
|
|
130
124
|
call = self.create_call(
|
|
@@ -149,14 +143,14 @@ class WeaveTracer(Tracer):
|
|
|
149
143
|
output={key: coerce_tag_value(value) for key, value in pipeline_output.items()},
|
|
150
144
|
)
|
|
151
145
|
|
|
146
|
+
# the current implementation violates the Liskov Substitution Principle by using WeaveSpan instead of Span
|
|
147
|
+
# unfortunately, it seems hard to fix without rewriting the Tracer
|
|
152
148
|
@contextlib.contextmanager
|
|
153
|
-
def trace(
|
|
149
|
+
def trace( # type: ignore[override]
|
|
154
150
|
self,
|
|
155
151
|
operation_name: str,
|
|
156
|
-
tags:
|
|
157
|
-
|
|
158
|
-
# unfortunately, it seems hard to fix without rewriting the Tracer
|
|
159
|
-
parent_span: Optional[WeaveSpan] = None, # type: ignore[override]
|
|
152
|
+
tags: dict[str, Any] | None = None,
|
|
153
|
+
parent_span: WeaveSpan | None = None,
|
|
160
154
|
) -> Iterator[WeaveSpan]:
|
|
161
155
|
"""
|
|
162
156
|
A context manager that creates and manages spans for tracking operations in Weights & Biases Weave.
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from unittest.mock import patch
|
|
3
3
|
|
|
4
|
-
from weave.trace.autopatch import AutopatchSettings
|
|
5
|
-
|
|
6
4
|
from haystack_integrations.tracing.weave.tracer import WeaveSpan, WeaveTracer
|
|
7
5
|
|
|
8
6
|
|
|
@@ -40,13 +38,11 @@ class TestWeaveTracer:
|
|
|
40
38
|
mock_init.return_value = MockWeaveClient()
|
|
41
39
|
tracer = WeaveTracer(
|
|
42
40
|
project_name="test_project",
|
|
43
|
-
|
|
41
|
+
settings={"implicitly_patch_integrations": False},
|
|
44
42
|
)
|
|
45
43
|
assert tracer._client is not None
|
|
46
44
|
assert tracer._current_span is None
|
|
47
|
-
mock_init.assert_called_once_with(
|
|
48
|
-
"test_project", autopatch_settings=AutopatchSettings(disable_autopatch=True)
|
|
49
|
-
)
|
|
45
|
+
mock_init.assert_called_once_with("test_project", settings={"implicitly_patch_integrations": False})
|
|
50
46
|
|
|
51
47
|
def test_create_new_span(self):
|
|
52
48
|
with patch("weave.init") as mock_init:
|
|
@@ -8,7 +8,7 @@ from haystack import Pipeline, component
|
|
|
8
8
|
from haystack.components.builders import PromptBuilder
|
|
9
9
|
from haystack.core.errors import PipelineRuntimeError
|
|
10
10
|
from haystack.tracing import tracer as haystack_configured_tracer
|
|
11
|
-
from weave.trace.
|
|
11
|
+
from weave.trace.settings import UserSettings
|
|
12
12
|
|
|
13
13
|
from haystack_integrations.components.connectors.weave import WeaveConnector
|
|
14
14
|
from haystack_integrations.tracing.weave import WeaveTracer
|
|
@@ -66,12 +66,14 @@ class TestWeaveConnector:
|
|
|
66
66
|
"""Test that WeaveConnector can be serialized and deserialized correctly"""
|
|
67
67
|
connector = WeaveConnector(
|
|
68
68
|
pipeline_name="test_pipeline",
|
|
69
|
-
weave_init_kwargs={"
|
|
69
|
+
weave_init_kwargs={"settings": {"implicitly_patch_integrations": False}},
|
|
70
70
|
)
|
|
71
71
|
serialized: dict[str, Any] = connector.to_dict()
|
|
72
72
|
|
|
73
73
|
assert serialized["init_parameters"]["pipeline_name"] == "test_pipeline"
|
|
74
|
-
assert serialized["init_parameters"]["weave_init_kwargs"] == {
|
|
74
|
+
assert serialized["init_parameters"]["weave_init_kwargs"] == {
|
|
75
|
+
"settings": {"implicitly_patch_integrations": False}
|
|
76
|
+
}
|
|
75
77
|
assert "type" in serialized
|
|
76
78
|
assert serialized["type"] == "haystack_integrations.components.connectors.weave.weave_connector.WeaveConnector"
|
|
77
79
|
|
|
@@ -80,7 +82,29 @@ class TestWeaveConnector:
|
|
|
80
82
|
assert isinstance(deserialized, WeaveConnector)
|
|
81
83
|
assert deserialized.pipeline_name == "test_pipeline"
|
|
82
84
|
assert deserialized.tracer is None # tracer is only initialized with warm_up
|
|
83
|
-
assert deserialized.weave_init_kwargs == {"
|
|
85
|
+
assert deserialized.weave_init_kwargs == {"settings": {"implicitly_patch_integrations": False}}
|
|
86
|
+
|
|
87
|
+
def test_serialization_of_weave_init_kwargs_with_user_settings(self) -> None:
|
|
88
|
+
"""Test that WeaveConnector can be serialized and deserialized correctly with UserSettings"""
|
|
89
|
+
connector = WeaveConnector(
|
|
90
|
+
pipeline_name="test_pipeline",
|
|
91
|
+
weave_init_kwargs={"settings": UserSettings(implicitly_patch_integrations=False)},
|
|
92
|
+
)
|
|
93
|
+
serialized: dict[str, Any] = connector.to_dict()
|
|
94
|
+
|
|
95
|
+
assert serialized["init_parameters"]["pipeline_name"] == "test_pipeline"
|
|
96
|
+
assert serialized["init_parameters"]["weave_init_kwargs"] == {
|
|
97
|
+
"settings": {"implicitly_patch_integrations": False}
|
|
98
|
+
}
|
|
99
|
+
assert "type" in serialized
|
|
100
|
+
assert serialized["type"] == "haystack_integrations.components.connectors.weave.weave_connector.WeaveConnector"
|
|
101
|
+
|
|
102
|
+
deserialized = WeaveConnector.from_dict(serialized)
|
|
103
|
+
|
|
104
|
+
assert isinstance(deserialized, WeaveConnector)
|
|
105
|
+
assert deserialized.pipeline_name == "test_pipeline"
|
|
106
|
+
assert deserialized.tracer is None # tracer is only initialized with warm_up
|
|
107
|
+
assert deserialized.weave_init_kwargs == {"settings": {"implicitly_patch_integrations": False}}
|
|
84
108
|
|
|
85
109
|
def test_pipeline_tracing(self, mock_weave_client: Mock, sample_pipeline: Pipeline) -> None:
|
|
86
110
|
"""Test that pipeline operations are correctly traced"""
|
|
@@ -155,7 +179,7 @@ class TestWeaveConnector:
|
|
|
155
179
|
monkeypatch.setenv("HAYSTACK_CONTENT_TRACING_ENABLED", "true")
|
|
156
180
|
connector = WeaveConnector(
|
|
157
181
|
pipeline_name="test_pipeline",
|
|
158
|
-
weave_init_kwargs={"
|
|
182
|
+
weave_init_kwargs={"settings": {"implicitly_patch_integrations": False}},
|
|
159
183
|
)
|
|
160
184
|
assert connector.tracer is None
|
|
161
185
|
|
weave_haystack-1.0.0/PKG-INFO
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: weave-haystack
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: An integration of Weights & Biases Weave tracer with Haystack
|
|
5
|
-
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations
|
|
6
|
-
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/weights_and_biases_weave/README.md
|
|
7
|
-
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
8
|
-
Author-email: deepset GmbH <info@deepset.ai>
|
|
9
|
-
License-Expression: Apache-2.0
|
|
10
|
-
License-File: LICENSE.txt
|
|
11
|
-
Classifier: Development Status :: 4 - Beta
|
|
12
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
-
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
-
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
21
|
-
Requires-Python: >=3.9
|
|
22
|
-
Requires-Dist: haystack-ai
|
|
23
|
-
Requires-Dist: weave>=0.51.33
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
|
|
26
|
-
# weave-haystack
|
|
27
|
-
|
|
28
|
-
[](https://pypi.org/project/weave-haystack)
|
|
29
|
-
[](https://pypi.org/project/weave-haystack)
|
|
30
|
-
|
|
31
|
-
- [Installation](#installation)
|
|
32
|
-
- [Example](#example)
|
|
33
|
-
- [License](#license)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## Installation
|
|
37
|
-
|
|
38
|
-
```console
|
|
39
|
-
pip install weave-haystack
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Weave by Weights & Biases
|
|
43
|
-
|
|
44
|
-
### Example
|
|
45
|
-
|
|
46
|
-
You need to have a Weave account to use this feature. You can sign up for free at https://wandb.ai/site.
|
|
47
|
-
|
|
48
|
-
You then need to set the `WANDB_API_KEY:` environment variable with your Weights & Biases API key. You should find
|
|
49
|
-
your API key in https://wandb.ai/home when you are logged in.
|
|
50
|
-
|
|
51
|
-
You should then head to `https://wandb.ai/<user_name>/projects` and see the complete trace for your pipeline under
|
|
52
|
-
the pipeline name you specified, when creating the `WeaveConnector`.
|
|
53
|
-
|
|
54
|
-
You also need to have the `HAYSTACK_CONTENT_TRACING_ENABLED` environment variable set to `true`.
|
|
55
|
-
|
|
56
|
-
To use this connector simply add it to your pipeline without any connections, and it will automatically start
|
|
57
|
-
sending traces to Weights & Biases.
|
|
58
|
-
|
|
59
|
-
```python
|
|
60
|
-
import os
|
|
61
|
-
|
|
62
|
-
from haystack import Pipeline
|
|
63
|
-
from haystack.components.builders import ChatPromptBuilder
|
|
64
|
-
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
65
|
-
from haystack.dataclasses import ChatMessage
|
|
66
|
-
|
|
67
|
-
from haystack_integrations.components.connectors import WeaveConnector
|
|
68
|
-
|
|
69
|
-
os.environ["HAYSTACK_CONTENT_TRACING_ENABLED"] = "true"
|
|
70
|
-
|
|
71
|
-
pipe = Pipeline()
|
|
72
|
-
pipe.add_component("prompt_builder", ChatPromptBuilder())
|
|
73
|
-
pipe.add_component("llm", OpenAIChatGenerator(model="gpt-3.5-turbo"))
|
|
74
|
-
pipe.connect("prompt_builder.prompt", "llm.messages")
|
|
75
|
-
|
|
76
|
-
connector = WeaveConnector(pipeline_name="test_pipeline")
|
|
77
|
-
pipe.add_component("weave", connector)
|
|
78
|
-
|
|
79
|
-
messages = [
|
|
80
|
-
ChatMessage.from_system(
|
|
81
|
-
"Always respond in German even if some input data is in other languages."
|
|
82
|
-
),
|
|
83
|
-
ChatMessage.from_user("Tell me about {{location}}"),
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
response = pipe.run(
|
|
87
|
-
data={
|
|
88
|
-
"prompt_builder": {
|
|
89
|
-
"template_variables": {"location": "Berlin"},
|
|
90
|
-
"template": messages,
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
)
|
|
94
|
-
print(response["llm"]["replies"][0])
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## License
|
|
98
|
-
|
|
99
|
-
`weave-haystack` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
|
weave_haystack-1.0.0/README.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# weave-haystack
|
|
2
|
-
|
|
3
|
-
[](https://pypi.org/project/weave-haystack)
|
|
4
|
-
[](https://pypi.org/project/weave-haystack)
|
|
5
|
-
|
|
6
|
-
- [Installation](#installation)
|
|
7
|
-
- [Example](#example)
|
|
8
|
-
- [License](#license)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```console
|
|
14
|
-
pip install weave-haystack
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Weave by Weights & Biases
|
|
18
|
-
|
|
19
|
-
### Example
|
|
20
|
-
|
|
21
|
-
You need to have a Weave account to use this feature. You can sign up for free at https://wandb.ai/site.
|
|
22
|
-
|
|
23
|
-
You then need to set the `WANDB_API_KEY:` environment variable with your Weights & Biases API key. You should find
|
|
24
|
-
your API key in https://wandb.ai/home when you are logged in.
|
|
25
|
-
|
|
26
|
-
You should then head to `https://wandb.ai/<user_name>/projects` and see the complete trace for your pipeline under
|
|
27
|
-
the pipeline name you specified, when creating the `WeaveConnector`.
|
|
28
|
-
|
|
29
|
-
You also need to have the `HAYSTACK_CONTENT_TRACING_ENABLED` environment variable set to `true`.
|
|
30
|
-
|
|
31
|
-
To use this connector simply add it to your pipeline without any connections, and it will automatically start
|
|
32
|
-
sending traces to Weights & Biases.
|
|
33
|
-
|
|
34
|
-
```python
|
|
35
|
-
import os
|
|
36
|
-
|
|
37
|
-
from haystack import Pipeline
|
|
38
|
-
from haystack.components.builders import ChatPromptBuilder
|
|
39
|
-
from haystack.components.generators.chat import OpenAIChatGenerator
|
|
40
|
-
from haystack.dataclasses import ChatMessage
|
|
41
|
-
|
|
42
|
-
from haystack_integrations.components.connectors import WeaveConnector
|
|
43
|
-
|
|
44
|
-
os.environ["HAYSTACK_CONTENT_TRACING_ENABLED"] = "true"
|
|
45
|
-
|
|
46
|
-
pipe = Pipeline()
|
|
47
|
-
pipe.add_component("prompt_builder", ChatPromptBuilder())
|
|
48
|
-
pipe.add_component("llm", OpenAIChatGenerator(model="gpt-3.5-turbo"))
|
|
49
|
-
pipe.connect("prompt_builder.prompt", "llm.messages")
|
|
50
|
-
|
|
51
|
-
connector = WeaveConnector(pipeline_name="test_pipeline")
|
|
52
|
-
pipe.add_component("weave", connector)
|
|
53
|
-
|
|
54
|
-
messages = [
|
|
55
|
-
ChatMessage.from_system(
|
|
56
|
-
"Always respond in German even if some input data is in other languages."
|
|
57
|
-
),
|
|
58
|
-
ChatMessage.from_user("Tell me about {{location}}"),
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
response = pipe.run(
|
|
62
|
-
data={
|
|
63
|
-
"prompt_builder": {
|
|
64
|
-
"template_variables": {"location": "Berlin"},
|
|
65
|
-
"template": messages,
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
print(response["llm"]["replies"][0])
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## License
|
|
73
|
-
|
|
74
|
-
`weave-haystack` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
loaders:
|
|
2
|
-
- type: haystack_pydoc_tools.loaders.CustomPythonLoader
|
|
3
|
-
search_path: [../src]
|
|
4
|
-
modules: [
|
|
5
|
-
"haystack_integrations.components.connectors.weave.weave_connector",
|
|
6
|
-
"haystack_integrations.tracing.weave.tracer",
|
|
7
|
-
]
|
|
8
|
-
ignore_when_discovered: ["__init__"]
|
|
9
|
-
processors:
|
|
10
|
-
- type: filter
|
|
11
|
-
expression:
|
|
12
|
-
documented_only: true
|
|
13
|
-
do_not_filter_modules: false
|
|
14
|
-
skip_empty_modules: true
|
|
15
|
-
- type: smart
|
|
16
|
-
- type: crossref
|
|
17
|
-
renderer:
|
|
18
|
-
type: haystack_pydoc_tools.renderers.ReadmeIntegrationRenderer
|
|
19
|
-
excerpt: Weights & Bias integration for Haystack
|
|
20
|
-
category_slug: integrations-api
|
|
21
|
-
title: weights and bias
|
|
22
|
-
slug: integrations-weights-bias
|
|
23
|
-
order: 260
|
|
24
|
-
markdown:
|
|
25
|
-
descriptive_class_title: false
|
|
26
|
-
classdef_code_block: false
|
|
27
|
-
descriptive_module_title: true
|
|
28
|
-
add_method_class_prefix: true
|
|
29
|
-
add_member_class_prefix: false
|
|
30
|
-
filename: _readme_weights_and_bias.md
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{weave_haystack-1.0.0 → weave_haystack-3.0.0}/src/haystack_integrations/tracing/weave/__init__.py
RENAMED
|
File without changes
|