本文整理汇总了Python中ipykernel.comm.Comm方法的典型用法代码示例。如果您正苦于以下问题:Python comm.Comm方法的具体用法?Python comm.Comm怎么用?Python comm.Comm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ipykernel.comm
的用法示例。
在下文中一共展示了comm.Comm方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def __init__(self, wsport=None, wsuri=None):
global sender
baseObj.glow = self
if _isnotebook:
from ipykernel.comm import Comm
if (wsport):
self.comm = Comm(target_name='glow', data={'wsport':wsport, 'wsuri':wsuri})
else:
self.comm = Comm(target_name='glow')
self.comm.on_close(self.handle_close)
self.comm.on_msg(self.handle_msg)
sender = self.comm.send
self.show = True
else:
sender = None
## baseObj.object_registry = {}
## idx -> instance
示例2: __init__
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def __init__(self, manager):
self.supports_binary = None
self.manager = manager
self.uuid = str(uuid.uuid4())
# Publish an output area with a unique ID. The javascript can then
# hook into this area.
display(HTML("<div id=%r></div>" % self.uuid))
try:
self.comm = Comm('matplotlib', data={'id': self.uuid})
except AttributeError:
raise RuntimeError('Unable to create an IPython notebook Comm '
'instance. Are you in the IPython notebook?')
self.comm.on_msg(self.on_message)
manager = self.manager
self._ext_close = False
def _on_close(close_message):
self._ext_close = True
manager.remove_comm(close_message['content']['comm_id'])
manager.clearup_closed()
self.comm.on_close(_on_close)
示例3: __init__
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def __init__(self, session=None, json=None, auth=None):
self.session = session
self.id = json.get('id')
self.auth = auth
if self.session.lgn.ipython_enabled:
from ipykernel.comm import Comm
self.comm = Comm('lightning', {'id': self.id})
self.comm_handlers = {}
self.comm.on_msg(self._handle_comm_message)
示例4: open
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def open(self):
"""Open a comm to the frontend if one isn't already open."""
if self.comm is None:
state, buffer_paths, buffers = _remove_buffers(self.get_state())
args = dict(target_name='jupyter.widget',
data={'state': state, 'buffer_paths': buffer_paths},
buffers=buffers,
metadata={'version': __protocol_version__}
)
if self._model_id is not None:
args['comm_id'] = self._model_id
self.comm = Comm(**args)
示例5: model_id
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def model_id(self):
"""Gets the model id of this widget.
If a Comm doesn't exist yet, a Comm will be created automagically."""
return self.comm.comm_id
#-------------------------------------------------------------------------
# Methods
#-------------------------------------------------------------------------
示例6: _get_comm
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def _get_comm():
# pylint: disable=import-error
from ipykernel.comm import Comm
return Comm(target_name='neptune_comm')
示例7: locate_jpd_comm
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def locate_jpd_comm(da_id, app, app_path):
global local_comms
comm = local_comms.get(da_id, None )
if comm is None:
comm = Comm(target_name='jpd_%s' %da_id,
data={'jpd_type':'inform',
'da_id':da_id})
@comm.on_msg
def callback(msg, app=app, da_id=da_id, app_path=app_path):
# TODO see if app and da_id args needed for this closure
content = msg['content']
data = content['data']
stem = data['stem']
args = data['args']
#app_path = "app/endpoints/%s" % da_id
response, mimetype = app.process_view(stem, args, app_path)
comm.send({'jpd_type':'response',
'da_id':da_id,
'app':str(app),
'response':response,
'mimetype':mimetype})
local_comms[da_id] = comm
return comm
示例8: open
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def open(self, props):
props['module'] = self.module
args = dict(target_name=self.target_name, data=props)
args['comm_id'] = 'jupyter_react.{}.{}'.format( uuid.uuid4(), props['module'] )
self.comm = Comm(**args)
示例9: __init__
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def __init__(self, id):
# Use comm to send a message from the kernel
self.comm = Comm(target_name=id, data={})
示例10: _train_visualize
# 需要导入模块: from ipykernel import comm [as 别名]
# 或者: from ipykernel.comm import Comm [as 别名]
def _train_visualize(self, table, attributes=None, inputs=None, nominals=None, texts=None, valid_table=None,
valid_freq=1, model=None, init_weights=None, model_weights=None, target=None,
target_sequence=None, sequence=None, text_parms=None, weight=None, gpu=None, seed=0,
record_seed=None, missing='mean', optimizer=None, target_missing='mean', best_weights=None,
repeat_weight_table=False, force_equal_padding=None, data_specs=None, n_threads=None,
target_order='ascending', x=None, y=None, y_loss=None, total_sample_size=None, e=None,
iter_history=None, freq=None, status=None):
"""
Function that calls the training action enriched with training history visualization.
This is an internal private function and for documentation, please refer to fit() or train()
"""
self._train_visualization()
b_w = None
if best_weights is not None:
b_w = dict(replace=True, name=best_weights)
if optimizer is not None:
optimizer['log_level'] = 3
else:
optimizer=Optimizer(log_level=3)
parameters = DLPyDict(table=table, attributes=attributes, inputs=inputs, nominals=nominals, texts=texts,
valid_table=valid_table, valid_freq=valid_freq, model=model, init_weights=init_weights,
model_weights=model_weights, target=target, target_sequence=target_sequence,
sequence=sequence, text_parms=text_parms, weight=weight, gpu=gpu, seed=seed,
record_seed=record_seed, missing=missing, optimizer=optimizer,
target_missing=target_missing, best_weights=b_w, repeat_weight_table=repeat_weight_table,
force_equal_padding=force_equal_padding, data_specs=data_specs, n_threads=n_threads,
target_order=target_order)
import swat
from ipykernel.comm import Comm
comm = Comm(target_name='%(plot_id)s_comm' % dict(plot_id='foo'))
# the recordSeed option must not be specified in order to disable it, contrary to the Viya documentation
if record_seed == 0 or record_seed is None:
del parameters['record_seed']
with swat.option_context(print_messages=False):
self._retrieve_('deeplearn.dltrain', message_level='note',
responsefunc=_pre_parse_results(x, y, y_loss, total_sample_size,
e, comm, iter_history, freq, status),
**parameters)
if status[0] == 0:
self.model_ever_trained = True
return iter_history[0]
else:
return None