-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from minrk/parallel-to-ipyparallel
move ipyparallel-specific code to this package
- Loading branch information
Showing
21 changed files
with
1,020 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .engine.datapub import publish_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Publishing native (typically pickled) objects.""" | ||
|
||
# Copyright (c) IPython Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
from traitlets.config import Configurable | ||
from traitlets import Instance, Dict, CBytes, Any | ||
from ipykernel.jsonutil import json_clean | ||
from ipyparallel.serialize import serialize_object | ||
from jupyter_client.session import Session, extract_header | ||
|
||
class ZMQDataPublisher(Configurable): | ||
|
||
topic = topic = CBytes(b'datapub') | ||
session = Instance(Session, allow_none=True) | ||
pub_socket = Any(allow_none=True) | ||
parent_header = Dict({}) | ||
|
||
def set_parent(self, parent): | ||
"""Set the parent for outbound messages.""" | ||
self.parent_header = extract_header(parent) | ||
|
||
def publish_data(self, data): | ||
"""publish a data_message on the IOPub channel | ||
Parameters | ||
---------- | ||
data : dict | ||
The data to be published. Think of it as a namespace. | ||
""" | ||
session = self.session | ||
buffers = serialize_object(data, | ||
buffer_threshold=session.buffer_threshold, | ||
item_threshold=session.item_threshold, | ||
) | ||
content = json_clean(dict(keys=list(data.keys()))) | ||
session.send(self.pub_socket, 'data_message', content=content, | ||
parent=self.parent_header, | ||
buffers=buffers, | ||
ident=self.topic, | ||
) | ||
|
||
|
||
def publish_data(data): | ||
"""publish a data_message on the IOPub channel | ||
Parameters | ||
---------- | ||
data : dict | ||
The data to be published. Think of it as a namespace. | ||
""" | ||
from ipykernel.zmqshell import ZMQInteractiveShell | ||
ZMQInteractiveShell.instance().data_pub.publish_data(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.