-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Use dill to serialize logp functions in DensityDist #4053
Conversation
0da0c00
to
2ec28db
Compare
2ec28db
to
a92ce54
Compare
Codecov Report
@@ Coverage Diff @@
## master #4053 +/- ##
==========================================
+ Coverage 86.82% 86.83% +0.01%
==========================================
Files 88 88
Lines 14154 14165 +11
==========================================
+ Hits 12289 12300 +11
Misses 1865 1865
|
RELEASE-NOTES.md
Outdated
@@ -5,6 +5,7 @@ | |||
### Maintenance | |||
- Mentioned the way to do any random walk with `theano.tensor.cumsum()` in `GaussianRandomWalk` docstrings (see [#4048](https://github.com/pymc-devs/pymc3/pull/4048)). | |||
- Fixed numerical instability in ExGaussian's logp by preventing `logpow` from returning `-inf` (see [#4050](https://github.com/pymc-devs/pymc3/pull/4050)). | |||
- Use dill to serialize user defined logp functions in `DensityDist`. `dill` is now a required dependency. (see [#3844](https://github.com/pymc-devs/pymc3/issues/3844)). |
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.
- Use dill to serialize user defined logp functions in `DensityDist`. `dill` is now a required dependency. (see [#3844](https://github.com/pymc-devs/pymc3/issues/3844)). | |
- Use dill to serialize user-defined logp functions in `DensityDist`. `dill` is now a required dependency. (see [#3844](https://github.com/pymc-devs/pymc3/issues/3844)). |
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 would add what this allows what wasn't possible before. did pickling just throw an error?
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.
ok
scripts/create_testenv.sh
Outdated
@@ -24,13 +24,15 @@ ENVNAME="${ENVNAME:-testenv}" # if no ENVNAME is specified, use testenv | |||
if [ -z ${GLOBAL} ]; then | |||
if conda env list | grep -q ${ENVNAME}; then | |||
echo "Environment ${ENVNAME} already exists, keeping up to date" | |||
source activate ${ENVNAME} |
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 new style is conda activate
(or mamba).
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.
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.
If it's brittle probably best to keep it the way you had then.
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.
Well, it is now the way the conda docs specify it...
But I can of course change it back.
f9b563d
to
712e3fb
Compare
Thanks! |
Fix #3844
When users pass functions to
pm.DensityDist
, then in most cases pickle will not be able to deal with those functions. The code will still work on Linux, because the default multiprocessing context isfork
, and we don't even have to pickle the logp function. On Windows and Mac the default isspawn
orforkserver
however, and code usingpm.DensityDist
with a logp function that is not accessible in a module or protected byif __name__ == '__main__
will fail. This includes all functions defined in a notebook as far as I understand.We can work around this issue by manually serializing the logp function with dill.
This PR introduces dill as a new required dependency to PyMC3, before it was optional.
Edit: I had some trouble with the cache of miniconda, so I also included a fix so that the cached environment is updated.