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

Event and state serde aren't expansible #202

Open
ramedina86 opened this issue Jan 23, 2024 · 3 comments
Open

Event and state serde aren't expansible #202

ramedina86 opened this issue Jan 23, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@ramedina86
Copy link
Collaborator

To address this, we need a plug-in style approach for event deserialization and for state serialization. We'll need to migrate from the big IF blocks we currently have, to this.

This is a prerequisite for effective, wider-purpose extensions.

We'll need to be able to intercept/sanitize new types of events (e.g. ss-mycustomsafeevent), but also new types of objects (produced by libraries other than the supported by the core).

@FabienArcellier
Copy link
Collaborator

FabienArcellier commented Jan 23, 2024

Hello @ramedina86, I would think to extends the extension mechanism (FabienArcellier:14-pagination-component-for-repeater-and-dataframe-2). The developper could add a file setup.py in the extension. This file would be loaded when streamsync starts if the extension is installed.

The developper could declare serializer and santitizer for event.

streamsync.register_serializer('Folium', lambda v: v.json())
streamsync.register_serializer(FileWrapper, serialize_file)

streamsync.register_sanitizer('change-folium-location', check_folium_input)

On event, I would propose to evolve the event definition and set the sanitizer as argument.

@ramedina86
Copy link
Collaborator Author

Thanks Fabien; that sounds great.

Couple of questions:

  1. Why is Folium in quotes? Is this supposed to be MRO?
  2. Would change-folium-location be the name of the event?
  3. Are we maintaining a similar logic to what we have now, where we basically link an event type to a specific sanitizer?

@FabienArcellier
Copy link
Collaborator

FabienArcellier commented Jan 24, 2024

  1. Yes it's either the MRO, either a class or a type
  2. I take some time to think on it. I think using the event name could be great. It's easy to explain and document. There is a risk of implementing same code on different sanitizer but it's not an issue.
streamsync.register_sanitizer('ss-change-folium-location', check_folium_input)

@ramedina86 ramedina86 added the enhancement New feature or request label Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants