Skip to content

Commit ab9f1a9

Browse files
authored
fix!: Weave - move Connector, fix types, add py.typed (#2038)
* draft * more fixes * fix example * workflow * fix pydoc config * fix labeler
1 parent 4157b0b commit ab9f1a9

11 files changed

Lines changed: 24 additions & 36 deletions

File tree

.github/labeler.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ integration:weaviate:
174174
- any-glob-to-any-file: "integrations/weaviate/**/*"
175175
- any-glob-to-any-file: ".github/workflows/weaviate.yml"
176176

177-
integration:weight_bias:
177+
integration:weights_and_biases_weave:
178178
- changed-files:
179-
- any-glob-to-any-file: "integrations/weight_bias/**/*"
180-
- any-glob-to-any-file: ".github/workflows/weight_bias.yml"
179+
- any-glob-to-any-file: "integrations/weights_and_biases_weave/**/*"
180+
- any-glob-to-any-file: ".github/workflows/weights_and_biases_weave.yml"
181181

182182
# Topics
183183
topic:CI:

.github/workflows/weights_and_biases_weave.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ jobs:
4646
- name: Install Hatch
4747
run: pip install --upgrade hatch
4848

49-
# TODO: Once this integration is properly typed, use hatch run test:types
50-
# https://github.com/deepset-ai/haystack-core-integrations/issues/1771
5149
- name: Lint
5250
if: matrix.python-version == '3.9' && runner.os == 'Linux'
53-
run: hatch run fmt-check && hatch run lint:typing
51+
run: hatch run fmt-check && hatch run test:types
5452

5553
- name: Generate docs
5654
if: matrix.python-version == '3.9' && runner.os == 'Linux'

integrations/weights_and_biases_weave/example/hybrid_retrieval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from haystack.components.retrievers.in_memory import InMemoryBM25Retriever, InMemoryEmbeddingRetriever
66
from haystack.document_stores.in_memory import InMemoryDocumentStore
77

8-
from haystack_integrations.components.connectors import WeaveConnector
8+
from haystack_integrations.components.connectors.weave import WeaveConnector
99

1010

1111
def index():

integrations/weights_and_biases_weave/pydoc/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ loaders:
22
- type: haystack_pydoc_tools.loaders.CustomPythonLoader
33
search_path: [../src]
44
modules: [
5-
"haystack_integrations.components.connectors.weave_connector",
5+
"haystack_integrations.components.connectors.weave.weave_connector",
66
"haystack_integrations.tracing.weave.tracer",
77
]
88
ignore_when_discovered: ["__init__"]

integrations/weights_and_biases_weave/pyproject.toml

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,14 @@ unit = 'pytest -m "not integration" {args:tests}'
6464
integration = 'pytest -m "integration" {args:tests}'
6565
all = 'pytest {args:tests}'
6666
cov-retry = 'all --cov=haystack_integrations --reruns 3 --reruns-delay 30 -x'
67-
types = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
68-
69-
# TODO: remove lint environment once this integration is properly typed
70-
# test environment should be used instead
71-
# https://github.com/deepset-ai/haystack-core-integrations/issues/1771
72-
[tool.hatch.envs.lint]
73-
installer = "uv"
74-
detached = true
75-
dependencies = ["pip", "mypy>=1.0.0", "ruff>=0.0.243"]
76-
[tool.hatch.envs.lint.scripts]
77-
typing = "mypy --install-types --non-interactive --explicit-package-bases {args:src/ tests}"
67+
types = """mypy -p haystack_integrations.components.connectors.weave \
68+
-p haystack_integrations.tracing.weave {args}"""
7869

70+
[tool.mypy]
71+
install_types = true
72+
non_interactive = true
73+
check_untyped_defs = true
74+
disallow_incomplete_defs = true
7975

8076
[tool.ruff]
8177
target-version = "py39"
@@ -155,14 +151,3 @@ exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
155151
markers = [
156152
"integration: integration tests"
157153
]
158-
159-
[[tool.mypy.overrides]]
160-
module = [
161-
"grpc",
162-
"haystack.*",
163-
"haystack_integrations.*",
164-
"numpy",
165-
"pytest.*",
166-
"weave.*"
167-
]
168-
ignore_missing_imports = true

integrations/weights_and_biases_weave/src/haystack_integrations/components/connectors/py.typed

Whitespace-only changes.

integrations/weights_and_biases_weave/src/haystack_integrations/components/connectors/__init__.py renamed to integrations/weights_and_biases_weave/src/haystack_integrations/components/connectors/weave/__init__.py

File renamed without changes.

integrations/weights_and_biases_weave/src/haystack_integrations/components/connectors/weave_connector.py renamed to integrations/weights_and_biases_weave/src/haystack_integrations/components/connectors/weave/weave_connector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Any, Optional
22

33
from haystack import component, default_from_dict, default_to_dict, logging, tracing
4-
from weave.trace.autopatch import AutopatchSettings
54

65
from haystack_integrations.tracing.weave import WeaveTracer
6+
from weave.trace.autopatch import AutopatchSettings
77

88
logger = logging.getLogger(__name__)
99

integrations/weights_and_biases_weave/src/haystack_integrations/tracing/py.typed

Whitespace-only changes.

integrations/weights_and_biases_weave/src/haystack_integrations/tracing/weave/tracer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_correlation_data_for_logs(self) -> dict[str, Any]:
5353
return {}
5454
return {"weave.call_id": self._call.id, "weave.run_id": getattr(self._call, "run_id", "")}
5555

56-
def set_call(self, call: "weave.Call") -> None:
56+
def set_call(self, call: Call) -> None:
5757
self._call = call
5858

5959
def get_attributes(self) -> dict[str, Any]:
@@ -151,7 +151,12 @@ def _finish_regular_call(self, span: WeaveSpan) -> None:
151151

152152
@contextlib.contextmanager
153153
def trace(
154-
self, operation_name: str, tags: Optional[dict[str, Any]] = None, parent_span: Optional[WeaveSpan] = None
154+
self,
155+
operation_name: str,
156+
tags: Optional[dict[str, Any]] = None,
157+
# the current implementation violates the Liskov Substitution Principle by using WeaveSpan instead of Span
158+
# unfortunately, it seems hard to fix without rewriting the Tracer
159+
parent_span: Optional[WeaveSpan] = None, # type: ignore[override]
155160
) -> Iterator[WeaveSpan]:
156161
"""
157162
A context manager that creates and manages spans for tracking operations in Weights & Biases Weave.

0 commit comments

Comments
 (0)