Skip to content

Conversation

@dbczumar
Copy link
Collaborator

Fix additional evaluation display failures for non-dict objects

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
Signed-off-by: dbczumar <corey.zumar@databricks.com>
@dbczumar dbczumar requested a review from okhat November 18, 2024 18:39
Comment on lines +133 to +138
(
lambda text: Predict("text: str -> entities: List[Dict[str, str]]")(text=text).entities,
dspy.Example(text="United States", entities=[{"name": "United States", "type": "location"}]).with_inputs(
"text"
),
),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails on main with:

    def merge_dicts(d1, d2) -> dict:
        merged = {}
        for k, v in d1.items():
            if k in d2:
                merged[f"example_{k}"] = v
            else:
                merged[k] = v

>       for k, v in d2.items():
E       AttributeError: 'list' object has no attribute 'items'

../../dspy/evaluate/evaluate.py:204: AttributeError
============================================================= warnings summary =============================================================
../../../miniconda3/envs/default/lib/python3.10/site-packages/pydantic/_internal/_config.py:291
  /Users/corey.zumar/miniconda3/envs/default/lib/python3.10/site-packages/pydantic/_internal/_config.py:291: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.9/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

../../../miniconda3/envs/default/lib/python3.10/site-packages/wandb/env.py:16
  /Users/corey.zumar/miniconda3/envs/default/lib/python3.10/site-packages/wandb/env.py:16: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    from distutils.util import strtobool

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================= short test summary info ==========================================================
FAILED test_evaluate.py::test_evaluate_display_table[False-True-program_with_example0] - AttributeError: 'list' object has no attribute 'items'
    def merge_dicts(d1, d2) -> dict:
        merged = {}
        for k, v in d1.items():
            if k in d2:
                merged[f"example_{k}"] = v
            else:
                merged[k] = v

>       for k, v in d2.items():
E       AttributeError: 'list' object has no attribute 'items'

../../dspy/evaluate/evaluate.py:204: AttributeError
============================================================= warnings summary =============================================================
../../../miniconda3/envs/default/lib/python3.10/site-packages/pydantic/_internal/_config.py:291
  /Users/corey.zumar/miniconda3/envs/default/lib/python3.10/site-packages/pydantic/_internal/_config.py:291: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.9/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

../../../miniconda3/envs/default/lib/python3.10/site-packages/wandb/env.py:16
  /Users/corey.zumar/miniconda3/envs/default/lib/python3.10/site-packages/wandb/env.py:16: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    from distutils.util import strtobool

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================= short test summary info ==========================================================
FAILED test_evaluate.py::test_evaluate_display_table[False-True-program_with_example0] - AttributeError: 'list' object has no attribute 'items'

Comment on lines +139 to +142
(
lambda text: Predict("text: str -> first_word: Tuple[str, int]")(text=text).words,
dspy.Example(text="United States", first_word=("United", 6)).with_inputs("text"),
),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing some additional coverage for non-list and non-dict outputs

@okhat okhat merged commit 62526fc into stanfordnlp:main Nov 18, 2024
4 checks passed
isaacbmiller pushed a commit that referenced this pull request Dec 11, 2024
* Fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* Handle lists of dicts

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

* fix

Signed-off-by: dbczumar <corey.zumar@databricks.com>

---------

Signed-off-by: dbczumar <corey.zumar@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants