@@ -1586,6 +1586,12 @@ def _cluster_id_default(self):
15861586 help = "The name of the command line program used to delete jobs." ,
15871587 )
15881588
1589+ signal_command = List (
1590+ ['' ],
1591+ config = True ,
1592+ help = "The name of the command line program used to send signals to jobs." ,
1593+ )
1594+
15891595 job_id = Unicode ().tag (to_dict = True )
15901596
15911597 job_id_regexp = CRegExp (
@@ -1616,7 +1622,7 @@ def _cluster_id_default(self):
16161622 def _queue_changed (self , change ):
16171623 self ._update_context (change )
16181624
1619- n = Integer (1 )
1625+ n = Integer (1 ). tag ( to_dict = True )
16201626
16211627 @observe ('n' )
16221628 def _n_changed (self , change ):
@@ -1643,7 +1649,7 @@ def _n_changed(self, change):
16431649 This lets you parameterize additional options,
16441650 such as wall_time with a custom template.
16451651 """ ,
1646- )
1652+ ). tag ( to_dict = True )
16471653
16481654 @default ("context" )
16491655 def _context_default (self ):
@@ -1714,7 +1720,7 @@ def write_batch_script(self, n=1):
17141720 # from user config
17151721 ns .update (self .namespace )
17161722 script_as_string = self .formatter .format (self .batch_template , ** ns )
1717- self .log .debug ('Writing batch script: %s' , self .batch_file )
1723+ self .log .debug (f 'Writing batch script: { self .batch_file } \n { script_as_string } ' )
17181724 with open (self .batch_file , 'w' ) as f :
17191725 f .write (script_as_string )
17201726 os .chmod (self .batch_file , stat .S_IRUSR | stat .S_IWUSR | stat .S_IXUSR )
@@ -1739,35 +1745,44 @@ def start(self, n=1):
17391745 # Here we save profile_dir in the context so they
17401746 # can be used in the batch script template as {profile_dir}
17411747 self .write_batch_script (n )
1748+
17421749 output = check_output (self .args , env = os .environ )
17431750 output = output .decode (DEFAULT_ENCODING , 'replace' )
1751+ self .log .debug (f"Submitted { shlex_join (self .args )} . Output: { output } " )
17441752
17451753 job_id = self .parse_job_id (output )
17461754 self .notify_start (job_id )
17471755 return job_id
17481756
17491757 def stop (self ):
17501758 try :
1751- p = Popen (
1759+ output = check_output (
17521760 self .delete_command + [self .job_id ],
1753- env = os .environ ,
1754- stdout = PIPE ,
1755- stderr = PIPE ,
1756- )
1757- out , err = p .communicate ()
1758- output = out + err
1759- except :
1761+ stdin = None ,
1762+ ).decode (DEFAULT_ENCODING , 'replace' )
1763+ except Exception :
17601764 self .log .exception (
17611765 "Problem stopping cluster with command: %s"
17621766 % (self .delete_command + [self .job_id ])
17631767 )
17641768 output = ""
1765- output = output . decode ( DEFAULT_ENCODING , 'replace' )
1769+
17661770 self .notify_stop (
17671771 dict (job_id = self .job_id , output = output )
17681772 ) # Pass the output of the kill cmd
17691773 return output
17701774
1775+ def signal (self , sig ):
1776+ cmd = self .signal_command + [str (sig ), self .job_id ]
1777+ try :
1778+ output = check_output (
1779+ cmd ,
1780+ stdin = None ,
1781+ ).decode (DEFAULT_ENCODING , 'replace' )
1782+ except Exception :
1783+ self .log .exception ("Problem sending signal with: {shlex_join(cmd)}" )
1784+ output = ""
1785+
17711786
17721787class BatchControllerLauncher (BatchSystemLauncher , ControllerLauncher ):
17731788 @default ("program" )
@@ -1813,6 +1828,9 @@ class PBSLauncher(BatchSystemLauncher):
18131828
18141829 submit_command = List (['qsub' ], config = True , help = "The PBS submit command ['qsub']" )
18151830 delete_command = List (['qdel' ], config = True , help = "The PBS delete command ['qdel']" )
1831+ signal_command = List (
1832+ ['qsig' , '-s' ], config = True , help = "The PBS signal command ['qsig']"
1833+ )
18161834 job_id_regexp = CRegExp (
18171835 r'\d+' ,
18181836 config = True ,
@@ -1868,6 +1886,11 @@ class SlurmLauncher(BatchSystemLauncher):
18681886 delete_command = List (
18691887 ['scancel' ], config = True , help = "The slurm delete command ['scancel']"
18701888 )
1889+ signal_command = List (
1890+ ['scancel' , '-s' ],
1891+ config = True ,
1892+ help = "The slurm signal command ['scancel', '-s']" ,
1893+ )
18711894 job_id_regexp = CRegExp (
18721895 r'\d+' ,
18731896 config = True ,
@@ -2023,9 +2046,12 @@ class SGEEngineSetLauncher(SGELauncher, BatchEngineSetLauncher):
20232046class LSFLauncher (BatchSystemLauncher ):
20242047 """A BatchSystemLauncher subclass for LSF."""
20252048
2026- submit_command = List (['bsub' ], config = True , help = "The PBS submit command ['bsub']" )
2049+ submit_command = List (['bsub' ], config = True , help = "The LSF submit command ['bsub']" )
20272050 delete_command = List (
2028- ['bkill' ], config = True , help = "The PBS delete command ['bkill']"
2051+ ['bkill' ], config = True , help = "The LSF delete command ['bkill']"
2052+ )
2053+ signal_command = List (
2054+ ['bkill' , '-s' ], config = True , help = "The LSF signal command ['bkill', '-s']"
20292055 )
20302056 job_id_regexp = CRegExp (
20312057 r'\d+' ,
0 commit comments