maxfordham / ipyautoui

create ipywidgets user input form pydantic model or jsonschema
https://maxfordham.github.io/ipyautoui/
42 stars 4 forks source link

EditGrid Ordering Issue #126

Closed ollyhensby closed 1 year ago

ollyhensby commented 1 year ago

Issue

When setting the order of the grid instance in EditGrid, it fails when the columns passed are a strict subset of the columns in the grid.

Re-creating Issue

For example, the columns in the schema defined below are ("string", "floater", "inty"), and the order tuple passed is ("string", "floater"). Trying to set this to the order traitlet in AutoGrid is raising a ValueError.

import typing as ty
import pandas as pd

from pydantic import BaseModel, Field
from ipyautoui.custom.editgrid import EditGrid 

class TestProperties(BaseModel):
    string: str = Field(column_width=100, section="a")
    floater: float = Field(1.5, column_width=70, aui_sig_fig=3, section="b")
    inty: int = Field(1, section="b")

class TestGridSchema(BaseModel):
    """no default"""

    __root__: ty.List[TestProperties] = Field(
        [TestProperties(string="string").dict()],
        format="dataframe",
    )

df = pd.DataFrame([{"string": "test2", "floater": 2.2, "inty": 1}])
gr = EditGrid(schema=TestGridSchema)
display(gr)

gr.grid.order = ("string", "floater")

Error

image

jgunstone commented 1 year ago

stale issue - now resolved