@@ -420,6 +420,38 @@ def parse_status_output(self, exit_code: int, out: str) -> Dict[str, JobStatus]:
420420 """
421421 pass
422422
423+ @abstractmethod
424+ def get_list_command (self ) -> List [str ]:
425+ """Constructs a command to retrieve the list of jobs known to the LRM for the current user.
426+
427+ Concrete implementations of batch scheduler executors must override this method. Upon
428+ running the command, the output can be parsed with :func:`~parse_list_output`.
429+
430+ Returns
431+ -------
432+ A list of strings representing the executable and arguments to invoke in order to obtain
433+ the list of jobs the LRM knows for the current user.
434+ """
435+ pass
436+
437+ def parse_list_output (self , out : str ) -> List [str ]:
438+ """Parses the output of the command obtained from :func:`~get_list_command`.
439+
440+ The default implementation of this method assumes that the output has no header and
441+ consists of native IDs, one per line, possibly surrounded by whitespace. Concrete
442+ implementations should override this method if a different format is expected.
443+
444+ Parameters
445+ ----------
446+ out
447+ The output from the "list" command as returned by :func:`~get_list_command`.
448+ Returns
449+ -------
450+ A list of strings representing the native IDs of the jobs known to the LRM for the current
451+ user.
452+ """
453+ return [s .strip () for s in out .splitlines ()]
454+
423455 def _create_script_context (self , job : Job ) -> Dict [str , object ]:
424456 launcher = self ._get_launcher_from_job (job )
425457 if isinstance (launcher , ScriptBasedLauncher ) and logger .isEnabledFor (logging .DEBUG ):
@@ -551,7 +583,10 @@ def list(self) -> List[str]:
551583 Implementations are encouraged to restrict the results to jobs accessible by the current
552584 user.
553585 """
554- raise NotImplementedError ()
586+ return self .parse_list_output (self ._run_command (self .get_list_command ()))
587+
588+ def _current_user (self ) -> str :
589+ return os .getlogin ()
555590
556591
557592class _QueuePollThread (Thread ):
0 commit comments