Closed phillies closed 1 year ago
Example code from the bug video:
from typing import Optional
import numpy as np
import pandas as pd
from sqlmodel import SQLModel
from pandera import SchemaModel
from pandera.engines.pandas_engine import PydanticModel
from pandera.typing import DataFrame
df_new = pd.read_csv(
'testdata.csv',
encoding="utf-8",
quotechar="'",
keep_default_na=False,
na_values=set([""]),
)
display(df_new)
display(df_new.dtypes)
class DemoModel(SQLModel):
name: str
value: Optional[int]
value2: int
class PanderaModel(SchemaModel):
class Config:
dtype = PydanticModel(DemoModel)
coerce = True
I can't get this to repro, but I suspect it is something in the csv file being read. How large is that file? would you be able to attach it here?
That's a tiny test file:
name,value
'A',1
'B',
(last value is intentionally omitted to read a NaN)
huh, still no repro for me, but we could just take a look at that code.
The following code reliably reproduces the issue for me:
from pydantic import BaseModel
def to_camel(string: str) -> str:
pascal = "".join(word.capitalize() for word in string.split("_"))
if len(pascal) == 0:
return pascal
return pascal[0].lower() + pascal[1:]
class MyModel(BaseModel):
model_config = dict(alias_generator=to_camel, use_enum_values=True)
It happens when It seems simply importing pydantic breaks the variable viewer.MyModel
is a subclass of BaseModel
, if you remove BaseModel
from MyModel
, it works for whatever reason.
pydantic version is 2.0a3
I still can't repro the exact same issue. But I noticed a couple things
ModelMetaclass
that isn't excluded by our current filtersSo I fixed both of those and I'm hoping that helps
Applies To
What happened?
After opening the variables view and running some code in a jupyter cell, the variables are shown as loading in the variables view, then the view gets completely empty. Even the table headlines disappear.
https://user-images.githubusercontent.com/1006347/234009411-38bd83f0-85a7-4c6d-9f07-5b2a5850aef8.mp4
VS Code Version
Version: 1.77.3 (user setup) Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710 Date: 2023-04-12T09:16:02.548Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Windows_NT x64 10.0.19045 Sandboxed: Yes
Jupyter Extension Version
v2023.3.1201040234
Jupyter logs
Coding Language and Runtime Version
python v3.8.16
Language Extension Version (if applicable)
No response
Anaconda Version (if applicable)
No response
Running Jupyter locally or remotely?
Local