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

19 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-29 09:36 +0000

1# This file is part of ctrl_bps_parsl. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org) and the LSST DESC (https://www.lsstdesc.org/). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This software is dual licensed under the GNU General Public License and also 

10# under a 3-clause BSD license. Recipients may choose which of these licenses 

11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt, 

12# respectively. If you choose the GPL option then the following text applies 

13# (but note that there is still no warranty even if you opt for BSD instead): 

14# 

15# This program is free software: you can redistribute it and/or modify 

16# it under the terms of the GNU General Public License as published by 

17# the Free Software Foundation, either version 3 of the License, or 

18# (at your option) any later version. 

19# 

20# This program is distributed in the hope that it will be useful, 

21# but WITHOUT ANY WARRANTY; without even the implied warranty of 

22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

23# GNU General Public License for more details. 

24# 

25# You should have received a copy of the GNU General Public License 

26# along with this program. If not, see <https://www.gnu.org/licenses/>. 

27 

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

29 

30from .workflow import ParslWorkflow 

31 

32__all__ = ("ParslService",) 

33 

34 

35class ParslService(BaseWmsService): 

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

37 

38 def prepare( 

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

40 ) -> BaseWmsWorkflow: 

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

42 

43 Parameters 

44 ---------- 

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

46 Configuration of the workflow. 

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

48 Generic representation of a single workflow. 

49 out_prefix : `str` [None] 

50 Prefix for WMS output files. 

51 

52 Returns 

53 ------- 

54 workflow : `ParslWorkflow` 

55 Workflow that will execute the jobs. 

56 """ 

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

58 if out_prefix is None: 

59 out_prefix = config["submitPath"] 

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

61 workflow.write(out_prefix) 

62 return workflow 

63 

64 def submit(self, workflow: BaseWmsWorkflow): 

65 """Submit a single WMS workflow 

66 

67 Parameters 

68 ---------- 

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

70 Prepared WMS Workflow to submit for execution 

71 """ 

72 workflow.start() 

73 workflow.run() 

74 

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

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

77 

78 Parameters 

79 ---------- 

80 out_prefix : `str` 

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

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

83 

84 Returns 

85 ------- 

86 wms_id : `str` 

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

88 to None. 

89 run_name : `str` 

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

91 to None. 

92 message : `str` 

93 A message describing any issues encountered during the restart. 

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

95 """ 

96 workflow = ParslWorkflow.read(out_prefix) 

97 workflow.restart() 

98 workflow.run() 

99 return workflow.name, workflow.name, ""