Skip to content

Conversation

@jopemachine
Copy link
Member

@jopemachine jopemachine commented May 10, 2024

Ref: https://github.com/lablup/backend.ai/pull/2105/files#r1595126303

Now, we need to improve code readability, not just write code that works, for integration and maintenance.
Let's handle the callback functions that specify formatters in Python through a single gateway function, instead of calling each one individually.

Before

def register_custom_deserializer() -> None:
    """
    Initialize the custom deserializers.
    """

    set_confchange_context_deserializer(pickle_deserialize)
    set_confchangev2_context_deserializer(pickle_deserialize)
    set_entry_context_deserializer(pickle_deserialize)
    set_entry_data_deserializer(pickle_deserialize)
    set_message_context_deserializer(pickle_deserialize)
    set_snapshot_data_deserializer(pickle_deserialize)

After

def register_custom_deserializer() -> None:
    """
    Initialize the custom deserializers.
    """

    set_custom_formatters(
        entry_data=pickle_deserialize,
        entry_context=pickle_deserialize,
        confchange_context=pickle_deserialize,
        confchangev2_context=pickle_deserialize,
        message_context=pickle_deserialize,
        snapshot_data=pickle_deserialize,
        log_entry=pickle_deserialize,
        fsm=pickle_deserialize,
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement python Python binding refactoring Rewrite something in better way while keeping the same functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants