Repository: DataBiosphere/toil

Issue:
Display job's name in Mesos UI



Discussion:

Resolving patch:
diff --git a/src/toil/batchSystems/mesos/__init__.py b/src/toil/batchSystems/mesos/__init__.py
--- a/src/toil/batchSystems/mesos/__init__.py
+++ b/src/toil/batchSystems/mesos/__init__.py
@@ -42,6 +42,8 @@ def size(self):
 ToilJob = namedtuple('ToilJob', (
     # A job ID specific to this batch system implementation
     'jobID',
+    # What string to display in the mesos UI
+    'name',
     # A ResourceRequirement tuple describing the resources needed by this job
     'resources',
     # The command to be run on the worker node
diff --git a/src/toil/batchSystems/mesos/batchSystem.py b/src/toil/batchSystems/mesos/batchSystem.py
--- a/src/toil/batchSystems/mesos/batchSystem.py
+++ b/src/toil/batchSystems/mesos/batchSystem.py
@@ -146,6 +146,7 @@ def issueBatchJob(self, jobNode):
         self.checkResourceRequest(jobNode.memory, jobNode.cores, jobNode.disk)
         jobID = next(self.unusedJobID)
         job = ToilJob(jobID=jobID,
+                      name=str(jobNode),
                       resources=ResourceRequirement(**jobNode._requirements),
                       command=jobNode.command,
                       userScript=self.userScript,
@@ -449,7 +450,7 @@ def _newMesosTask(self, job, offer):
         task.task_id.value = str(job.jobID)
         task.slave_id.value = offer.slave_id.value
         # FIXME: what bout
-        task.name = str(job)
+        task.name = job.name
         task.data = pickle.dumps(job)
         task.executor.MergeFrom(self.executor)
 


Test patch:
diff --git a/src/toil/test/batchSystems/batchSystemTest.py b/src/toil/test/batchSystems/batchSystemTest.py
--- a/src/toil/test/batchSystems/batchSystemTest.py
+++ b/src/toil/test/batchSystems/batchSystemTest.py
@@ -123,9 +123,9 @@ def testAvailableCores(self):
         def testRunJobs(self):
             testPath = os.path.join(self.tempDir, "test.txt")
             jobNode1 = JobNode(command='sleep 1000', jobName='test1', unitName=None,
-                               jobStoreID=None, requirements=defaultRequirements)
+                               jobStoreID='1', requirements=defaultRequirements)
             jobNode2 = JobNode(command='sleep 1000', jobName='test2', unitName=None,
-                               jobStoreID=None, requirements=defaultRequirements)
+                               jobStoreID='2', requirements=defaultRequirements)
             job1 = self.batchSystem.issueBatchJob(jobNode1)
             job2 = self.batchSystem.issueBatchJob(jobNode2)
 
@@ -144,7 +144,7 @@ def testRunJobs(self):
             # updated jobs queue.
             self.assertFalse(os.path.exists(testPath))
             jobNode3 = JobNode(command="touch %s" % testPath, jobName='test3', unitName=None,
-                               jobStoreID=None, requirements=defaultRequirements)
+                               jobStoreID='3', requirements=defaultRequirements)
             job3 = self.batchSystem.issueBatchJob(jobNode3)
 
             jobID, exitStatus, wallTime = self.batchSystem.getUpdatedBatchJob(maxWait=1000)
@@ -179,7 +179,7 @@ def assertEnv():
                 # First, ensure that the test fails if the variable is *not* set
                 command = sys.executable + ' ' + script_path
                 jobNode4 = JobNode(command=command, jobName='test4', unitName=None,
-                                   jobStoreID=None, requirements=defaultRequirements)
+                                   jobStoreID='4', requirements=defaultRequirements)
                 job4 = self.batchSystem.issueBatchJob(jobNode4)
                 jobID, exitStatus, wallTime = self.batchSystem.getUpdatedBatchJob(maxWait=1000)
                 self.assertEqual(exitStatus, 42)
@@ -187,7 +187,7 @@ def assertEnv():
                 # Now set the variable and ensure that it is present
                 self.batchSystem.setEnv('FOO', 'bar')
                 jobNode5 = JobNode(command=command, jobName='test5', unitName=None,
-                                   jobStoreID=None, requirements=defaultRequirements)
+                                   jobStoreID='5', requirements=defaultRequirements)
                 job5 = self.batchSystem.issueBatchJob(jobNode5)
                 jobID, exitStatus, wallTime = self.batchSystem.getUpdatedBatchJob(maxWait=1000)
                 self.assertEqual(exitStatus, 0)
@@ -544,14 +544,14 @@ def testBatchResourceLimits(self):
                            requirements=dict(memory=1 << 30, cores=1,
                                              disk=1000, preemptable=preemptable),
                            jobName='testResourceLimits', unitName=None,
-                           jobStoreID=None)
+                           jobStoreID='1')
         job1 = self.batchSystem.issueBatchJob(jobNode1)
         self.assertIsNotNone(job1)
         jobNode2 = JobNode(command="sleep 1000",
                            requirements=dict(memory=2 << 30, cores=1,
                                              disk=1000, preemptable=preemptable),
                            jobName='testResourceLimits', unitName=None,
-                           jobStoreID=None)
+                           jobStoreID='2')
         job2 = self.batchSystem.issueBatchJob(jobNode2)
         self.assertIsNotNone(job2)
         batches = self._getBatchList()