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

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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/>.
22"""Driver for submitting a prepared WMS-specific workflow
23"""
24import logging
26from lsst.utils import doImport
27from lsst.utils.timer import time_this
28from lsst.ctrl.bps.bps_utils import _create_execution_butler
30_LOG = logging.getLogger(__name__)
33def submit(config, wms_workflow, wms_service=None):
34 """Convert generic workflow to a workflow for a particular WMS.
36 Parameters
37 ----------
38 config : `lsst.ctrl.bps.BpsConfig`
39 Configuration values to be used by submission.
40 wms_workflow : `lsst.ctrl.bps.BaseWmsWorkflow`
41 The workflow to submit.
42 wms_service : `lsst.ctrl.bps.BaseWmsService`, optional
43 The workflow management service to which the workflow should be
44 submitted.
46 Returns
47 -------
48 wms_workflow : `lsst.ctrl.bps.BaseWmsWorkflow`
49 WMS-specific workflow.
50 """
51 if wms_service is None:
52 wms_service_class = doImport(config["wmsServiceClass"])
53 wms_service = wms_service_class(config)
55 _, when_create = config.search(".executionButler.whenCreate")
56 if when_create.upper() == "SUBMIT":
57 _, execution_butler_dir = config.search(".bps_defined.executionButlerDir")
58 _LOG.info("Creating execution butler in '%s'", execution_butler_dir)
59 with time_this(log=_LOG, level=logging.INFO, prefix=None, msg="Completed creating execution butler"):
60 _create_execution_butler(config, config["runQgraphFile"], execution_butler_dir,
61 config["submitPath"])
63 _LOG.info("Submitting run to a workflow management system for execution")
64 with time_this(log=_LOG, level=logging.INFO, prefix=None,
65 msg="Completed submitting to a workflow management system"):
66 workflow = wms_service.submit(wms_workflow)
67 return workflow