Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state.to_spec should validate if type is correct #428

Open
hoxbro opened this issue Jan 16, 2023 · 1 comment
Open

state.to_spec should validate if type is correct #428

hoxbro opened this issue Jan 16, 2023 · 1 comment

Comments

@hoxbro
Copy link
Member

hoxbro commented Jan 16, 2023

Right now, state.to_spec will run the respective class to_spec method. There should be a type check to validate that the type is correct, e.g., layouts should have the type of Layouts:

import lumen
import panel as pn
import yaml
from lumen.layout import Layout
from lumen.pipeline import Pipeline
from lumen.sources import FileSource
from lumen.views import Table

pn.extension("tabulator")

data_url = "https://datasets.holoviz.org/penguins/v1/penguins.csv"

pipeline = Pipeline(source=FileSource(tables={"penguins": data_url}), table="penguins")
pipeline.add_filter("widget", field="species")
pipeline.add_filter("widget", field="island")
pipeline.add_filter("widget", field="sex")
pipeline.add_filter("widget", field="year")

view = Table(pipeline=pipeline)

This should raise an error

specification = lumen.state.to_spec(
    config={"title": "test"},
    layouts=[view],
)

I can submit a PR, but I want to be sure I have not overlooked anything.

@philippjfr
Copy link
Member

Maybe also a good idea for lumen.state.to_spec to also run a validation pass on the output it generates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants