sepal_ui.model.model.Model#

class sepal_ui.model.model.Model(**kwargs)[source]#

Model object to store information of your computation (input, output.. etc).

The Model structure is based on traitlets and embed function for export or import in json format. The model traitlets can be bind to any widget field.

Attributes

Methods

bind

Binding a widget input 'v_model' trait to a trait of the model.

export_data

Export a json description of all the object traitlets.

import_data

Import the model (i.e. the traitlets) from a json file.

Parameters:
  • args (t.Any)

  • kwargs (t.Any)

Return type:

t.Any

Model.bind(widget, trait)[source]#

Binding a widget input ‘v_model’ trait to a trait of the model.

The binding will be unidirectionnal for the sake of some custom widget that does not support it. This wrapper avoid to import the ipywidgets lib everywhere and reduce the number of parameters Some existence check are also performed and will throw an error if the trait doesn’t exist.

Parameters:
  • widget (VuetifyWidget) – any input widget with a v_model trait

  • trait (str) – the name of a trait of the current model

Return type:

Self

Model.export_data()[source]#

Export a json description of all the object traitlets.

Note that the members will be ignored.

Returns:

the serialized traitlets

Return type:

dict

Model.import_data(data)[source]#

Import the model (i.e. the traitlets) from a json file.

Parameters:

data (dict | str) – the json ditionary of the model

Return type:

None