Repository: yt-project/yt

Issue:
Rockstar interface broken with python 3


### Bug report

**Bug summary**

Running the nested grid cookbook recipe for finding halos with rockstar fails.
Works (no abort) using python 2.

**Code for reproduction**

see http://yt-project.org/docs/dev/cookbook/rockstar_nest.py linked here http://yt-project.org/docs/dev/cookbook/cosmological_analysis.html#running-rockstar-to-find-halos-on-multi-resolution-particle-datasets

**Actual outcome**

```
yt : [INFO     ] 2017-05-20 11:40:57,264 Global parallel computation enabled: 2 / 3
yt : [INFO     ] 2017-05-20 11:40:57,264 Global parallel computation enabled: 0 / 3
yt : [INFO     ] 2017-05-20 11:40:57,264 Global parallel computation enabled: 1 / 3
P000 yt : [INFO     ] 2017-05-20 11:40:58,783 Parameters: current_time              = 14.1336338797
P000 yt : [INFO     ] 2017-05-20 11:40:58,783 Parameters: domain_dimensions         = [128 128 128]
P000 yt : [INFO     ] 2017-05-20 11:40:58,793 Parameters: domain_left_edge          = [ 0.  0.  0.]
P000 yt : [INFO     ] 2017-05-20 11:40:58,794 Parameters: domain_right_edge         = [ 1.  1.  1.]
P000 yt : [INFO     ] 2017-05-20 11:40:58,794 Parameters: cosmological_simulation   = 1
P000 yt : [INFO     ] 2017-05-20 11:40:58,795 Parameters: current_redshift          = 14.092558914923
P000 yt : [INFO     ] 2017-05-20 11:40:58,795 Parameters: omega_lambda              = 0.6911
P000 yt : [INFO     ] 2017-05-20 11:40:58,795 Parameters: omega_matter              = 0.3089
P000 yt : [INFO     ] 2017-05-20 11:40:58,795 Parameters: hubble_constant           = 0.6774
P000 yt : [INFO     ] 2017-05-20 11:40:58,861 Starting 'Parsing Hierarchy '
P002 yt : [INFO     ] 2017-05-20 11:40:58,861 Starting 'Parsing Hierarchy '
P001 yt : [INFO     ] 2017-05-20 11:40:58,861 Starting 'Parsing Hierarchy '
P002 yt : [INFO     ] 2017-05-20 11:40:58,956 Finishing 'Parsing Hierarchy '
P001 yt : [INFO     ] 2017-05-20 11:40:58,958 Finishing 'Parsing Hierarchy '
P000 yt : [INFO     ] 2017-05-20 11:40:58,961 Finishing 'Parsing Hierarchy '
P000 yt : [INFO     ] 2017-05-20 11:40:59,146 Gathering a field list (this may take a moment.)
[hpost3:191042] 2 more processes have sent help message help-mpi-btl-openib.txt / default subnet prefix
[hpost3:191042] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help / error messages
P000 yt : [INFO     ] 2017-05-20 11:41:08,858 The citation for the Rockstar halo finder can be found at
P000 yt : [INFO     ] 2017-05-20 11:41:08,858 http://adsabs.harvard.edu/abs/2013ApJ...762..109B
P001 yt : [INFO     ] 2017-05-20 11:41:08,858 Rockstar is using 1 readers and 1 writers
P002 yt : [INFO     ] 2017-05-20 11:41:08,858 Rockstar is using 1 readers and 1 writers
P000 yt : [INFO     ] 2017-05-20 11:41:08,858 Rockstar is using 1 readers and 1 writers
P001 yt : [WARNING  ] 2017-05-20 11:42:19,993 Total Particle Count: 4.533e+05
  File "rockstar_nest.py", line 59, in <module>
    hc.create()
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_catalog.py", line 335, in create
    self._run(save_halos, save_catalog, njobs=njobs, dynamic=dynamic)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 306, in barrierize
    retval = func(*args, **kwargs)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_catalog.py", line 404, in _run
    self.halos_ds = self.finder_method(self.data_ds)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_finding_methods.py", line 44, in __call__
    return self.function(ds, *self.args, **self.kwargs)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_finding_methods.py", line 77, in _rockstar_method
    rh.run()
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_finding/rockstar/rockstar.py", line 341, in run
    min_halo_size = self.min_halo_size)
  File "yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx", line 249, in yt.analysis_modules.halo_finding.rockstar.rockstar_interface.RockstarInterface.setup_rockstar (yt/analysis_modules/halo_finding/rockstar/rockstar_interface.c:4291)
P001 yt : [ERROR    ] 2017-05-20 11:42:20,193 TypeError: expected bytes, str found
  File "rockstar_nest.py", line 59, in <module>
    hc.create()
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_catalog.py", line 335, in create
    self._run(save_halos, save_catalog, njobs=njobs, dynamic=dynamic)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 306, in barrierize
    retval = func(*args, **kwargs)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_catalog.py", line 404, in _run
    self.halos_ds = self.finder_method(self.data_ds)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_finding_methods.py", line 44, in __call__
    return self.function(ds, *self.args, **self.kwargs)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_finding_methods.py", line 77, in _rockstar_method
    rh.run()
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_finding/rockstar/rockstar.py", line 341, in run
    min_halo_size = self.min_halo_size)
  File "yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx", line 249, in yt.analysis_modules.halo_finding.rockstar.rockstar_interface.RockstarInterface.setup_rockstar (yt/analysis_modules/halo_finding/rockstar/rockstar_interface.c:4291)
P000 yt : [ERROR    ] 2017-05-20 11:42:20,193 TypeError: expected bytes, str found
  File "rockstar_nest.py", line 59, in <module>
    hc.create()
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_catalog.py", line 335, in create
    self._run(save_halos, save_catalog, njobs=njobs, dynamic=dynamic)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 306, in barrierize
    retval = func(*args, **kwargs)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_catalog.py", line 404, in _run
    self.halos_ds = self.finder_method(self.data_ds)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_finding_methods.py", line 44, in __call__
    return self.function(ds, *self.args, **self.kwargs)
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_analysis/halo_finding_methods.py", line 77, in _rockstar_method
    rh.run()
  File "/gfs2/work/nipgrete/yt-conda/src/yt-git/yt/analysis_modules/halo_finding/rockstar/rockstar.py", line 341, in run
    min_halo_size = self.min_halo_size)
  File "yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx", line 249, in yt.analysis_modules.halo_finding.rockstar.rockstar_interface.RockstarInterface.setup_rockstar (yt/analysis_modules/halo_finding/rockstar/rockstar_interface.c:4291)
P002 yt : [ERROR    ] 2017-05-20 11:42:20,193 TypeError: expected bytes, str found
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 1 in communicator MPI_COMM_WORLD 
with errorcode 1.

NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------

```

