Skip to content

feat: aggregations in structured views #524

feat: aggregations in structured views

feat: aggregations in structured views #524

GitHub Actions / JUnit Test Report failed Aug 16, 2024 in 0s

101 tests run, 82 passed, 0 skipped, 19 failed.

Annotations

Check failure on line 24 in tests/integration/test_llm_options.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_llm_options.test_llm_options_propagation

ValueError: Builder function is required for views with non-default arguments
Raw output
@pytest.mark.asyncio
    async def test_llm_options_propagation():
        default_options = MockLLMOptions(mock_property1=1, mock_property2="default mock")
        custom_options = MockLLMOptions(mock_property1=2)
        expected_options = MockLLMOptions(mock_property1=2, mock_property2="default mock")
    
        llm = MockLLM(default_options=default_options)
        llm.client.call = AsyncMock(return_value="MockView1")
    
        collection = create_collection(
            name="test_collection",
            llm=llm,
        )
        collection.n_retries = 0
>       collection.add(MockView1)

tests/integration/test_llm_options.py:24: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fee59e430>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_list

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed1b4ee0>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_get

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed1a6040>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_get_not_found

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed17fb80>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_add

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed1a2910>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_add_custom_name

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed1913a0>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_add_with_builder

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed15aee0>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_error_when_view_already_registered

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed191460>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_error_when_view_with_non_default_args

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed08e220>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_error_when_view_builder_with_wrong_return_type

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed098f40>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_error_when_view_incorrect_builder

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed08e1f0>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 302 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_ask_view_selection_single_view

ValueError: Builder function is required for views with non-default arguments
Raw output
async def test_ask_view_selection_single_view() -> None:
        """
        Tests that the ask method select view correctly when there is only one view
        """
        collection = Collection(
            "foo",
            view_selector=MockViewSelector(""),
            llm=MockLLM(),
            nl_responder=AsyncMock(),
            event_handlers=[],
        )
>       collection.add(MockViewWithResults)

tests/unit/test_collection.py:302: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed0948b0>
view = <class 'tests.unit.test_collection.MockViewWithResults'>, builder = None
name = 'MockViewWithResults'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 321 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_ask_view_selection_multiple_views

ValueError: Builder function is required for views with non-default arguments
Raw output
async def test_ask_view_selection_multiple_views() -> None:
        """
        Tests that the ask method select view correctly when there are multiple views
        """
        collection = Collection(
            "foo",
            view_selector=MockViewSelector("MockViewWithResults"),
            llm=MockLLM(),
            nl_responder=AsyncMock(),
            event_handlers=[],
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:321: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed0565b0>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_get_similarity_indexes

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed0ba790>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_update_similarity_indexes

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed0b1640>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 149 in tests/unit/test_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_collection.test_update_similarity_indexes_error

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="collection")
    def mock_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_collection.py:149: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed0a9040>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 79 in tests/unit/test_fallback_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_fallback_collection.test_no_fallback_collection

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="base_collection")
    def mock_base_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_fallback_collection.py:79: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed0fe790>
view = <class 'tests.unit.test_fallback_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 79 in tests/unit/test_fallback_collection.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_fallback_collection

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture(name="base_collection")
    def mock_base_collection() -> Collection:
        """
        Returns a collection with two mock views
        """
        collection = dbally.create_collection(
            "foo",
            llm=MockLLM(),
            view_selector=MockViewSelector("MockView1"),
            nl_responder=AsyncMock(),
        )
>       collection.add(MockView1)

tests/unit/test_fallback_collection.py:79: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fed0f24f0>
view = <class 'tests.unit.test_fallback_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError

Check failure on line 28 in tests/unit/test_view_selector.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_view_selector.test_view_selection

failed on setup with "ValueError: Builder function is required for views with non-default arguments"
Raw output
@pytest.fixture
    def views() -> Dict[str, str]:
        """Return a map of view names + view descriptions to be used in the test."""
        mock_collection = dbally.create_collection("mock_collection", llm=MockLLM())
>       mock_collection.add(MockView1)

tests/unit/test_view_selector.py:28: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <dbally.collection.collection.Collection object at 0x7f6fecfd6c70>
view = <class 'tests.unit.test_collection.MockView1'>, builder = None
name = 'MockView1'

    def add(self, view: Type[T], builder: Optional[Callable[[], T]] = None, name: Optional[str] = None) -> None:
        """
        Register new [View](views/index.md) that will be available to query via the collection.
    
        Args:
            view: A class inheriting from BaseView. Object of this type will be initialized during\
            query execution. We expect Class instead of object, as otherwise Views must have been implemented\
            stateless, which would be cumbersome.
            builder: Optional factory function that will be used to create the View instance. Use it when you\
            need to pass outcome of API call or database connection to the view, and it can change over time.
            name: Custom name of the view (defaults to the name of the class).
    
        Raises:
            ValueError: if view with the given name is already registered or views class possess some non-default\
            arguments.
    
        **Example** of custom `builder` usage
    
        ```python
            def build_dogs_df_view():
                dogs_df = request.get("https://dog.ceo/api/breeds/list")
                return DogsDFView(dogs_df)
    
            collection.add(DogsDFView, build_dogs_df_view)
        ```
        """
        if name is None:
            name = view.__name__
    
        if name in self._views or name in self._builders:
            raise ValueError(f"View with name {name} is already registered")
    
        non_default_args = any(
            p.default == inspect.Parameter.empty for p in inspect.signature(view).parameters.values()
        )
        if non_default_args and builder is None:
>           raise ValueError("Builder function is required for views with non-default arguments")
E           ValueError: Builder function is required for views with non-default arguments

src/dbally/collection/collection.py:112: ValueError