-
Notifications
You must be signed in to change notification settings - Fork 59
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
make learners picklable #264
Conversation
b2965d8
to
cb2cb25
Compare
Codecov Report
@@ Coverage Diff @@
## master #264 +/- ##
==========================================
+ Coverage 79.52% 80.18% +0.66%
==========================================
Files 32 33 +1
Lines 4425 4522 +97
Branches 815 819 +4
==========================================
+ Hits 3519 3626 +107
+ Misses 779 773 -6
+ Partials 127 123 -4
Continue to review full report at Codecov.
|
817cda9
to
303efaa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think tests should be more strict with idempotency. For example the loss reported by the new learner should be exactly the same, the learner's response to .ask
should be exactly the same, etc.
@basnijholt any idea why tests fail? |
The failure is intermittent and unrelated to these changes, also happens in master sometimes. It seems like the |
Oh, you are right! I assumed it were the same failures I had seen before. I think that is fixed by bc65213. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, and thanks for taking feedback on board.
The refactors I proposed are nice-to-haves, but I understand if we just want to get this merged.
OTOH we use an unseeded random number generator in such a way that I cannot see why the tests pass.
For me, explaining/fixing this is a prerequisite for merging.
@tlaeven, this is actually unrelated to these changes. The code you posted never worked, and has nothing to do with Adaptive: from functools import lru_cache
import loky
from concurrent.futures import ProcessPoolExecutor
@lru_cache()
def g(x):
return x ** 2
def f(x):
return x - g(0)
# Before
with ProcessPoolExecutor() as ex:
fut = ex.submit(f, 0)
try:
fut.result()
except Exception as e:
print(f"ProcessPoolExecutor failed: {e}")
# Now
ex = loky.get_reusable_executor()
fut = ex.submit(f, 0)
try:
fut.result()
except Exception as e:
print(f"loky failed: {e}") which prints:
I guess the difference is because of basnijholt/adaptive-scheduler#39. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work.
Description
I realized that in some cases it's very useful to pickle learners. For example to send it over the network when parallelizing code.
With these changes, most learners become picklable.
Checklist
pre-commit run --all
(first install usingpip install pre-commit
)pytest
passedType of change
Check relevant option(s).