ipykernel-helper 0.0.1__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ipykernel-helper might be problematic. Click here for more details.
- {ipykernel_helper-0.0.1/ipykernel_helper.egg-info → ipykernel_helper-0.0.2}/PKG-INFO +2 -1
- ipykernel_helper-0.0.2/ipykernel_helper/__init__.py +2 -0
- ipykernel_helper-0.0.2/ipykernel_helper/_modidx.py +18 -0
- ipykernel_helper-0.0.2/ipykernel_helper/core.py +117 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2/ipykernel_helper.egg-info}/PKG-INFO +2 -1
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/requires.txt +1 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/settings.ini +15 -20
- ipykernel_helper-0.0.1/ipykernel_helper/__init__.py +0 -2
- ipykernel_helper-0.0.1/ipykernel_helper/_modidx.py +0 -9
- ipykernel_helper-0.0.1/ipykernel_helper/core.py +0 -36
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/LICENSE +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/MANIFEST.in +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/README.md +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/SOURCES.txt +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/dependency_links.txt +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/entry_points.txt +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/not-zip-safe +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/top_level.txt +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/pyproject.toml +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/setup.cfg +0 -0
- {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipykernel-helper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Helpers for ipykernel and friends
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/ipykernel-helper
|
|
6
6
|
Author: Jeremy Howard
|
|
@@ -19,6 +19,7 @@ Requires-Python: >=3.9
|
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: fastcore
|
|
22
|
+
Requires-Dist: toolslm>=0.2.0
|
|
22
23
|
Provides-Extra: dev
|
|
23
24
|
Dynamic: author
|
|
24
25
|
Dynamic: author-email
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Autogenerated by nbdev
|
|
2
|
+
|
|
3
|
+
d = { 'settings': { 'branch': 'main',
|
|
4
|
+
'doc_baseurl': '/ipykernel-helper',
|
|
5
|
+
'doc_host': 'https://AnswerDotAI.github.io',
|
|
6
|
+
'git_url': 'https://github.com/AnswerDotAI/ipykernel-helper',
|
|
7
|
+
'lib_path': 'ipykernel_helper'},
|
|
8
|
+
'syms': { 'ipykernel_helper.core': { 'ipykernel_helper.core.AsyncKernelClient.interactive': ( 'core.html#asynckernelclient.interactive',
|
|
9
|
+
'ipykernel_helper/core.py'),
|
|
10
|
+
'ipykernel_helper.core._get_schema': ('core.html#_get_schema', 'ipykernel_helper/core.py'),
|
|
11
|
+
'ipykernel_helper.core._rank': ('core.html#_rank', 'ipykernel_helper/core.py'),
|
|
12
|
+
'ipykernel_helper.core._signatures': ('core.html#_signatures', 'ipykernel_helper/core.py'),
|
|
13
|
+
'ipykernel_helper.core.get_schemas': ('core.html#get_schemas', 'ipykernel_helper/core.py'),
|
|
14
|
+
'ipykernel_helper.core.get_vars': ('core.html#get_vars', 'ipykernel_helper/core.py'),
|
|
15
|
+
'ipykernel_helper.core.ranked_complete': ('core.html#ranked_complete', 'ipykernel_helper/core.py'),
|
|
16
|
+
'ipykernel_helper.core.safe_repr': ('core.html#safe_repr', 'ipykernel_helper/core.py'),
|
|
17
|
+
'ipykernel_helper.core.sig_help': ('core.html#sig_help', 'ipykernel_helper/core.py'),
|
|
18
|
+
'ipykernel_helper.core.user_items': ('core.html#user_items', 'ipykernel_helper/core.py')}}}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""API for ipykernel-helper"""
|
|
2
|
+
|
|
3
|
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
4
|
+
|
|
5
|
+
# %% auto 0
|
|
6
|
+
__all__ = ['safe_repr', 'user_items', 'ranked_complete', 'sig_help', 'get_vars', 'get_schemas']
|
|
7
|
+
|
|
8
|
+
# %% ../nbs/00_core.ipynb
|
|
9
|
+
from fastcore.meta import delegates
|
|
10
|
+
from fastcore.utils import patch,dict2obj
|
|
11
|
+
import typing,warnings
|
|
12
|
+
from types import ModuleType, FunctionType, MethodType, BuiltinFunctionType
|
|
13
|
+
from inspect import signature, currentframe
|
|
14
|
+
from functools import cmp_to_key,partial
|
|
15
|
+
from toolslm.funccall import *
|
|
16
|
+
|
|
17
|
+
from jupyter_client import AsyncKernelClient
|
|
18
|
+
from IPython.core.completer import ProvisionalCompleterWarning
|
|
19
|
+
from jedi import Interpreter, Script as jscript
|
|
20
|
+
|
|
21
|
+
# %% ../nbs/00_core.ipynb
|
|
22
|
+
warnings.filterwarnings('ignore', category=ProvisionalCompleterWarning)
|
|
23
|
+
|
|
24
|
+
# %% ../nbs/00_core.ipynb
|
|
25
|
+
def safe_repr(obj, max_len=200):
|
|
26
|
+
"Safely get the repr() of an object, truncating if it exceeds max_len."
|
|
27
|
+
try:
|
|
28
|
+
s = str(obj)
|
|
29
|
+
return s[:max_len] + ("…" if len(s)>max_len else "")
|
|
30
|
+
except Exception as e: return f"<repr error: {str(e)}>"
|
|
31
|
+
|
|
32
|
+
# %% ../nbs/00_core.ipynb
|
|
33
|
+
def user_items(ns=None, max_len=200, xtra_skip=()):
|
|
34
|
+
"Get user-defined vars & funcs from namespace."
|
|
35
|
+
if ns is None: ns = currentframe().f_back.f_globals
|
|
36
|
+
ignore = {'In', 'Out', 'exit', 'quit', 'open', 'nbmeta', 'receive_nbmeta'}
|
|
37
|
+
ignore.add(xtra_skip)
|
|
38
|
+
rm_types = (
|
|
39
|
+
type, FunctionType, ModuleType, MethodType, BuiltinFunctionType,
|
|
40
|
+
getattr(typing, '_SpecialGenericAlias', ()),
|
|
41
|
+
getattr(typing, '_GenericAlias', ()),
|
|
42
|
+
getattr(typing, '_SpecialForm', ())
|
|
43
|
+
)
|
|
44
|
+
user_items = {k:v for k, v in ns.items()
|
|
45
|
+
if not k in ignore}
|
|
46
|
+
user_vars = {k:safe_repr(v, max_len=max_len)
|
|
47
|
+
for k, v in user_items.items() if not k.startswith('_') and not isinstance(v, rm_types)}
|
|
48
|
+
user_fns = {k:str(signature(v)) for k, v in user_items.items()
|
|
49
|
+
if isinstance(v, FunctionType) and v.__module__ == '__main__' and not k.startswith('__')}
|
|
50
|
+
return user_vars,user_fns
|
|
51
|
+
|
|
52
|
+
# %% ../nbs/00_core.ipynb
|
|
53
|
+
@patch
|
|
54
|
+
@delegates(AsyncKernelClient.execute_interactive)
|
|
55
|
+
async def interactive(self:AsyncKernelClient, code:str, **kwargs):
|
|
56
|
+
"Like AsyncKernelClient.execute_interactive, but also returns outputs"
|
|
57
|
+
outputs = []
|
|
58
|
+
def _h(msg: dict): outputs.append(msg)
|
|
59
|
+
res = await self.execute_interactive(code, output_hook=_h, **kwargs)
|
|
60
|
+
return res,outputs
|
|
61
|
+
|
|
62
|
+
# %% ../nbs/00_core.ipynb
|
|
63
|
+
def _rank(c, s):
|
|
64
|
+
"Rank a completion `c` for text `s` with namespace `ns`."
|
|
65
|
+
parts = s.split('.')
|
|
66
|
+
is_public = not c.text.startswith('_')
|
|
67
|
+
if c.type=='param': r=1
|
|
68
|
+
elif c.mod=='__main__': r=2 # local
|
|
69
|
+
elif len(parts)>1 and parts[0]==c.mod: r=3 # module
|
|
70
|
+
elif c.mod=='builtins': r=4
|
|
71
|
+
else: r=5
|
|
72
|
+
return r if is_public else r+0.1
|
|
73
|
+
|
|
74
|
+
# %% ../nbs/00_core.ipynb
|
|
75
|
+
def ranked_complete(code, line_no=None, col_no=None):
|
|
76
|
+
ipy = get_ipython()
|
|
77
|
+
lines = code.splitlines(True)
|
|
78
|
+
if line_no: offset = sum(len(lines[i]) for i in range(line_no-1)) + col_no -1
|
|
79
|
+
else: offset = len(code)
|
|
80
|
+
cs = ipy.Completer.completions(code, offset)
|
|
81
|
+
def _c(a):
|
|
82
|
+
res = dict2obj({attr: getattr(a, attr) for attr in dir(a) if attr[0]!='_'})
|
|
83
|
+
res['mod']= getattr(ipy.user_ns.get(a.text, None), '__module__', None)
|
|
84
|
+
res['rank'] = _rank(res, s=code)
|
|
85
|
+
return res
|
|
86
|
+
return [_c(c) for c in cs if not c.text.startswith('__')]
|
|
87
|
+
|
|
88
|
+
# %% ../nbs/00_core.ipynb
|
|
89
|
+
def _signatures(ns, s, line, col):
|
|
90
|
+
ctx = Interpreter(s, [ns]).get_signatures(line, col)
|
|
91
|
+
if not ctx: ctx = jscript(s).get_signatures(line, col)
|
|
92
|
+
return ctx
|
|
93
|
+
|
|
94
|
+
def sig_help(code, line_no=None, col_no=None):
|
|
95
|
+
ns = get_ipython().user_ns
|
|
96
|
+
ctx = _signatures(ns, code, line=line_no, col=col_no)
|
|
97
|
+
def _s(s): return {'label':s.description,'typ':s.type, 'mod':s.module_name, 'doc':s.docstring(),
|
|
98
|
+
'idx':s.index, 'params':[{'name':p.name} for p in s.params]}
|
|
99
|
+
return [_s(opt) for opt in ctx]
|
|
100
|
+
|
|
101
|
+
# %% ../nbs/00_core.ipynb
|
|
102
|
+
def get_vars(vs:list):
|
|
103
|
+
"Get variables from namespace."
|
|
104
|
+
ns = get_ipython().user_ns
|
|
105
|
+
return {v:ns[v] for v in vs if v in ns}
|
|
106
|
+
|
|
107
|
+
# %% ../nbs/00_core.ipynb
|
|
108
|
+
def _get_schema(ns: dict, t):
|
|
109
|
+
"Check if tool `t` has errors."
|
|
110
|
+
if t not in ns: return f"`{t}` not found. Did you run it?"
|
|
111
|
+
try: return get_schema(ns[t])
|
|
112
|
+
except Exception as e: return f"`{t}`: {e}."
|
|
113
|
+
|
|
114
|
+
def get_schemas(fs:list):
|
|
115
|
+
"Get schemas from namespace."
|
|
116
|
+
ns = get_ipython().user_ns
|
|
117
|
+
return {f:_get_schema(ns,f) for f in fs}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ipykernel-helper
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Helpers for ipykernel and friends
|
|
5
5
|
Home-page: https://github.com/AnswerDotAI/ipykernel-helper
|
|
6
6
|
Author: Jeremy Howard
|
|
@@ -19,6 +19,7 @@ Requires-Python: >=3.9
|
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
Requires-Dist: fastcore
|
|
22
|
+
Requires-Dist: toolslm>=0.2.0
|
|
22
23
|
Provides-Extra: dev
|
|
23
24
|
Dynamic: author
|
|
24
25
|
Dynamic: author-email
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
[DEFAULT]
|
|
2
|
-
### Python library ###
|
|
3
2
|
repo = ipykernel-helper
|
|
4
|
-
lib_name =
|
|
5
|
-
version = 0.0.
|
|
3
|
+
lib_name = ipykernel-helper
|
|
4
|
+
version = 0.0.2
|
|
6
5
|
min_python = 3.9
|
|
7
6
|
license = apache2
|
|
8
7
|
black_formatting = False
|
|
9
|
-
requirements = fastcore
|
|
8
|
+
requirements = fastcore toolslm>=0.2.0
|
|
10
9
|
cell_number = False
|
|
11
|
-
|
|
12
|
-
### nbdev ###
|
|
13
10
|
doc_path = _docs
|
|
14
11
|
lib_path = ipykernel_helper
|
|
15
12
|
nbs_path = nbs
|
|
@@ -17,28 +14,26 @@ recursive = True
|
|
|
17
14
|
tst_flags = notest
|
|
18
15
|
put_version_in_init = True
|
|
19
16
|
update_pyproject = True
|
|
20
|
-
|
|
21
|
-
### Docs ###
|
|
22
17
|
branch = main
|
|
23
18
|
custom_sidebar = False
|
|
24
|
-
doc_host = https
|
|
25
|
-
doc_baseurl =
|
|
26
|
-
git_url = https://github.com
|
|
27
|
-
title =
|
|
28
|
-
|
|
29
|
-
### PyPI ###
|
|
19
|
+
doc_host = https://AnswerDotAI.github.io
|
|
20
|
+
doc_baseurl = /ipykernel-helper
|
|
21
|
+
git_url = https://github.com/AnswerDotAI/ipykernel-helper
|
|
22
|
+
title = ipykernel-helper
|
|
30
23
|
audience = Developers
|
|
31
24
|
author = Jeremy Howard
|
|
32
25
|
author_email = info@fast.ai
|
|
33
|
-
copyright = 2025 onwards,
|
|
26
|
+
copyright = 2025 onwards, Jeremy Howard
|
|
34
27
|
description = Helpers for ipykernel and friends
|
|
35
28
|
keywords = nbdev jupyter notebook python
|
|
36
29
|
language = English
|
|
37
30
|
status = 3
|
|
38
31
|
user = AnswerDotAI
|
|
32
|
+
readme_nb = index.ipynb
|
|
33
|
+
allowed_metadata_keys =
|
|
34
|
+
allowed_cell_metadata_keys =
|
|
35
|
+
jupyter_hooks = False
|
|
36
|
+
clean_ids = True
|
|
37
|
+
clear_all = False
|
|
38
|
+
skip_procs =
|
|
39
39
|
|
|
40
|
-
### Optional ###
|
|
41
|
-
# dev_requirements =
|
|
42
|
-
# console_scripts =
|
|
43
|
-
# conda_user =
|
|
44
|
-
# package_data =
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# Autogenerated by nbdev
|
|
2
|
-
|
|
3
|
-
d = { 'settings': { 'branch': 'main',
|
|
4
|
-
'doc_baseurl': '/ipykernel-helper',
|
|
5
|
-
'doc_host': 'https://AnswerDotAI.github.io',
|
|
6
|
-
'git_url': 'https://github.com/AnswerDotAI/ipykernel-helper',
|
|
7
|
-
'lib_path': 'ipykernel_helper'},
|
|
8
|
-
'syms': { 'ipykernel_helper.core': { 'ipykernel_helper.core.safe_repr': ('core.html#safe_repr', 'ipykernel_helper/core.py'),
|
|
9
|
-
'ipykernel_helper.core.user_items': ('core.html#user_items', 'ipykernel_helper/core.py')}}}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"""API for ipykernel-helper"""
|
|
2
|
-
|
|
3
|
-
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
|
|
4
|
-
|
|
5
|
-
# %% auto 0
|
|
6
|
-
__all__ = ['safe_repr', 'user_items']
|
|
7
|
-
|
|
8
|
-
# %% ../nbs/00_core.ipynb
|
|
9
|
-
import typing
|
|
10
|
-
from types import ModuleType, FunctionType, MethodType, BuiltinFunctionType
|
|
11
|
-
from inspect import signature
|
|
12
|
-
|
|
13
|
-
# %% ../nbs/00_core.ipynb
|
|
14
|
-
def safe_repr(obj, max_len=200):
|
|
15
|
-
"Safely get the repr() of an object, truncating if it exceeds max_len."
|
|
16
|
-
try:
|
|
17
|
-
s = str(obj)
|
|
18
|
-
return s[:max_len] + ("…" if len(s)>max_len else "")
|
|
19
|
-
except Exception as e: return f"<repr error: {str(e)}>"
|
|
20
|
-
|
|
21
|
-
# %% ../nbs/00_core.ipynb
|
|
22
|
-
def user_items(ns, max_len=200, xtra_skip=()):
|
|
23
|
-
"Get user-defined vars & funcs from namespace."
|
|
24
|
-
ignore = {'In', 'Out', 'exit', 'quit', 'open', 'nbmeta', 'receive_nbmeta'}
|
|
25
|
-
ignore.add(xtra_skip)
|
|
26
|
-
rm_types = (
|
|
27
|
-
type, FunctionType, ModuleType, MethodType, BuiltinFunctionType,
|
|
28
|
-
getattr(typing, '_SpecialGenericAlias', ()),
|
|
29
|
-
getattr(typing, '_GenericAlias', ()),
|
|
30
|
-
getattr(typing, '_SpecialForm', ())
|
|
31
|
-
)
|
|
32
|
-
user_items = {k: v for k, v in ns.items() if not (k.startswith('_') or k in ignore)}
|
|
33
|
-
user_vars = {k:safe_repr(v, max_len=max_len) for k, v in user_items.items() if not isinstance(v, rm_types)}
|
|
34
|
-
user_fns = {k:str(signature(v)) for k, v in user_items.items()
|
|
35
|
-
if isinstance(v, FunctionType) and v.__module__ == '__main__' and not k.startswith('__')}
|
|
36
|
-
return user_vars,user_fns
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{ipykernel_helper-0.0.1 → ipykernel_helper-0.0.2}/ipykernel_helper.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|