Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions deepset_cloud_sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,9 @@ class PipelineConfig(BaseConfig):
"""

inputs: PipelineInputs = Field(
default_factory=PipelineInputs,
description=("Pipeline input configuration. Use `PipelineInputs` model to define the inputs."),
)
outputs: PipelineOutputs = Field(
default_factory=PipelineOutputs,
description=("Pipeline output configuration. Use `PipelineOutputs` model to define the outputs."),
)
pipeline_output_type: PipelineOutputType | None = Field(
Expand Down
2 changes: 2 additions & 0 deletions deepset_cloud_sdk/workflows/sync_client/pipeline_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def import_into_deepset(self, pipeline: PipelineProtocol, config: IndexConfig |
"""
try:
loop = asyncio.get_event_loop()
if loop.is_closed():
raise RuntimeError("Event loop is closed")
# do not close if event loop already exists, e.g. in Jupyter notebooks
should_close = False
except RuntimeError:
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ deepset-cloud = "deepset_cloud_sdk.cli:run_packaged"

[dependency-groups]
test = [
"pytest-cov==4.0.0",
"pytest==7.3.1",
"pytest-asyncio==0.21.0",
"pytest-cov==7.0.0",
"pytest==8.4.2",
"pytest-asyncio==1.2.0",
"haystack-ai>=2.13.2", # only for testing
"respx==0.22.0",
"sniffio>=1.3.1",
]
code-quality = [
"ruff==0.8.4",
"mypy==1.1.1",
"pre-commit==2.20.0",
"types-aiofiles==23.1.0.2",
"ruff==0.14.7",
"mypy==1.19.0",
"pre-commit==4.3.0",
"types-aiofiles==25.1.0.20251011",
"types-tabulate==0.9.0.20241207",
]

Expand Down
24 changes: 12 additions & 12 deletions tests/integration/service/test_integration_files_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ async def test_direct_upload_path(self, integration_config: CommonConfig, worksp

for file in files:
if file.name in names_of_uploaded_files:
assert (
file.meta.get("source") == "msmarco"
), f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
assert file.meta.get("source") == "msmarco", (
f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
)

async def test_direct_upload_path_multiple_file_types(
self, integration_config: CommonConfig, workspace_name: str
Expand Down Expand Up @@ -91,9 +91,9 @@ async def test_direct_upload_path_multiple_file_types(

for file in uploaded_files:
if file.name in local_file_names:
assert (
file.meta.get("source") == "multiple file types"
), f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
assert file.meta.get("source") == "multiple file types", (
f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
)

async def test_async_upload(
self, integration_config: CommonConfig, workspace_name: str, monkeypatch: MonkeyPatch
Expand Down Expand Up @@ -135,9 +135,9 @@ async def test_async_upload(

for file in uploaded_files:
if file.name in local_file_names:
assert (
file.meta.get("source") == "msmarco"
), f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
assert file.meta.get("source") == "msmarco", (
f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
)

async def test_async_upload_multiple_file_types(
self, integration_config: CommonConfig, workspace_name: str, monkeypatch: MonkeyPatch
Expand Down Expand Up @@ -189,9 +189,9 @@ async def test_async_upload_multiple_file_types(

for file in uploaded_files:
if file.name in local_file_names:
assert (
file.meta.get("source") == "multiple file types"
), f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
assert file.meta.get("source") == "multiple file types", (
f"Metadata was not uploaded correctly for file '{file.name}': {file.meta}"
)

# Make sure that the metadata for File00.txt and file00.txt are mapped correctly
File00_metadata = next((file.meta for file in uploaded_files if file.name == "File00.txt"), None)
Expand Down
17 changes: 1 addition & 16 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from uuid import UUID

import pytest
import structlog
from typer.testing import CliRunner

__version__ = version("deepset-cloud-sdk")
Expand All @@ -23,31 +22,17 @@
from deepset_cloud_sdk.models import UserInfo
from deepset_cloud_sdk.workflows.sync_client.files import download as sync_download

logger = structlog.get_logger(__name__)
runner = CliRunner()


class TestCLIMethods:
@patch("deepset_cloud_sdk.workflows.sync_client.files.async_upload")
def test_uploading(self, async_upload_mock: AsyncMock) -> None:
# Configure logger to output to stdout and avoid interference with other tests
structlog.configure(
processors=[
structlog.processors.UnicodeDecoder(),
structlog.processors.format_exc_info,
structlog.dev.ConsoleRenderer(),
],
wrapper_class=structlog.BoundLogger,
context_class=dict,
logger_factory=structlog.PrintLoggerFactory(),
cache_logger_on_first_use=True,
)

def log_upload_folder_mock(
*args: Any,
**kwargs: Any,
) -> None:
logger.info("Fake log line")
print("Fake log line")

async_upload_mock.side_effect = log_upload_folder_mock
result = runner.invoke(cli_app, ["upload", "./test/data/upload_folder/example.txt"])
Expand Down
1 change: 1 addition & 0 deletions tests/unit/workflows/sync_client/test_pipeline_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def test_import_into_deepset_with_existing_event_loop(
)

mock_loop = Mock()
mock_loop.is_closed.return_value = False
mock_loop.run_until_complete.return_value = None
mock_loop.close = Mock()

Expand Down
21 changes: 13 additions & 8 deletions tests/unit/workflows/sync_client/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
from asyncio import AbstractEventLoop
import asyncio
from typing import AsyncIterator

from deepset_cloud_sdk.workflows.sync_client.utils import iter_over_async


def test_iter_over_async(event_loop: AbstractEventLoop) -> None:
async def async_generator() -> AsyncIterator[int]:
yield 1
yield 2
yield 3
def test_iter_over_async() -> None:
loop = asyncio.new_event_loop()
try:

sync_generator = iter_over_async(async_generator(), event_loop)
assert list(sync_generator) == [1, 2, 3]
async def async_generator() -> AsyncIterator[int]:
yield 1
yield 2
yield 3

sync_generator = iter_over_async(async_generator(), loop)
assert list(sync_generator) == [1, 2, 3]
finally:
loop.close()
Loading
Loading