There seems to be a bug(?) where the configuration object that the Python plugin receives is never set unless handleUpdateModel is called from the UI. This gives me the annoying issue where the default configuration set in the DesignerApi component never reaches the plugin until the user interacts with the UI.
const Tool = (): JSX.Element => {
return (
<DesignerApi
messages={{}}
defaultConfig={{ Configuration: { foo: 'Hello, world!' } }}
>
<AyxAppWrapper>
<App />
</AyxAppWrapper>
</DesignerApi>
)
}
class MyPlugin(PluginV2):
def __init__(self, provider: AMPProviderV2):
self.name = "MyPlugin"
self.provider = provider
# This should be "Hello, world!" but the key "foo" doesn't exist
self.foo = self.provider.tool_config.get("foo") or ""
I'm currently getting around this by forcing an update when the UI loads.
const App = (): JSX.Element => {
const [model, handleUpdateModel] = useContext(UiSdkContext)
useEffect(() => handleUpdateModel({ ...model }), [])
return (
/* ... */
)
}
There seems to be a bug(?) where the configuration object that the Python plugin receives is never set unless
handleUpdateModelis called from the UI. This gives me the annoying issue where the default configuration set in theDesignerApicomponent never reaches the plugin until the user interacts with the UI.I'm currently getting around this by forcing an update when the UI loads.