diff options
| author | stuppie | 2026-08-18 12:08:03 -0600 |
|---|---|---|
| committer | stuppie | 2026-08-18 12:08:03 -0600 |
| commit | 48bf1738bcb78f8fde7f82c7003af5622a1b1769 (patch) | |
| tree | 3f22cda1568756872aaeeabf81242f09e8120fdd | |
| parent | d2e6004682c737985c5793efdde28d05c142e720 (diff) | |
| download | generalresearch-48bf1738bcb78f8fde7f82c7003af5622a1b1769.tar.gz generalresearch-48bf1738bcb78f8fde7f82c7003af5622a1b1769.zip | |
hopefully silence stupid pandera warning
| -rw-r--r-- | generalresearch/models/thl/survey/task_collection.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/generalresearch/models/thl/survey/task_collection.py b/generalresearch/models/thl/survey/task_collection.py index b09cdfb..b80166f 100644 --- a/generalresearch/models/thl/survey/task_collection.py +++ b/generalresearch/models/thl/survey/task_collection.py @@ -5,8 +5,7 @@ import json import logging import pandas as pd -from pandera import DataFrameSchema -from pandera.errors import SchemaErrors +import pandera.pandas as pa from pydantic import BaseModel, ConfigDict, Field, model_validator from generalresearch.models.thl.survey import MarketplaceTask @@ -29,14 +28,14 @@ class TaskCollection(BaseModel): df: pd.DataFrame = Field(default_factory=pd.DataFrame) # overload this with the correct schema! - _schema: DataFrameSchema + _schema: pa.DataFrameSchema @model_validator(mode="after") def handle_df(self): df = self.to_df() try: df = self._schema.validate(df, lazy=True) - except SchemaErrors as exc: + except pa.errors.SchemaErrors as exc: idx = exc.failure_cases["index"] if len(idx) >= len(df) * 0.10: raise exc @@ -50,7 +49,7 @@ class TaskCollection(BaseModel): def to_df(self) -> pd.DataFrame: ... -def create_empty_df_from_schema(schema: DataFrameSchema) -> pd.DataFrame: +def create_empty_df_from_schema(schema: pa.DataFrameSchema) -> pd.DataFrame: # Create an empty df from the schema. We have to do this or else a plain empty df # will fail validating non-nullable columns b/c they don't have a default. schema = copy.deepcopy(schema) |
