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

feat: Implement set_custom_formatters as a one unified gateway function #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

1 participant