c56bef871b
Sync docs with Docusaurus / sync (push) Waiting to run
Tests / Check if changed (push) Waiting to run
Tests / format (push) Blocked by required conditions
Tests / check-imports (push) Blocked by required conditions
Tests / Unit / macos-latest (push) Blocked by required conditions
Tests / Unit / ubuntu-latest (push) Blocked by required conditions
Tests / Unit / windows-latest (push) Blocked by required conditions
Tests / mypy (push) Blocked by required conditions
Tests / Integration / ubuntu-latest (push) Blocked by required conditions
Tests / Integration / macos-latest (push) Blocked by required conditions
Tests / Integration / windows-latest (push) Blocked by required conditions
Tests / notify-slack-on-failure (push) Blocked by required conditions
Tests / Mark tests as completed (push) Blocked by required conditions
Docker image release / Build base image (push) Waiting to run
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import warnings
|
|
|
|
import pytest
|
|
|
|
from haystack.dataclasses.breakpoints import Breakpoint, PipelineSnapshot, PipelineState
|
|
|
|
|
|
def test_pipeline_state_no_warning_on_init():
|
|
with warnings.catch_warnings():
|
|
warnings.simplefilter("error", Warning)
|
|
PipelineState(inputs={}, component_visits={}, pipeline_outputs={})
|
|
|
|
|
|
def test_pipeline_state_warn_on_inplace_mutation():
|
|
state = PipelineState(inputs={}, component_visits={}, pipeline_outputs={})
|
|
with pytest.warns(Warning, match="dataclasses.replace"):
|
|
state.inputs = {"new": "value"}
|
|
|
|
|
|
def test_pipeline_snapshot_no_warning_on_init():
|
|
state = PipelineState(inputs={}, component_visits={"comp": 1}, pipeline_outputs={})
|
|
bp = Breakpoint(component_name="comp")
|
|
with warnings.catch_warnings():
|
|
warnings.simplefilter("error", Warning)
|
|
PipelineSnapshot(original_input_data={}, ordered_component_names=["comp"], pipeline_state=state, break_point=bp)
|
|
|
|
|
|
def test_pipeline_snapshot_warn_on_inplace_mutation():
|
|
state = PipelineState(inputs={}, component_visits={"comp": 1}, pipeline_outputs={})
|
|
bp = Breakpoint(component_name="comp")
|
|
snap = PipelineSnapshot(
|
|
original_input_data={}, ordered_component_names=["comp"], pipeline_state=state, break_point=bp
|
|
)
|
|
with pytest.warns(Warning, match="dataclasses.replace"):
|
|
snap.original_input_data = {"new": "data"}
|