gnes.router.base module

class gnes.router.base.BaseEmbedReduceRouter(*args, **kwargs)[source]

Bases: gnes.router.base.BaseReduceRouter

apply(msg, accum_msgs, *args, **kwargs)[source]

reduce embeddings from encoders (means, concat ….)

Parameters:
  • msg (Message) – the current message
  • accum_msgs (List[Message]) – accumulated messages
Return type:

None

reduce_embedding(accum_msgs, msg_type, chunk_idx, doc_idx)[source]
train(*args, **kwargs)

Train the model, need to be overrided

class gnes.router.base.BaseMapRouter(*args, **kwargs)[source]

Bases: gnes.router.base.BaseRouter

apply(msg, *args, **kwargs)[source]

Modify the incoming message

Parameters:msg (Message) – incoming message
Return type:Generator[+T_co, -T_contra, +V_co]
train(*args, **kwargs)

Train the model, need to be overrided

class gnes.router.base.BaseReduceRouter(*args, **kwargs)[source]

Bases: gnes.router.base.BaseRouter

apply(msg, accum_msgs, *args, **kwargs)[source]

Modify the current message based on accumulated messages

Parameters:
  • msg (Message) – the current message
  • accum_msgs (List[Message]) – accumulated messages
Return type:

None

train(*args, **kwargs)

Train the model, need to be overrided

class gnes.router.base.BaseRouter(*args, **kwargs)[source]

Bases: gnes.base.TrainableBase

Base class for the router. Inherit from this class to create a new router.

Router forwards messages between services. Essentially, it receives a ‘gnes_pb2.Message’ and call apply() method on it.

apply(msg, *args, **kwargs)[source]

Modify the incoming message

Parameters:msg (Message) – incoming message
train(*args, **kwargs)

Train the model, need to be overrided

class gnes.router.base.BaseTopkReduceRouter(reduce_op='sum', *args, **kwargs)[source]

Bases: gnes.router.base.BaseReduceRouter

apply(msg, accum_msgs, *args, **kwargs)[source]

Modify the current message based on accumulated messages

Parameters:
  • msg (Message) – the current message
  • accum_msgs (List[Message]) – accumulated messages
get_key(x)[source]
Return type:str
post_init()[source]

Declare class attributes/members that can not be serialized in standard way

set_key(x, k)[source]
Return type:None
train(*args, **kwargs)

Train the model, need to be overrided

class gnes.router.base.PipelineRouter(*args, **kwargs)[source]

Bases: gnes.base.CompositionalTrainableBase

apply(*args, **kwargs)[source]
Return type:None
train(*args, **kwargs)

Train the model, need to be overrided