Giter Site home page Giter Site logo

Comments (3)

cosmicBboy avatar cosmicBboy commented on June 12, 2024

Hi @airibarne can you report what the failure is exactly?

from pandera.

airibarne avatar airibarne commented on June 12, 2024

Sure @cosmicBboy, thanks for the quick response. Here is a screenshot of the error:

image

It seems to be a schema generation issue, but I am not familiarized enough with the way Pandera integrates with Pydantic to expose its JSON schema to fully assess it.

I'd add, for extra context, that this is breaking the /docs page of a standard FastAPI application having an endpoint that uses a Pandera model as either an input or an output. The only workaround I found up to today is to exclude these endpoints from the final OpenAPI schema using FastAPI's include_in_schema (documented here).

from pandera.

cosmicBboy avatar cosmicBboy commented on June 12, 2024

The part of the code base responsible for converting pandera schema to json schema representation can be found here:

if PYDANTIC_V2:
@classmethod
def __get_pydantic_core_schema__(
cls, _source_type: Any, _handler: GetCoreSchemaHandler
) -> core_schema.CoreSchema:
return core_schema.no_info_plain_validator_function(
cls.pydantic_validate,
)
@classmethod
def __get_pydantic_json_schema__(
cls,
_core_schema: core_schema.CoreSchema,
_handler: GetJsonSchemaHandler,
):
"""Update pydantic field schema."""
json_schema = _handler(_core_schema)
json_schema = _handler.resolve_ref_schema(json_schema)
json_schema.update(_to_json_schema(cls.to_schema()))
else:
@classmethod
def __modify_schema__(cls, field_schema):
"""Update pydantic field schema."""
field_schema.update(_to_json_schema(cls.to_schema()))
@classmethod
def __get_validators__(cls):
yield cls.pydantic_validate

For simplicity it only converts pandera schemas to a very simple json schema representation (column names and types).

Feel free to make a PR for this!

from pandera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.