**Expected outcome**

No error.

**Version Information**
  * Operating System: SUSE Linux Enterprise Server 11 (x86_64)
  * Python Version: 3 
  * yt version: c9a645d

dependencies with conda, yt from source




Discussion:
I haven't tested, but I think this would be fixed if you make the following modification to yt:

```
diff --git a/yt/analysis_modules/halo_finding/rockstar/rockstar.py b/yt/analysis_modules/halo_finding/rockstar/rockstar.py
index 48ea51e..a4e492f 100644
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar.py
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar.py
@@ -325,7 +325,9 @@ class RockstarHaloFinder(ParallelAnalysisInterface):
             self.ts._pre_outputs = self.ts._pre_outputs[restart_num:]
         else:
             restart_num = 0
-        self.handler.setup_rockstar(self.server_address, self.port,
+        self.handler.setup_rockstar(
+                    self.server_address.encode('ascii'),
+                    self.port.encode('ascii'),
                     num_outputs, self.total_particles,
                     self.particle_type,
                     particle_mass = self.particle_mass,
```

Resolving patch:
diff --git a/yt/analysis_modules/halo_finding/rockstar/rockstar.py b/yt/analysis_modules/halo_finding/rockstar/rockstar.py
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar.py
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar.py
@@ -17,6 +17,8 @@
 from yt.config import ytcfg
 from yt.data_objects.time_series import \
     DatasetSeries
+from yt.extern import \
+    six
 from yt.funcs import \
     is_root, mylog
 from yt.utilities.parallel_tools.parallel_analysis_interface import \
@@ -325,7 +327,9 @@ def run(self, block_ratio = 1, callbacks = None, restart = False):
             self.ts._pre_outputs = self.ts._pre_outputs[restart_num:]
         else:
             restart_num = 0
-        self.handler.setup_rockstar(self.server_address, self.port,
+        self.handler.setup_rockstar(
+                    six.b(self.server_address),
+                    six.b(self.port),
                     num_outputs, self.total_particles, 
                     self.particle_type,
                     particle_mass = self.particle_mass,
@@ -334,7 +338,7 @@ def run(self, block_ratio = 1, callbacks = None, restart = False):
                     num_writers = self.num_writers,
                     writing_port = -1,
                     block_ratio = block_ratio,
-                    outbase = self.outbase,
+                    outbase = six.b(self.outbase),
                     force_res = self.force_res,
                     callbacks = callbacks,
                     restart_num = restart_num,


Test patch: