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

refactor: modifying _update_from_checkpoint signature #186

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

Conversation

jeandut
Copy link
Contributor

@jeandut jeandut commented Jan 19, 2024

Related issue

No related issue

Summary

Notes

This PR introduces a change in the signature of the algorithm's update_from_checkpoint function in order to ease its use in complex pipelines.
As of before this PR if you had a checkpoint (a dict from say a call to get_state_to_save) it was impossible to load it ...
Now workflows can use patterns like:

chkpt = self.get_state_to_save()
self._update_from_checkpoint(chkpt)

Please check if the PR fulfills these requirements

  • If the feature has an impact on the user experience, the changelog has been updated
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • The commit message follows the conventional commit specification

@jeandut jeandut requested a review from a team as a code owner January 19, 2024 09:00
@jeandut jeandut changed the title Modifying _update_from_checkpoint signature refactor: modifying _update_from_checkpoint signature Jan 19, 2024
@jeandut jeandut force-pushed the jean/change_update_from_chkpt_signature branch 2 times, most recently from cdb467e to a56ce18 Compare January 19, 2024 09:23
@jeandut jeandut force-pushed the jean/change_update_from_chkpt_signature branch from 9aafcd8 to 78224dc Compare January 19, 2024 10:03
Copy link
Contributor

@SdgJlbl SdgJlbl left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your PR.
I understand the context of the change, and I agree that it is best to separate the I/O (loading the checkpoint) and the update part. Nevertheless, the method _update_from_checkpoint was idempotent (i.e. you can apply it several times in a row and get the same results as if you apply it once), and it's not the case anymore after your change, because of the side effect on checkpoint. It would be safer to keep _update_from_checkpoint idempotent, either by reading from checkpoint but not popping values from it, or by passing a copy to the function.

@jeandut
Copy link
Contributor Author

jeandut commented Jan 23, 2024

Okay will copy checkpoint in the function however striving for functional purity is a bit of an unattainable ideal.

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