ipykernel-helper 0.0.2__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 (20) hide show
  1. {ipykernel_helper-0.0.2/ipykernel_helper.egg-info → ipykernel_helper-0.0.3}/PKG-INFO +1 -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.2 → ipykernel_helper-0.0.3}/ipykernel_helper/core.py +21 -23
  5. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3/ipykernel_helper.egg-info}/PKG-INFO +1 -1
  6. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/settings.ini +1 -1
  7. ipykernel_helper-0.0.2/ipykernel_helper/__init__.py +0 -2
  8. ipykernel_helper-0.0.2/ipykernel_helper/_modidx.py +0 -18
  9. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/LICENSE +0 -0
  10. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/MANIFEST.in +0 -0
  11. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/README.md +0 -0
  12. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/SOURCES.txt +0 -0
  13. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/dependency_links.txt +0 -0
  14. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/entry_points.txt +0 -0
  15. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/not-zip-safe +0 -0
  16. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/requires.txt +0 -0
  17. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/ipykernel_helper.egg-info/top_level.txt +0 -0
  18. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/pyproject.toml +0 -0
  19. {ipykernel_helper-0.0.2 → ipykernel_helper-0.0.3}/setup.cfg +0 -0
  20. {ipykernel_helper-0.0.2 → 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.2
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
@@ -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')}}}
@@ -3,7 +3,7 @@
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
4
4
 
5
5
  # %% auto 0
6
- __all__ = ['safe_repr', 'user_items', 'ranked_complete', 'sig_help', 'get_vars', 'get_schemas']
6
+ __all__ = ['safe_repr']
7
7
 
8
8
  # %% ../nbs/00_core.ipynb
9
9
  from fastcore.meta import delegates
@@ -15,9 +15,12 @@ from functools import cmp_to_key,partial
15
15
  from toolslm.funccall import *
16
16
 
17
17
  from jupyter_client import AsyncKernelClient
18
+ from IPython.core.interactiveshell import InteractiveShell
18
19
  from IPython.core.completer import ProvisionalCompleterWarning
19
20
  from jedi import Interpreter, Script as jscript
20
21
 
22
+ from IPython.core.display import DisplayObject
23
+
21
24
  # %% ../nbs/00_core.ipynb
22
25
  warnings.filterwarnings('ignore', category=ProvisionalCompleterWarning)
23
26
 
@@ -30,9 +33,10 @@ def safe_repr(obj, max_len=200):
30
33
  except Exception as e: return f"<repr error: {str(e)}>"
31
34
 
32
35
  # %% ../nbs/00_core.ipynb
33
- def user_items(ns=None, max_len=200, xtra_skip=()):
36
+ @patch
37
+ def user_items(self:InteractiveShell, max_len=200, xtra_skip=()):
34
38
  "Get user-defined vars & funcs from namespace."
35
- if ns is None: ns = currentframe().f_back.f_globals
39
+ ns = self.user_ns
36
40
  ignore = {'In', 'Out', 'exit', 'quit', 'open', 'nbmeta', 'receive_nbmeta'}
37
41
  ignore.add(xtra_skip)
38
42
  rm_types = (
@@ -49,16 +53,6 @@ def user_items(ns=None, max_len=200, xtra_skip=()):
49
53
  if isinstance(v, FunctionType) and v.__module__ == '__main__' and not k.startswith('__')}
50
54
  return user_vars,user_fns
51
55
 
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
56
  # %% ../nbs/00_core.ipynb
63
57
  def _rank(c, s):
64
58
  "Rank a completion `c` for text `s` with namespace `ns`."
@@ -72,15 +66,16 @@ def _rank(c, s):
72
66
  return r if is_public else r+0.1
73
67
 
74
68
  # %% ../nbs/00_core.ipynb
75
- def ranked_complete(code, line_no=None, col_no=None):
76
- ipy = get_ipython()
69
+ @patch
70
+ def ranked_complete(self:InteractiveShell, code, line_no=None, col_no=None):
71
+ ns = self.user_ns
77
72
  lines = code.splitlines(True)
78
73
  if line_no: offset = sum(len(lines[i]) for i in range(line_no-1)) + col_no -1
79
74
  else: offset = len(code)
80
- cs = ipy.Completer.completions(code, offset)
75
+ cs = self.Completer.completions(code, offset)
81
76
  def _c(a):
82
77
  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)
78
+ res['mod']= getattr(ns.get(a.text, None), '__module__', None)
84
79
  res['rank'] = _rank(res, s=code)
85
80
  return res
86
81
  return [_c(c) for c in cs if not c.text.startswith('__')]
@@ -91,17 +86,19 @@ def _signatures(ns, s, line, col):
91
86
  if not ctx: ctx = jscript(s).get_signatures(line, col)
92
87
  return ctx
93
88
 
94
- def sig_help(code, line_no=None, col_no=None):
95
- ns = get_ipython().user_ns
89
+ @patch
90
+ def sig_help(self:InteractiveShell, code, line_no=None, col_no=None):
91
+ ns = self.user_ns
96
92
  ctx = _signatures(ns, code, line=line_no, col=col_no)
97
93
  def _s(s): return {'label':s.description,'typ':s.type, 'mod':s.module_name, 'doc':s.docstring(),
98
94
  'idx':s.index, 'params':[{'name':p.name} for p in s.params]}
99
95
  return [_s(opt) for opt in ctx]
100
96
 
101
97
  # %% ../nbs/00_core.ipynb
102
- def get_vars(vs:list):
98
+ @patch
99
+ def get_vars(self:InteractiveShell, vs:list):
103
100
  "Get variables from namespace."
104
- ns = get_ipython().user_ns
101
+ ns = self.user_ns
105
102
  return {v:ns[v] for v in vs if v in ns}
106
103
 
107
104
  # %% ../nbs/00_core.ipynb
@@ -111,7 +108,8 @@ def _get_schema(ns: dict, t):
111
108
  try: return get_schema(ns[t])
112
109
  except Exception as e: return f"`{t}`: {e}."
113
110
 
114
- def get_schemas(fs:list):
111
+ @patch
112
+ def get_schemas(self:InteractiveShell, fs:list):
115
113
  "Get schemas from namespace."
116
- ns = get_ipython().user_ns
114
+ ns = self.user_ns
117
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.2
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
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = ipykernel-helper
3
3
  lib_name = ipykernel-helper
4
- version = 0.0.2
4
+ version = 0.0.3
5
5
  min_python = 3.9
6
6
  license = apache2
7
7
  black_formatting = False
@@ -1,2 +0,0 @@
1
- __version__ = "0.0.2"
2
- from .core import *
@@ -1,18 +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.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')}}}