Skip to content

Conversation

@jakobj
Copy link
Owner

@jakobj jakobj commented Jul 2, 2018

This PR adds basic checkpointing by dumping all local variables that are changed during optimization to a pickle file and automatically loading the most recent checkpoint if any is found.
During the implementation, I found that it may be much easier to implement checkpointing if the optimization routine is a stateful object, so maybe your idea @mschmidt87 to turn all algorithms into classes should be done first and a new checkpointing mechanism added to that. Let me know what you think about this.

Branches of #4, so should not be merged before that.

@jakobj jakobj changed the title Enh/checkpointing [WIP]Enh/checkpointing Jul 13, 2018
Copy link
Contributor

@mschmidt87 mschmidt87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just some minor comments.


if load_existing_checkpoint:
state = load_checkpoint()
if state:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If state is None here, i.e. if there were no checkpoints that can be loaded, I suggest to raise an error. Otherwise checkpoint loading fails silently.

from . import lib


def load_checkpoint():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about enabling the user to specify a specific checkpoint, not only the most recent one? You could implement this by allowing load_existing_checkpoint to be specified as True or -1 (for the most recent one) or as an integer specifying the generation.

pickle.dump(state, f)


def extract_keys_from_dict(d, whitelist, blacklist=[]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to me that this function should be located in lib.py.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants