Description
Is your feature request related to a problem? Please describe.
In PR #499, we need to serialize selector
into a jsonable dictionary and then to initialize a new selector
from that dictionary later, which requires us to store all the parameters from a selector
. To instantiate a selector
, we need to pass the input kwargs
to the constructor, and the kwargs
should be stored and serialized in some way that allows a new selector
to be initialized by deserializing its intermediate representation (IR).
Describe the solution you'd like
As described in method 2 from #499 (comment), we may add a todict()
and fromdict()
to the base Selector
class, where we can implement the serialization/deserialization of input kwargs
and any necessary states of a selector. We also need to remove kwargs
from the __init__
to avoid confusing behaviors of subclasses. Maybe it's better to put input kwargs
into a default_configs()
method and then propagate them in initialize()
just like what PipelineComponent
does so that todict()
and fromdict()
can be more straightforward.
The changes described above may deprecate a lot of interfaces related to Selector
that was previously used, so maybe we should keep the implementation and method signatures (keep the __init__
signature) of the current selector
s inherited from base class. But we need to override their todict()/fromdict()
since the todict()/fromdict()
in base Selector
class may not apply to them.
Describe alternatives you've considered
Any suggestions/solutions for selector serialization/deserialization are welcome.
Additional context
Add any other context or screenshots about the feature request here.