Skip to content

Commit

Permalink
Handle new naming scheme in newer Jupyter notebook (#1214)
Browse files Browse the repository at this point in the history

Co-authored-by: Olivier Grisel <[email protected]>
  • Loading branch information
mjziebarth and ogrisel committed Sep 13, 2021
1 parent 9c6cc4c commit 0730b77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Development version
is a decorated function.
https://github.com/joblib/joblib/pull/1165

- Fix `joblib.Memory` to properly handle caching for functions defined
interactively in a IPython session or in Jupyter notebook cell.
https://github.com/joblib/joblib/pull/1214

1.0.1
-----

Expand Down
7 changes: 7 additions & 0 deletions joblib/func_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ def get_func_name(func, resolv_alias=True, win_characters=True):
# notebooks
splitted = parts[-1].split('-')
parts[-1] = '-'.join(splitted[:2] + splitted[3:])
elif len(parts) > 2 and parts[-2].startswith('ipykernel_'):
# In a notebook session (ipykernel). Filename seems to be 'xyz'
# of above. parts[-2] has the structure ipykernel_XXXXXX where
# XXXXXX is a six-digit number identifying the current run (?).
# If we split it off, the function again has the same
# identifier across runs.
parts[-2] = 'ipykernel'
filename = '-'.join(parts)
if filename.endswith('.py'):
filename = filename[:-3]
Expand Down

0 comments on commit 0730b77

Please sign in to comment.