Skip to content

Commit 28cb6bc

Browse files
test
1 parent 7b46bd9 commit 28cb6bc

File tree

5 files changed

+34
-67
lines changed

5 files changed

+34
-67
lines changed

run_personal/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

run_shared/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

singlestoredb/magics/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from IPython.core.interactiveshell import InteractiveShell
2+
3+
from .run_personal import RunPersonalMagic
4+
from .run_shared import RunSharedMagic
5+
6+
# In order to actually use these magics, we must register them with a
7+
# running IPython.
8+
9+
10+
def load_ipython_extension(ip: InteractiveShell) -> None:
11+
"""
12+
Any module file that define a function named `load_ipython_extension`
13+
can be loaded via `%load_ext module.path` or be configured to be
14+
autoloaded by IPython at startup time.
15+
"""
16+
17+
# Load jupysql extension
18+
# This is necessary for jupysql to initialize internal state
19+
# required to render messages
20+
assert ip.extension_manager is not None
21+
result = ip.extension_manager.load_extension('sql')
22+
if result == 'no load function':
23+
raise RuntimeError('Could not load sql extension. Is jupysql installed?')
24+
25+
# Check if %run magic command is defined
26+
if ip.find_line_magic('run') is None:
27+
raise RuntimeError(
28+
'%run magic command is not defined. '
29+
'Is it available in your IPython environment?',
30+
)
31+
32+
# Register run_personal and run_shared
33+
ip.register_magics(RunPersonalMagic(ip))
34+
ip.register_magics(RunSharedMagic(ip))
Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,3 @@ def run_personal(self, line: str, local_ns: Any = None) -> Any:
5555
# Delete the local file after running it
5656
if os.path.exists(local_filename):
5757
os.remove(local_filename)
58-
59-
60-
# In order to actually use these magics, you must register them with a
61-
# running IPython.
62-
63-
64-
def load_ipython_extension(ip: InteractiveShell) -> None:
65-
"""
66-
Any module file that define a function named `load_ipython_extension`
67-
can be loaded via `%load_ext module.path` or be configured to be
68-
autoloaded by IPython at startup time.
69-
"""
70-
71-
# Load jupysql extension
72-
# This is necessary for jupysql to initialize internal state
73-
# required to render messages
74-
assert ip.extension_manager is not None
75-
result = ip.extension_manager.load_extension('sql')
76-
if result == 'no load function':
77-
raise RuntimeError('Could not load sql extension. Is jupysql installed?')
78-
79-
# Check if %run magic command is defined
80-
if ip.find_line_magic('run') is None:
81-
raise RuntimeError(
82-
'%run magic command is not defined. '
83-
'Is it available in your IPython environment?',
84-
)
85-
86-
# Register run_personal
87-
ip.register_magics(RunPersonalMagic(ip))
Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,3 @@ def run_shared(self, line: str, local_ns: Any = None) -> Any:
5353
# Delete the local file after running it
5454
if os.path.exists(local_filename):
5555
os.remove(local_filename)
56-
57-
# In order to actually use these magics, you must register them with a
58-
# running IPython.
59-
60-
61-
def load_ipython_extension(ip: InteractiveShell) -> None:
62-
"""
63-
Any module file that define a function named `load_ipython_extension`
64-
can be loaded via `%load_ext module.path` or be configured to be
65-
autoloaded by IPython at startup time.
66-
"""
67-
68-
# Load jupysql extension
69-
# This is necessary for jupysql to initialize internal state
70-
# required to render messages
71-
assert ip.extension_manager is not None
72-
result = ip.extension_manager.load_extension('sql')
73-
if result == 'no load function':
74-
raise RuntimeError('Could not load sql extension. Is jupysql installed?')
75-
76-
# Check if %run magic command is defined
77-
if ip.find_line_magic('run') is None:
78-
raise RuntimeError(
79-
'%run magic command is not defined. '
80-
'Is it available in your IPython environment?',
81-
)
82-
83-
# Register run_shared
84-
ip.register_magics(RunSharedMagic(ip))

0 commit comments

Comments
 (0)