Skip to content

Add versioning support to savable objects #6

@muhrin

Description

@muhrin

It would be good to have some support for versions of objects as users may change their classes or change the way that they store the state in the database.

The proposition is as follows:

  1. Add a VERSION class attribute to SavableObject and TypeHelper that is expected to be an integer >= 0
  2. Encourage users to add a special _version key to their saved state dictionary (if it's not a dict they will have to 'promote' it to one and store the current value within)

Now, when a user gets a state dict in load_instance_state they can interrogate the _version value and have logic that handles the various versions. If they absoloutely cannot handle the version they've been given they can raise a new UnsupportedVersion exception and provide an explanation to the user. This should be discouraged as it's effectively the end of the road for getting the data to be read.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions