Coverage for python/lsst/ctrl/bps/parsl/service.py: 33%

19 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-27 09:24 +0000

1from lsst.ctrl.bps import BaseWmsService, BaseWmsWorkflow, BpsConfig, GenericWorkflow 

2 

3from .workflow import ParslWorkflow 

4 

5__all__ = ("ParslService",) 

6 

7 

8class ParslService(BaseWmsService): 

9 """Parsl-based implementation for the WMS interface.""" 

10 

11 def prepare( 

12 self, config: BpsConfig, generic_workflow: GenericWorkflow, out_prefix: str | None = None 

13 ) -> BaseWmsWorkflow: 

14 """Convert a generic workflow to a Parsl pipeline. 

15 

16 Parameters 

17 ---------- 

18 config: `lss.ctrl.bps.BpsConfig` 

19 Configuration of the workflow. 

20 generic_workflow: `lsst.ctrl.bps.generic_workflow.GenericWorkflow` 

21 Generic representation of a single workflow. 

22 out_prefix : `str` [None] 

23 Prefix for WMS output files. 

24 

25 Returns 

26 ------- 

27 workflow : `ParslWorkflow` 

28 Workflow that will execute the jobs. 

29 """ 

30 service_class = self.__class__.__module__ + "." + self.__class__.__name__ 

31 if out_prefix is None: 

32 out_prefix = config["submitPath"] 

33 workflow = ParslWorkflow.from_generic_workflow(config, generic_workflow, out_prefix, service_class) 

34 workflow.write(out_prefix) 

35 return workflow 

36 

37 def submit(self, workflow: BaseWmsWorkflow): 

38 """Submit a single WMS workflow 

39 

40 Parameters 

41 ---------- 

42 workflow : `lsst.ctrl.bps.BaseWmsWorkflow` 

43 Prepared WMS Workflow to submit for execution 

44 """ 

45 workflow.start() 

46 workflow.run() 

47 

48 def restart(self, out_prefix: str) -> tuple[str, str, str]: 

49 """Restart a workflow from the point of failure. 

50 

51 Parameters 

52 ---------- 

53 out_prefix : `str` 

54 Id for workflow to be restarted. For this service, it is the prefix 

55 for WMS files, also known as the ``submitPath``. 

56 

57 Returns 

58 ------- 

59 wms_id : `str` 

60 Id of the restarted workflow. If restart failed, it will be set 

61 to None. 

62 run_name : `str` 

63 Name of the restarted workflow. If restart failed, it will be set 

64 to None. 

65 message : `str` 

66 A message describing any issues encountered during the restart. 

67 If there were no issue, an empty string is returned. 

68 """ 

69 workflow = ParslWorkflow.read(out_prefix) 

70 workflow.restart() 

71 workflow.run() 

72 return workflow.name, workflow.name, ""