Skip to content

[BUG] Error with dependency on pydantic >v2 needs addressing #372

@Analect

Description

@Analect

Describe the bug
I was playing around with getting an interactive-app working, per your docs

To Reproduce
Create a test.py with this code from link above.

import meerkat as mk

@mk.reactive()
def square(a: float) -> float:
    return a**2


@mk.reactive()
def multiply(coef: float, a: float) -> float:
    return coef * a


@mk.endpoint()
def increment(value: mk.Store):
    value.set(value + 1)


input_slider = mk.gui.Slider(value=2.0)
coef_slider = mk.gui.Slider(value=2.0)

squared_value = square(input_slider.value)
result = multiply(coef_slider.value, squared_value)

button = mk.gui.Button(
    title="Increment", on_click=increment.partial(value=input_slider.value)
)

page = mk.gui.Page(
    component=mk.gui.html.div([input_slider, coef_slider, button, mk.gui.Text(result)]),
    id="quickstart",
)
page.launch()

Then run python test.py.

You get an error:

ImportError: cannot import name 'ModelField' from 'pydantic.fields' (/home/xxxx/miniconda3/lib/python3.9/site-packages/pydantic/fields.py)

It seems from this issue, ModelField no longer exists since V2 of pydantic. The above works, if I force an install of an earlier version of pydantic. (pip install pydantic==1.10.11).

Given that the default version of pydantic is >2, this will need fixing

System Information

  • OS: ubuntu linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions