|
5 | 5 | # pylint: disable=wrong-import-order,wrong-import-position,ungrouped-imports |
6 | 6 | # ruff: noqa: I001 |
7 | 7 |
|
| 8 | +import inspect |
8 | 9 | from dataclasses import dataclass |
9 | 10 | from typing import Any, Optional, Union |
10 | 11 |
|
@@ -285,7 +286,13 @@ def run( # noqa: PLR0915 |
285 | 286 | "snapshot": snapshot, |
286 | 287 | **kwargs, |
287 | 288 | } |
288 | | - self._runtime_checks(break_point=break_point, snapshot=snapshot) |
| 289 | + # The PR https://github.com/deepset-ai/haystack/pull/9987 removed the unused snapshot parameter from |
| 290 | + # _runtime_checks. This change will be released in Haystack 2.20.0. |
| 291 | + # To maintain compatibility with Haystack 2.19 we check the number of parameters and call accordingly. |
| 292 | + if len(inspect.signature(self._runtime_checks).parameters) == 2: |
| 293 | + self._runtime_checks(break_point, snapshot) |
| 294 | + else: |
| 295 | + self._runtime_checks(break_point) # type: ignore[call-arg] # pylint: disable=no-value-for-parameter |
289 | 296 |
|
290 | 297 | if snapshot: |
291 | 298 | exe_context = self._initialize_from_snapshot( |
@@ -472,7 +479,13 @@ async def run_async( |
472 | 479 | "snapshot": snapshot, |
473 | 480 | **kwargs, |
474 | 481 | } |
475 | | - self._runtime_checks(break_point=break_point, snapshot=snapshot) |
| 482 | + # The PR https://github.com/deepset-ai/haystack/pull/9987 removed the unused snapshot parameter from |
| 483 | + # _runtime_checks. This change will be released in Haystack 2.20.0. |
| 484 | + # To maintain compatibility with Haystack 2.19 we check the number of parameters and call accordingly. |
| 485 | + if len(inspect.signature(self._runtime_checks).parameters) == 2: |
| 486 | + self._runtime_checks(break_point, snapshot) |
| 487 | + else: |
| 488 | + self._runtime_checks(break_point) # type: ignore[call-arg] # pylint: disable=no-value-for-parameter |
476 | 489 |
|
477 | 490 | if snapshot: |
478 | 491 | exe_context = self._initialize_from_snapshot( |
|
0 commit comments