Skip to content

Commit

Permalink
remove deprecated ipykernel imports
Browse files Browse the repository at this point in the history
import from ipyparallel instead.
  • Loading branch information
minrk committed Oct 27, 2015
1 parent 6580310 commit b4a831d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 52 deletions.
2 changes: 1 addition & 1 deletion examples/Using Dill.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
"This is equivalent to\n",
"\n",
"```python\n",
"from ipykernel.pickleutil import use_dill\n",
"from ipyparallel.serialize import use_dill\n",
"use_dill()\n",
"rc[:].apply(use_dill)\n",
"```"
Expand Down
2 changes: 1 addition & 1 deletion ipyparallel/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from ipyparallel import util

from jupyter_client.session import Session, Message
from ipykernel import serialize
from ipyparallel import serialize

from .asyncresult import AsyncResult, AsyncHubResult
from .view import DirectView, LoadBalancedView
Expand Down
16 changes: 8 additions & 8 deletions ipyparallel/client/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
from __future__ import print_function

import imp
import sys
import warnings
from contextlib import contextmanager
from types import ModuleType

import zmq

from ipykernel import pickleutil
from .. import serialize
from traitlets import (
HasTraits, Any, Bool, List, Dict, Set, Instance, CFloat, Integer
)
Expand Down Expand Up @@ -500,16 +498,18 @@ def use_dill(self):
adds support for closures, etc.
This calls ipykernel.pickleutil.use_dill() here and on each engine.
This calls ipyparallel.serialize.use_dill() here and on each engine.
"""
pickleutil.use_dill()
return self.apply(pickleutil.use_dill)
serialize.use_dill()
return self.apply(serialize.use_dill)

def use_cloudpickle(self):
"""Expand serialization support with cloudpickle.
This calls ipyparallel.serialize.use_cloudpickle() here and on each engine.
"""
pickleutil.use_cloudpickle()
return self.apply(pickleutil.use_cloudpickle)
serialize.use_cloudpickle()
return self.apply(serialize.use_cloudpickle)


@sync_results
Expand Down
4 changes: 2 additions & 2 deletions ipyparallel/controller/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ipyparallel.util import interactive
from ipython_genutils import py3compat
from ipython_genutils.py3compat import string_types
from ipykernel.pickleutil import can, uncan
from ipyparallel.serialize import can, uncan

class depend(object):
"""Dependency decorator, for use with tasks.
Expand Down Expand Up @@ -81,7 +81,7 @@ def __name__(self):
def _require(*modules, **mapping):
"""Helper for @require decorator."""
from ipyparallel.error import UnmetDependency
from ipykernel.pickleutil import uncan
from ipyparallel.serialize import uncan
user_ns = globals()
for name in modules:
try:
Expand Down
2 changes: 1 addition & 1 deletion ipyparallel/serialize/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .canning import Reference, can_map, uncan_map
from .canning import Reference, can_map, uncan_map, can, uncan
from .serialize import (
serialize_object, deserialize_object,
pack_apply_message, unpack_apply_message,
Expand Down
4 changes: 2 additions & 2 deletions ipyparallel/serialize/canning.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def use_dill():
pickle = dill

try:
from ipykernel import serialize
from . import serialize
except ImportError:
pass
else:
Expand All @@ -103,7 +103,7 @@ def use_cloudpickle():
pickle = cloudpickle

try:
from ipykernel import serialize
from . import serialize
except ImportError:
pass
else:
Expand Down
2 changes: 1 addition & 1 deletion ipyparallel/serialize/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from itertools import chain

from ipython_genutils.py3compat import PY3, buffer_to_bytes_py2
from ipykernel.pickleutil import (
from .canning import (
can, uncan, can_sequence, uncan_sequence, CannedObject,
istype, sequence_types, PICKLE_PROTOCOL,
)
Expand Down
2 changes: 1 addition & 1 deletion ipyparallel/tests/test_asyncresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def test_await_data(self):
v = self.client[-1]
ar = v.execute('\n'.join([
"import time",
"from ipykernel.datapub import publish_data",
"from ipyparallel.datapub import publish_data",
"for i in range(5):",
" publish_data(dict(i=i))",
" time.sleep(0.1)",
Expand Down
50 changes: 17 additions & 33 deletions ipyparallel/tests/test_dependency.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
"""Tests for dependency.py
"""Tests for dependency.py"""

Authors:
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

* Min RK
"""

__docformat__ = "restructuredtext en"

#-------------------------------------------------------------------------------
# Copyright (C) 2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
# Imports
#-------------------------------------------------------------------------------

# import
import os

from ipykernel.pickleutil import can, uncan
from ipyparallel.serialize import can, uncan

import ipyparallel as pmod
import ipyparallel as ipp
from ipyparallel.util import interactive

from ipyparallel.tests import add_engines
Expand All @@ -32,12 +16,12 @@
def setup():
add_engines(1, total=True)

@pmod.require('time')
@ipp.require('time')
def wait(n):
time.sleep(n)
return n

@pmod.interactive
@ipp.interactive
def func(x):
return x*x

Expand Down Expand Up @@ -74,35 +58,35 @@ def cancan(self, f):
def test_require_imports(self):
"""test that @require imports names"""
@self.cancan
@pmod.require('base64')
@ipp.require('base64')
@interactive
def encode(arg):
return base64.b64encode(arg)
# must pass through canning to properly connect namespaces
self.assertEqual(encode(b'foo'), b'Zm9v')

def test_success_only(self):
dep = pmod.Dependency(mixed, success=True, failure=False)
dep = ipp.Dependency(mixed, success=True, failure=False)
self.assertUnmet(dep)
self.assertUnreachable(dep)
dep.all=False
self.assertMet(dep)
self.assertReachable(dep)
dep = pmod.Dependency(completed, success=True, failure=False)
dep = ipp.Dependency(completed, success=True, failure=False)
self.assertMet(dep)
self.assertReachable(dep)
dep.all=False
self.assertMet(dep)
self.assertReachable(dep)

def test_failure_only(self):
dep = pmod.Dependency(mixed, success=False, failure=True)
dep = ipp.Dependency(mixed, success=False, failure=True)
self.assertUnmet(dep)
self.assertUnreachable(dep)
dep.all=False
self.assertMet(dep)
self.assertReachable(dep)
dep = pmod.Dependency(completed, success=False, failure=True)
dep = ipp.Dependency(completed, success=False, failure=True)
self.assertUnmet(dep)
self.assertUnreachable(dep)
dep.all=False
Expand All @@ -111,12 +95,12 @@ def test_failure_only(self):

def test_require_function(self):

@pmod.interactive
@ipp.interactive
def bar(a):
return func(a)

@pmod.require(func)
@pmod.interactive
@ipp.require(func)
@ipp.interactive
def bar2(a):
return func(a)

Expand All @@ -127,8 +111,8 @@ def bar2(a):

def test_require_object(self):

@pmod.require(foo=func)
@pmod.interactive
@ipp.require(foo=func)
@ipp.interactive
def bar(a):
return foo(a)

Expand Down
4 changes: 2 additions & 2 deletions ipyparallel/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ def bar(f=foo):
def test_data_pub_single(self):
view = self.client[-1]
ar = view.execute('\n'.join([
'from ipykernel.datapub import publish_data',
'from ipyparallel.datapub import publish_data',
'for i in range(5):',
' publish_data(dict(i=i))'
]), block=False)
Expand All @@ -722,7 +722,7 @@ def test_data_pub_single(self):
def test_data_pub(self):
view = self.client[:]
ar = view.execute('\n'.join([
'from ipykernel.datapub import publish_data',
'from ipyparallel.datapub import publish_data',
'for i in range(5):',
' publish_data(dict(i=i))'
]), block=False)
Expand Down

0 comments on commit b4a831d

Please sign in to comment.