Coverage for python/lsst/ctrl/bps/submit.py: 30%

22 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-11 03:25 -0700

1# This file is part of ctrl_bps. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

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

7# for details of code ownership. 

8# 

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

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

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

12# (at your option) any later version. 

13# 

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

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

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

17# GNU General Public License for more details. 

18# 

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

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

21 

22"""Driver for submitting a prepared WMS-specific workflow 

23""" 

24import logging 

25 

26from lsst.ctrl.bps.bps_utils import _create_execution_butler 

27from lsst.utils import doImport 

28from lsst.utils.logging import VERBOSE 

29from lsst.utils.timer import time_this, timeMethod 

30 

31_LOG = logging.getLogger(__name__) 

32 

33 

34@timeMethod(logger=_LOG, logLevel=VERBOSE) 

35def submit(config, wms_workflow, wms_service=None): 

36 """Convert generic workflow to a workflow for a particular WMS. 

37 

38 Parameters 

39 ---------- 

40 config : `lsst.ctrl.bps.BpsConfig` 

41 Configuration values to be used by submission. 

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

43 The workflow to submit. 

44 wms_service : `lsst.ctrl.bps.BaseWmsService`, optional 

45 The workflow management service to which the workflow should be 

46 submitted. 

47 

48 Returns 

49 ------- 

50 wms_workflow : `lsst.ctrl.bps.BaseWmsWorkflow` 

51 WMS-specific workflow. 

52 """ 

53 if wms_service is None: 

54 wms_service_class = doImport(config["wmsServiceClass"]) 

55 wms_service = wms_service_class(config) 

56 

57 _, when_create = config.search(".executionButler.whenCreate") 

58 if when_create.upper() == "SUBMIT": 

59 _, execution_butler_dir = config.search(".bps_defined.executionButlerDir") 

60 _LOG.info("Creating execution butler in '%s'", execution_butler_dir) 

61 with time_this(log=_LOG, level=logging.INFO, prefix=None, msg="Completed creating execution butler"): 

62 _create_execution_butler( 

63 config, config["runQgraphFile"], execution_butler_dir, config["submitPath"] 

64 ) 

65 

66 _LOG.info("Submitting run to a workflow management system for execution") 

67 with time_this( 

68 log=_LOG, level=logging.INFO, prefix=None, msg="Completed submitting to a workflow management system" 

69 ): 

70 workflow = wms_service.submit(wms_workflow) 

71 return workflow