pytorch-lightning
pytorch-lightning copied to clipboard
(app): Add on_load_state_dict and on_save_state_dict
What does this PR do?
This PR introduces an API to reload dynamic component trees.
The current strategy is the following. We collect all the states. On reload, if a component state doesn't have its component, we give the responsibility to its closest parent to resolve it and then the cascade of instantiation is done.
class FlowReload(LightningFlow):
def run(self):
if not getattr(self, "w", None):
self.w = WorkReload()
self.w.run()
def on_load_state_dict(self, children_states, extras) -> None:
self.w = WorkReload()
Fixes #<issue_number>
Does your PR introduce any breaking changes? If yes, please list them.
Before submitting
- [x] Was this discussed/approved via a GitHub issue? (not for typos and docs)
- [x] Did you read the contributor guideline, Pull Request section?
- [x] Did you make sure your PR does only one thing, instead of bundling different changes together?
- [x] Did you make sure to update the documentation with your changes? (if necessary)
- [x] Did you write any new necessary tests? (not for typos and docs)
- [x] Did you verify new and existing tests pass locally with your changes?
- [x] Did you list all the breaking changes introduced by this pull request?
- [x] Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)
PR review
Anyone in the community is welcome to review the PR. Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
- [x] Is this pull request ready for review? (if not, please submit in draft mode)
- [x] Check that all items from Before submitting are resolved
- [x] Make sure the title is self-explanatory and the description concisely explains the PR
- [x] Add labels and milestones (and optionally projects) to the PR so it can be classified
Did you have fun?
Make sure you had fun coding 🙃
@tchaton, mind checking the remaining comments?