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:
- Add a
VERSION class attribute to SavableObject and TypeHelper that is expected to be an integer >= 0
- 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.
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:
VERSIONclass attribute toSavableObjectandTypeHelperthat is expected to be an integer>= 0_versionkey 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_statethey can interrogate the_versionvalue and have logic that handles the various versions. If they absoloutely cannot handle the version they've been given they can raise a newUnsupportedVersionexception 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.