Skip to content

Commit

Permalink
forward 'ip' to LocalCluster (#107)
Browse files Browse the repository at this point in the history
* forward 'ip' to LocalCluster

* Adding tests

* Flake8 checks
  • Loading branch information
twoertwein authored and guillaumeeb committed Aug 7, 2018
1 parent 499936f commit 392a927
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dask_jobqueue/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,16 @@ def __init__(self,
#This attribute should be overriden
self.job_header = None

# Find the IP address and (if requested) set interface for workers
localhost_kwargs = {}
if interface:
host = get_ip_interface(interface)
localhost_kwargs['ip'] = get_ip_interface(interface)
extra += ' --interface %s ' % interface
else:
host = socket.gethostname()
localhost_kwargs['ip'] = socket.gethostname()
localhost_kwargs.update(kwargs)

self.local_cluster = LocalCluster(n_workers=0, ip=host, **kwargs)
self.local_cluster = LocalCluster(n_workers=0, **localhost_kwargs)

# Keep information on process, threads and memory, for use in
# subclasses
Expand Down
14 changes: 14 additions & 0 deletions dask_jobqueue/tests/test_jobqueue_core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import socket

from dask_jobqueue import JobQueueCluster, PBSCluster, MoabCluster, SLURMCluster, SGECluster, LSFCluster

Expand Down Expand Up @@ -27,3 +28,16 @@ def test_repr(Cluster):
assert 'cores=0' in cluster_repr
assert 'memory=0 B' in cluster_repr
assert 'workers=0' in cluster_repr


def test_forward_ip():
ip = '127.0.0.1'
with PBSCluster(walltime='00:02:00', processes=4, cores=8, memory='28GB',
name='dask-worker', ip=ip) as cluster:
assert cluster.local_cluster.scheduler.ip == ip

default_ip = socket.gethostbyname(socket.gethostname())
assert default_ip != ip
with PBSCluster(walltime='00:02:00', processes=4, cores=8, memory='28GB',
name='dask-worker') as cluster:
assert cluster.local_cluster.scheduler.ip == default_ip

0 comments on commit 392a927

Please sign in to comment.