Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove use of ipython_genutils #557

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
# C: complexity
# F401: module imported but unused
# F403: import *
# F811: redefinition of unused `name` from line `N`
# F841: local variable assigned but never used
# E402: module level import not at top of file
# I100: Import statements are in the wrong order
# I101: Imported names are in the wrong order. Should be
ignore = E, C, W, F401, F403, F811, F841, E402, I100, I101, D400
ignore = E, C, W, F403, F841, E402, I100, I101, D400
builtins = c, get_config
exclude =
.cache,
Expand Down
5 changes: 0 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import shlex
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))

# We load the ipython release info into a dict by explicit execution
iprelease = {}
exec(
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/Using Dill.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
"import ipyparallel as ipp\n",
"\n",
"@interactive\n",
"class C(object):\n",
"class C:\n",
" a = 5\n",
"\n",
"@ipp.interactive\n",
Expand Down
7 changes: 3 additions & 4 deletions docs/source/examples/customresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
* MinRK
"""
import random
import time

import ipyparallel as parallel
import ipyparallel as ipp

# create client & views
rc = parallel.Client()
rc = ipp.Client()
dv = rc[:]
v = rc.load_balanced_view()

Expand All @@ -41,7 +40,7 @@ def sleep_here(count, t):
while pending:
try:
rc.wait(pending, 1e-3)
except parallel.TimeoutError:
except TimeoutError:
# ignore timeouterrors, since they only mean that at least one isn't done
pass
# finished is the set of msg_ids that are complete
Expand Down
1 change: 0 additions & 1 deletion docs/source/examples/daVinci Word Count/pwordfreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io
import os
import time
import urllib
from itertools import repeat

import requests
Expand Down
4 changes: 0 additions & 4 deletions docs/source/examples/daVinci Word Count/wordfreq.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
"""Count the frequencies of words in a string"""
from __future__ import division
from __future__ import print_function

import cmath as math


def wordfreq(text, is_filename=False):
Expand Down
1 change: 0 additions & 1 deletion docs/source/examples/dagdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* MinRK
"""
from random import randint
from random import random

import networkx as nx

Expand Down
21 changes: 5 additions & 16 deletions docs/source/examples/fetchparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,18 @@

ipcluster start -n 4
"""
from __future__ import print_function

import sys
import time

import bs4 # this isn't necessary, but it helps throw the dependency error earlier
import bs4 # noqa this isn't necessary, but it helps throw the dependency error earlier

import ipyparallel as ipp

try:
raw_input
except NameError:
raw_input = input


def fetchAndParse(url, data=None):
import requests

try:
from urllib.parse import urljoin
except ImportError:
from urlparse import urljoin
import bs4
from urllib.parse import urljoin
import bs4 # noqa

links = []
r = requests.get(url, data=data)
Expand All @@ -46,7 +35,7 @@ def fetchAndParse(url, data=None):
return links


class DistributedSpider(object):
class DistributedSpider:

# Time to wait between polling for task results.
pollingDelay = 0.5
Expand Down Expand Up @@ -103,7 +92,7 @@ def main():
if len(sys.argv) > 1:
site = sys.argv[1]
else:
site = raw_input('Enter site to crawl: ')
site = input('Enter site to crawl: ')
distributedSpider = DistributedSpider(site)
distributedSpider.run()

Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/interengine/bintree.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def disambiguate_dns_url(url, location):
return disambiguate_url(url, location)


class BinaryTreeCommunicator(object):
class BinaryTreeCommunicator:

id = None
pub = None
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/interengine/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ipyparallel.util import disambiguate_url


class EngineCommunicator(object):
class EngineCommunicator:
def __init__(self, interface='tcp://*', identity=None):
self._ctx = zmq.Context()
self.socket = self._ctx.socket(zmq.XREP)
Expand Down
2 changes: 0 additions & 2 deletions docs/source/examples/interengine/interengine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import sys

import ipyparallel as ipp


Expand Down
2 changes: 0 additions & 2 deletions docs/source/examples/phistogram.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Parallel histogram function"""
import numpy

from ipyparallel import Reference


Expand Down
1 change: 0 additions & 1 deletion docs/source/examples/pi/parallelpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from timeit import default_timer as clock

import numpy as np
from matplotlib import pyplot as plt
from pidigits import compute_two_digit_freqs
from pidigits import fetch_pi_file
Expand Down
11 changes: 2 additions & 9 deletions docs/source/examples/pi/pidigits.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,19 @@
If the digits of pi are truly random, these frequencies
should be equal.
"""
# Import statements
from __future__ import division
from __future__ import with_statement
import os
from urllib.request import urlretrieve

import numpy as np
from matplotlib import pyplot as plt

try: # python2
from urllib import urlretrieve
except ImportError: # python3
from urllib.request import urlretrieve

# Top-level functions


def fetch_pi_file(filename):
"""This will download a segment of pi from super-computing.org
if the file is not already present.
"""
import os, urllib

ftpdir = "ftp://pi.super-computing.org/.2/pi200m/"
if os.path.exists(filename):
Expand Down
10 changes: 3 additions & 7 deletions docs/source/examples/task_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
overhead of a single task is about 0.001-0.01 seconds.
"""
import random
import sys
import time
from optparse import OptionParser

from IPython.utils.timing import time

import ipyparallel as ipp


Expand Down Expand Up @@ -54,8 +52,6 @@ def main():
print(view)
rc.block = True
nengines = len(rc.ids)
with rc[:].sync_imports():
from IPython.utils.timing import time

# the jobs should take a random time within a range
times = [
Expand All @@ -68,10 +64,10 @@ def main():
% (opts.n, stime, nengines)
)
time.sleep(1)
start = time.time()
start = time.perf_counter()
amr = view.map(time.sleep, times)
amr.get()
stop = time.time()
stop = time.perf_counter()

ptime = stop - start
scale = stime / ptime
Expand Down
2 changes: 0 additions & 2 deletions docs/source/examples/wave2D/RectPartitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"""
from __future__ import print_function

import time

from numpy import ascontiguousarray
from numpy import frombuffer
from numpy import zeros
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/wave2D/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ipyparallel.util import disambiguate_url


class EngineCommunicator(object):
class EngineCommunicator:
"""An object that connects Engines to each other.
north and east sockets listen, while south and west sockets connect.

Expand Down
6 changes: 1 addition & 5 deletions docs/source/examples/wave2D/parallelwave-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@
* Min Ragan-Kelley

"""
import sys
import argparse
import time

from IPython.external import argparse
from numpy import exp
from numpy import newaxis
from numpy import sqrt
from numpy import zeros

import ipyparallel as ipp

Expand Down
7 changes: 1 addition & 6 deletions docs/source/examples/wave2D/parallelwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@
* Min Ragan-Kelley

"""
#
import sys
import argparse
import time

from IPython.external import argparse
from numpy import exp
from numpy import newaxis
from numpy import sqrt
from numpy import zeros

import ipyparallel as ipp

Expand Down
3 changes: 1 addition & 2 deletions docs/source/examples/wave2D/wavesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import time

from numpy import arange
from numpy import exp
from numpy import newaxis
from numpy import sqrt
from numpy import zeros
Expand All @@ -32,7 +31,7 @@ def iseq(start=0, stop=None, inc=1):
return arange(start, stop + inc, inc)


class WaveSolver(object):
class WaveSolver:
"""
Solve the 2D wave equation u_tt = u_xx + u_yy + f(x,y,t) with
u = bc(x,y,t) on the boundary and initial condition du/dt = 0.
Expand Down
28 changes: 12 additions & 16 deletions ipyparallel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@
"""The IPython ZMQ-based parallel computing interface."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import warnings

import zmq
from traitlets.config.configurable import MultipleInstanceError

from ._version import __version__
from ._version import version_info
from .client.asyncresult import *
from .client.client import Client
from .client.remotefunction import *
from .client.view import *
from .cluster import Cluster
from .cluster import ClusterManager
from .controller.dependency import *
from .error import *
from .serialize import *
from .util import interactive
from ._version import __version__ # noqa
from ._version import version_info # noqa
from .client.asyncresult import * # noqa
from .client.client import Client # noqa
from .client.remotefunction import * # noqa
from .client.view import * # noqa
from .cluster import Cluster # noqa
from .cluster import ClusterManager # noqa
from .controller.dependency import * # noqa
from .error import * # noqa
from .serialize import * # noqa
from .util import interactive # noqa

# -----------------------------------------------------------------------------
# Functions
Expand Down
9 changes: 3 additions & 6 deletions ipyparallel/apps/baseapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
from IPython.core.application import base_flags as base_ip_flags
from IPython.core.application import BaseIPythonApplication
from IPython.utils.path import expand_path
from IPython.utils.process import check_pid
from ipython_genutils import py3compat
from ipython_genutils.py3compat import unicode_type
from jupyter_client.session import Session
from tornado.ioloop import IOLoop
from traitlets import Bool
Expand Down Expand Up @@ -87,12 +84,12 @@ def _log_format_default(self):
return u"%(asctime)s.%(msecs).03d [%(name)s]%(highlevel)s %(message)s"

work_dir = Unicode(
py3compat.getcwd(), config=True, help='Set the working dir for the process.'
os.getcwd(), config=True, help='Set the working dir for the process.'
)

@observe('work_dir')
def _work_dir_changed(self, change):
self.work_dir = unicode_type(expand_path(change['new']))
self.work_dir = str(expand_path(change['new']))

log_to_file = Bool(config=True, help="whether to log to a file")

Expand Down Expand Up @@ -170,7 +167,7 @@ def init_deprecated_config(self):

def to_work_dir(self):
wd = self.work_dir
if unicode_type(wd) != py3compat.getcwd():
if wd != os.getcwd():
os.chdir(wd)
self.log.info("Changing to working dir: %s" % wd)
# This is the working dir by now.
Expand Down
2 changes: 1 addition & 1 deletion ipyparallel/apps/ipclusterapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

warnings.warn(f"{__name__} is deprecated in ipyparallel 7. Use ipyparallel.cluster")

from ipyparallel.cluster.app import IPCluster, IPClusterStart, main
from ipyparallel.cluster.app import IPCluster, IPClusterStart, main # noqa

IPClusterApp = IPCluster
launch_new_instance = main
Expand Down
Loading