Skip to content

Saving dataclass objects field-wise. #194

@yfukai

Description

@yfukai

I would like to propose an option to save dataclass objects into field-wise attributes, and automatically loads into the original object using the code like this:

import importlib

def resolve_class(path: str):
    module_name, qualname = path.split(":")
    module = importlib.import_module(module_name)
    obj = module
    for part in qualname.split("."):
        obj = getattr(obj, part)
    return obj

cls = resolve_class("mypkg.models:MyClass")
instance = cls(...)

This option can offer two benefits:

  • Enhances compatibility between different environments. (Current cloudpickle "can only be used to send objects between the exact same version of Python." from the doc)
  • By default, one can search nodes or edges by their attributes of dataclasses (Usecase: Splitting bbox and masks #119).

Prerequisite

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions