You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make Storage objects picklable and resumable by mp.Pool workers (microsoft#974)
# Pull Request
## Title
Make Storage objects picklable and resumable by mp.Pool workers.
______________________________________________________________________
## Description
To support a `ParallelTrialScheduler` with `Trials` running thru
`TrialRunners` in separate processes using `multiprocessing.Pool` we
need to be able to "send" all necessary state to "blank" python
processes using pickle since python doesn't actually use a `fork`
strategy for multiprocessing.
This change enables that by doing the following:
1. Allow pickling the core `Storage` class by hooking `__getstate__` and
`__setstate__` to disconnect the `Engine` prior to pickling and
reconnect on unpickling (restore).
2. Allow recreating an `Experiment` and `Trial` object by fetching it
from the `Storage` by `experiment_id` and `trial_id` respectively.
These two things allow gathering the details necessary for a
`TrialRunner` running in a separate child process to reconnect to the DB
independently, `run_trial`, and save the telemetry and results to the
DB.
After which, the "MainProcess" can `load` the results from the
Experiment from the Storage again to `bulk_register` the scores from
those completed `Trials` and start a new set.
______________________________________________________________________
## Type of Change
- 🛠️ Bug fix
- ✨ New feature
- 🔄 Refactor
- 🧪 Tests
______________________________________________________________________
## Testing
- [x] New CI tests
______________________________________________________________________
## Additional Notes (optional)
This change should have no impact on the existing `SyncScheduler`.
______________________________________________________________________
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
0 commit comments