ipykernel-helper 0.0.1__tar.gz → 0.0.3__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.

Files changed (21) hide show
  1. {ipykernel_helper-0.0.1/ipykernel_helper.egg-info → ipykernel_helper-0.0.3}/PKG-INFO +2 -1
  2. ipykernel_helper-0.0.3/ipykernel_helper/__init__.py +2 -0
  3. ipykernel_helper-0.0.3/ipykernel_helper/_modidx.py +21 -0
  4. ipykernel_helper-0.0.3/ipykernel_helper/core.py +115 -0
  5. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3/ipykernel_helper.egg-info}/PKG-INFO +2 -1
  6. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/requires.txt +1 -0
  7. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/settings.ini +15 -20
  8. ipykernel_helper-0.0.1/ipykernel_helper/__init__.py +0 -2
  9. ipykernel_helper-0.0.1/ipykernel_helper/_modidx.py +0 -9
  10. ipykernel_helper-0.0.1/ipykernel_helper/core.py +0 -36
  11. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/LICENSE +0 -0
  12. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/MANIFEST.in +0 -0
  13. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/README.md +0 -0
  14. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/SOURCES.txt +0 -0
  15. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/dependency_links.txt +0 -0
  16. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/entry_points.txt +0 -0
  17. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/not-zip-safe +0 -0
  18. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/top_level.txt +0 -0
  19. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/pyproject.toml +0 -0
  20. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/setup.cfg +0 -0
  21. {ipykernel_helper-0.0.1 → ipykernel_helper-0.0.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipykernel-helper
3
- Version: 0.0.1
3
+ Version: 0.0.3
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,2 @@
1
+ __version__ = "0.0.3"
2
+ from .core import *
@@ -0,0 +1,21 @@
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.InteractiveShell.get_schemas': ( 'core.html#interactiveshell.get_schemas',
9
+ 'ipykernel_helper/core.py'),
10
+ 'ipykernel_helper.core.InteractiveShell.get_vars': ( 'core.html#interactiveshell.get_vars',
11
+ 'ipykernel_helper/core.py'),
12
+ 'ipykernel_helper.core.InteractiveShell.ranked_complete': ( 'core.html#interactiveshell.ranked_complete',
13
+ 'ipykernel_helper/core.py'),
14
+ 'ipykernel_helper.core.InteractiveShell.sig_help': ( 'core.html#interactiveshell.sig_help',
15
+ 'ipykernel_helper/core.py'),
16
+ 'ipykernel_helper.core.InteractiveShell.user_items': ( 'core.html#interactiveshell.user_items',
17
+ 'ipykernel_helper/core.py'),
18
+ 'ipykernel_helper.core._get_schema': ('core.html#_get_schema', 'ipykernel_helper/core.py'),
19
+ 'ipykernel_helper.core._rank': ('core.html#_rank', 'ipykernel_helper/core.py'),
20
+ 'ipykernel_helper.core._signatures': ('core.html#_signatures', 'ipykernel_helper/core.py'),
21
+ 'ipykernel_helper.core.safe_repr': ('core.html#safe_repr', 'ipykernel_helper/core.py')}}}
@@ -0,0 +1,115 @@
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']
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.interactiveshell import InteractiveShell
19
+ from IPython.core.completer import ProvisionalCompleterWarning
20
+ from jedi import Interpreter, Script as jscript
21
+
22
+ from IPython.core.display import DisplayObject
23
+
24
+ # %% ../nbs/00_core.ipynb
25
+ warnings.filterwarnings('ignore', category=ProvisionalCompleterWarning)
26
+
27
+ # %% ../nbs/00_core.ipynb
28
+ def safe_repr(obj, max_len=200):
29
+ "Safely get the repr() of an object, truncating if it exceeds max_len."
30
+ try:
31
+ s = str(obj)
32
+ return s[:max_len] + ("…" if len(s)>max_len else "")
33
+ except Exception as e: return f"<repr error: {str(e)}>"
34
+
35
+ # %% ../nbs/00_core.ipynb
36
+ @patch
37
+ def user_items(self:InteractiveShell, max_len=200, xtra_skip=()):
38
+ "Get user-defined vars & funcs from namespace."
39
+ ns = self.user_ns
40
+ ignore = {'In', 'Out', 'exit', 'quit', 'open', 'nbmeta', 'receive_nbmeta'}
41
+ ignore.add(xtra_skip)
42
+ rm_types = (
43
+ type, FunctionType, ModuleType, MethodType, BuiltinFunctionType,
44
+ getattr(typing, '_SpecialGenericAlias', ()),
45
+ getattr(typing, '_GenericAlias', ()),
46
+ getattr(typing, '_SpecialForm', ())
47
+ )
48
+ user_items = {k:v for k, v in ns.items()
49
+ if not k in ignore}
50
+ user_vars = {k:safe_repr(v, max_len=max_len)
51
+ for k, v in user_items.items() if not k.startswith('_') and not isinstance(v, rm_types)}
52
+ user_fns = {k:str(signature(v)) for k, v in user_items.items()
53
+ if isinstance(v, FunctionType) and v.__module__ == '__main__' and not k.startswith('__')}
54
+ return user_vars,user_fns
55
+
56
+ # %% ../nbs/00_core.ipynb
57
+ def _rank(c, s):
58
+ "Rank a completion `c` for text `s` with namespace `ns`."
59
+ parts = s.split('.')
60
+ is_public = not c.text.startswith('_')
61
+ if c.type=='param': r=1
62
+ elif c.mod=='__main__': r=2 # local
63
+ elif len(parts)>1 and parts[0]==c.mod: r=3 # module
64
+ elif c.mod=='builtins': r=4
65
+ else: r=5
66
+ return r if is_public else r+0.1
67
+
68
+ # %% ../nbs/00_core.ipynb
69
+ @patch
70
+ def ranked_complete(self:InteractiveShell, code, line_no=None, col_no=None):
71
+ ns = self.user_ns
72
+ lines = code.splitlines(True)
73
+ if line_no: offset = sum(len(lines[i]) for i in range(line_no-1)) + col_no -1
74
+ else: offset = len(code)
75
+ cs = self.Completer.completions(code, offset)
76
+ def _c(a):
77
+ res = dict2obj({attr: getattr(a, attr) for attr in dir(a) if attr[0]!='_'})
78
+ res['mod']= getattr(ns.get(a.text, None), '__module__', None)
79
+ res['rank'] = _rank(res, s=code)
80
+ return res
81
+ return [_c(c) for c in cs if not c.text.startswith('__')]
82
+
83
+ # %% ../nbs/00_core.ipynb
84
+ def _signatures(ns, s, line, col):
85
+ ctx = Interpreter(s, [ns]).get_signatures(line, col)
86
+ if not ctx: ctx = jscript(s).get_signatures(line, col)
87
+ return ctx
88
+
89
+ @patch
90
+ def sig_help(self:InteractiveShell, code, line_no=None, col_no=None):
91
+ ns = self.user_ns
92
+ ctx = _signatures(ns, code, line=line_no, col=col_no)
93
+ def _s(s): return {'label':s.description,'typ':s.type, 'mod':s.module_name, 'doc':s.docstring(),
94
+ 'idx':s.index, 'params':[{'name':p.name} for p in s.params]}
95
+ return [_s(opt) for opt in ctx]
96
+
97
+ # %% ../nbs/00_core.ipynb
98
+ @patch
99
+ def get_vars(self:InteractiveShell, vs:list):
100
+ "Get variables from namespace."
101
+ ns = self.user_ns
102
+ return {v:ns[v] for v in vs if v in ns}
103
+
104
+ # %% ../nbs/00_core.ipynb
105
+ def _get_schema(ns: dict, t):
106
+ "Check if tool `t` has errors."
107
+ if t not in ns: return f"`{t}` not found. Did you run it?"
108
+ try: return get_schema(ns[t])
109
+ except Exception as e: return f"`{t}`: {e}."
110
+
111
+ @patch
112
+ def get_schemas(self:InteractiveShell, fs:list):
113
+ "Get schemas from namespace."
114
+ ns = self.user_ns
115
+ 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.1
3
+ Version: 0.0.3
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 = %(repo)s
5
- version = 0.0.1
3
+ lib_name = ipykernel-helper
4
+ version = 0.0.3
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://%(user)s.github.io
25
- doc_baseurl = /%(repo)s
26
- git_url = https://github.com/%(user)s/%(repo)s
27
- title = %(lib_name)s
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, %(author)s
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,2 +0,0 @@
1
- __version__ = "0.0.1"
2
- from .core import *
@@ -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