Commits

Matthew Turk  committed 1ef5a5e

Allowing return values from @parallel_root_only and using this in the SketchFab
uploader.

  • Participants
  • Parent commits a1e2ca6

Comments (0)

Files changed (2)

File yt/data_objects/data_containers.py

             'fileModel': zfs,
             'filenameModel': "yt_export.zip",
         }
-        self._upload_to_sketchfab(data)
+        upload_id = self._upload_to_sketchfab(data)
+        upload_id = self.comm.mpi_bcast(upload_id, root = 0)
+        return upload_id
 
     @parallel_root_only
     def _upload_to_sketchfab(self, data):
                         datamulti, headers)
         rv = urllib2.urlopen(request).read()
         rv = json.loads(rv)
-        upload_id = rv.get("id", None)
+        upload_id = rv.get("result", {}).get("id", None)
         if upload_id:
-            mylog.info("Model uploaded to: https://sketchfab.com/show/%s", id)
+            mylog.info("Model uploaded to: https://sketchfab.com/show/%s",
+                       upload_id)
         else:
             mylog.error("Problem uploading.")
+        return upload_id
 
 
 def _reconstruct_object(*args, **kwargs):

File yt/utilities/parallel_tools/parallel_analysis_interface.py

     @wraps(func)
     def root_only(*args, **kwargs):
         comm = _get_comm(args)
+        rv = None
         if comm.rank == 0:
             try:
-                func(*args, **kwargs)
+                rv = func(*args, **kwargs)
                 all_clear = 1
             except:
                 traceback.print_last()
             all_clear = None
         all_clear = comm.mpi_bcast(all_clear)
         if not all_clear: raise RuntimeError
+        return rv
     if parallel_capable: return root_only
     return func