Skip to content

Commit

Permalink
ci: Skip collection of test_json_schema.py to fix CI failures (#7353)
Browse files Browse the repository at this point in the history
* Skip collection of test_json_schema.py to fix CI failures

* mock chroma instance

* revert

---------

Co-authored-by: Massimiliano Pippi <[email protected]>
  • Loading branch information
2 people authored and anakin87 committed Apr 8, 2024
1 parent 7e59a7f commit 9c7425a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
10 changes: 9 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
from pathlib import Path
from test.tracing.utils import SpyingTracer
from typing import Generator
from unittest.mock import Mock, patch

Expand All @@ -9,7 +10,6 @@

from haystack import tracing
from haystack.testing.test_utils import set_all_seeds
from test.tracing.utils import SpyingTracer

set_all_seeds(0)

Expand Down Expand Up @@ -82,3 +82,11 @@ def spying_tracer() -> Generator[SpyingTracer, None, None]:

# Make sure to disable tracing after the test to avoid affecting other tests
tracing.disable_tracing()


# Collecting this test is causing issues when running tests in CI
# as it's indirectly importing jsonschema which for some reason
# is causing collection to fail.
# See this issue:
# https://github.com/python-jsonschema/jsonschema/issues/1236
collect_ignore = ["components/validators/test_json_schema.py"]
5 changes: 3 additions & 2 deletions test/core/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,9 @@ def test_describe_no_outputs():

def test_from_template(monkeypatch):
monkeypatch.setenv("OPENAI_API_KEY", "fake_key")
pipe = Pipeline.from_template(PredefinedPipeline.INDEXING)
assert pipe.get_component("cleaner")
with patch("haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore"):
pipe = Pipeline.from_template(PredefinedPipeline.INDEXING)
assert pipe.get_component("cleaner")


def test_walk_pipeline_with_no_cycles():
Expand Down
24 changes: 13 additions & 11 deletions test/core/pipeline/test_templates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import tempfile
from unittest import mock

import pytest

Expand Down Expand Up @@ -46,14 +47,15 @@ def test_from_predefined(self):
# Building a pipeline directly using all default components specified in a predefined or custom template.
def test_build_pipeline_with_default_components(self, monkeypatch):
monkeypatch.setenv("OPENAI_API_KEY", "fake_key")
rendered = PipelineTemplate.from_predefined(PredefinedPipeline.INDEXING).render()
pipeline = Pipeline.loads(rendered)

# pipeline has components
assert pipeline.get_component("cleaner")
assert pipeline.get_component("writer")
assert pipeline.get_component("embedder")

# pipeline should have inputs and outputs
assert len(pipeline.inputs()) > 0
assert len(pipeline.outputs()) > 0
with mock.patch("haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore"):
rendered = PipelineTemplate.from_predefined(PredefinedPipeline.INDEXING).render()
pipeline = Pipeline.loads(rendered)

# pipeline has components
assert pipeline.get_component("cleaner")
assert pipeline.get_component("writer")
assert pipeline.get_component("embedder")

# pipeline should have inputs and outputs
assert len(pipeline.inputs()) > 0
assert len(pipeline.outputs()) > 0

0 comments on commit 9c7425a

Please sign in to comment.