evidentlyai / evidently

Evidently is ​​an open-source ML and LLM observability framework. Evaluate, test, and monitor any AI-powered system or data pipeline. From tabular data to Gen AI. 100+ metrics.
https://www.evidentlyai.com/evidently-oss
Apache License 2.0
5.37k stars 595 forks source link

Assertion Error when trying to import evidently #549

Open khangt1k25 opened 1 year ago

khangt1k25 commented 1 year ago

I have a python code with Evidently library. But when i try to import like this. It causes Assertion error.

` import evidently

from evidently import ColumnMapping

from evidently.report import Report

from evidently.metric_preset import DataDriftPreset `

Traceback (most recent call last): File "/home/app.py", line 4, in <module> import evidently_client as evi File "/home/evidently_client.py", line 4, in <module> from evidently.report import Report File "/home/khangnt/anaconda3/envs/scoring/lib/python3.10/site-packages/evidently/report/__init__.py", line 1, in <module> from .report import Report File "/home/khangnt/anaconda3/envs/scoring/lib/python3.10/site-packages/evidently/report/report.py", line 14, in <module> from evidently.metric_preset.metric_preset import MetricPreset File "/home/khangnt/anaconda3/envs/scoring/lib/python3.10/site-packages/evidently/metric_preset/__init__.py", line 1, in <module> from .classification_performance import ClassificationPreset File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/evidently/metric_preset/classification_performance.py", line 5, in <module> from evidently.calculations.classification_performance import get_prediction_data File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/evidently/calculations/classification_performance.py", line 18, in <module> from evidently.metric_results import Boxes File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/evidently/metric_results.py", line 28, in <module> class ConfusionMatrix(MetricResultField): File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/pydantic/main.py", line 95, in __new__ fields[ann_name] = Field.infer( File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/pydantic/fields.py", line 92, in infer return cls( File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/pydantic/fields.py", line 77, in __init__ self.prepare() File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/pydantic/fields.py", line 133, in prepare self._populate_sub_fields() File "/home/khangnt/anaconda3/envs/ss/lib/python3.10/site-packages/pydantic/fields.py", line 171, in _populate_sub_fields assert issubclass(origin, Mapping) AssertionError

emeli-dral commented 1 year ago

Hey @khangt1k25

the quick solution is to change import from from evidently.pipeline.column_mapping import ColumnMapping to from evidently import ColumnMapping

Although we'll check what's going on with the initial import

khangt1k25 commented 1 year ago

Hi @emeli-dral , I changed that but it's still error. I figure out that the error come from two lines of code.

from evidently.report import Report from evidently.metric_preset import DataDriftPreset

mike0sv commented 1 year ago

Hi @khangt1k25 ! Can you check your pydantic version? Looks like this assertion fails because of old pydantic, try upgrade it. We also should add constraints on it in our requirements

mike0sv commented 1 year ago

related #568