Source documentation¶
kernel.py¶
- class kernel.metacall_jupyter(**kwargs)[source]¶
Defines the Jupyter Kernel declaration for MetaCall Core
- available_repl()[source]¶
Function to check for available REPLs on the MetaCall Kernel
- Parameters
None –
- Returns
List of REPLs available on the Kernel
- Return type
available_repl
- banner = 'Wrapper Kernel for MetaCall Core Library leveraging IPython and Jupyter'¶
- do_execute(code, silent, store_history=True, user_expressions=None, allow_stdin=False)[source]¶
Executes the User Code
- Parameters
code – The code to be executed
silent – Whether to display output
store_history – Whether to record this code in history and increase the execution count
user_expressions – Mapping of names to expressions to evaluate after the code has run
allow_stdin – Whether the frontend can provide input on request
- Returns
The history of the session.
- Return type
history (str)
- do_history(hist_access_type, output, raw, session=None, start=None, stop=None, n=None, pattern=None, unique=False)[source]¶
Get the history of a session
- Parameters
hist_access_type (str) – ‘tail’ or ‘range’
output (bool) – If True, then the history is printed to stdout. Otherwise, it is returned as a string.
raw (bool) – If True, then the history is not formatted in any way.
session (str) – The name of the session.
start (int) – The first execution count from the history to get.
stop (int) – The last execution count from the history to get.
n (int) – The number of executions to get.
pattern (str) – The pattern to search the history with.
unique (bool) – If True, then only unique history items are shown.
- Returns
The history of the session.
- Return type
history (str)
- do_shutdown(restart)[source]¶
Shuts down the Kernel
- Parameters
restart – Boolean value to determine the kernel is shutdown or restarted
- Returns
Boolean value to signal the kernel shutdown
- Return type
restart
- get_range(session, start, stop, raw, output)[source]¶
Gets the range of history items for a session
- Parameters
session – session name
start – start line number
stop – stop line number
raw – True to get the raw input
output – True to get the formatted output
- Returns
A list of tuples (source, input, output)
- Return type
result
- get_tail(n, raw, output, include_latest)[source]¶
Gets the last n lines of history, formatted nicely
- Parameters
n (int) – The number of lines to be fetched
raw (bool) – Whether to include raw_history
output (bool) – Whether to include output
include_latest (bool) – Whether to include the latest
- Returns
A list of lines
- Return type
list
- help_links¶
An instance of a Python list.
- history = {}¶
- history_db_ready = False¶
- implementation = 'Jupyter Kernel for MetaCall Core'¶
- implementation_version = '0.1'¶
- language = 'MetaCall Core'¶
- language_info = {'file_extension': '.txt', 'mimetype': 'text/plain', 'name': 'MetaCall Core'}¶
- language_version = '0.4.12'¶
- metacall_execute(code, extension)[source]¶
Executes the Code passed by creating a temporary file using a MetaCall Subprocess
- Parameters
code – Code to executed by the MetaCall subprocess
extension – The extension of the code to create a temporary file from
- Returns
The log output generated by the subprocess after a successful execution
- Return type
logger_output
- metacall_repl(code)[source]¶
Function to execute the user code and return the result through MetaCall subprocess.
- Parameters
code – The code to be executed
- Returns
The result of the execution
- Return type
result
- newfile_magic(code)[source]¶
Function to save a new file using the $newfile magic.
- Parameters
code (str) – The code to be executed
- record_history(session, count, code, data)[source]¶
Record the user code and the result of the user code to the history database.
- results = {}¶