You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm a big pydantic user and main author of ipyautoui, a package which builds UI forms from a (often pydantic generated) jsonschema.
In ipyautoui a dataframe can be defined as follows
pydantic code to make schema
frompydanticimportField, constr, RootModel, ConfigDictfromipyautoui.basemodelimportBaseModelfromtyping_extensionsimportAnnotatedfromdatetimeimportdatetimeclassNestedObject(BaseModel):
"""description in docstring"""string1: str=Field(default="adsf", description="a description about my string")
int_slider1: Annotated[int, Field(ge=0, le=3)] =2int_text1: int=1date: datetimeclassRootArray(RootModel):
root: list[NestedObject]
model_config=ConfigDict(
json_schema_extra={"format": "dataframe", "primaryKey": ["date"]}
)
fromjsonrefimportreplace_refsfrompprintimportpprintschema=RootArray.model_json_schema()
# ----schema=replace_refs(schema)
schema= {k: vfork, vinschema.items() ifk!="$defs"}
# ^ for simplicity / illustration purposes I removed the $defs / internal json linkpprint(schema)
row items (objects) are defined by the items keyword (i.e. no need to introduce additional term "field")
the required "name" field is implicitly required as it is the object key
this allows for validation using standard jsonschema libraries and pydantic
I'm interested if there would be any appetite to support this type of specification - perhaps as an allowed alternative? or possible future version specification?
I'm also interested to know if users here think that this is a good way of defining tabular data, or if there are issues with this suggestion that I've missed?
This discussion was converted from issue #887 on January 03, 2024 12:45.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm a big pydantic user and main author of ipyautoui, a package which builds UI forms from a (often pydantic generated) jsonschema.
In ipyautoui a dataframe can be defined as follows
pydantic code to make schema
note: length of items object above must equal 1 for this to be compliant.
the equivalent following the frictionless data spec would be:
I think that the are some benefits to the pydantic-style approach:
I'm interested if there would be any appetite to support this type of specification - perhaps as an allowed alternative? or possible future version specification?
I'm also interested to know if users here think that this is a good way of defining tabular data, or if there are issues with this suggestion that I've missed?
many thanks
Beta Was this translation helpful? Give feedback.
All reactions