Coverage for tests/test_job.py: 25%
28 statements
« prev ^ index » next coverage.py v7.3.3, created at 2023-12-20 17:43 +0000
« prev ^ index » next coverage.py v7.3.3, created at 2023-12-20 17:43 +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/>.
28import os
30from lsst.ctrl.bps import BpsConfig, GenericWorkflowJob
31from lsst.ctrl.bps.parsl.job import ParslJob
33TESTDIR = os.path.abspath(os.path.dirname(__file__))
36def testInitWithTemplate():
37 """Test ParslJob stdout/stderr init. with template."""
38 # Test doesn't actually use directory
39 submit_path = os.path.join(TESTDIR, "with_template")
40 config = BpsConfig(
41 {
42 "subDirTemplate": "{label}/{tract}/{patch}/{band}/{visit}/{exposure}",
43 "submitPath": submit_path,
44 }
45 )
46 gwjob = GenericWorkflowJob("job1", label="label1")
47 gwjob.tags = {"exposure": 903344}
49 parsl_job = ParslJob(gwjob, config, {})
50 assert parsl_job.stdout == os.path.join(submit_path, "logs/label1/903344/job1.stdout")
51 assert parsl_job.stderr == os.path.join(submit_path, "logs/label1/903344/job1.stderr")
54def testInitWithTemplateNoTags():
55 """Test ParslJob stdout/stderr init. with template but without tags."""
56 # Test doesn't actually use directory
57 submit_path = os.path.join(TESTDIR, "with_template_no_tags")
58 config = BpsConfig(
59 {
60 "subDirTemplate": "{label}/{tract}/{patch}/{band}/{visit}/{exposure}",
61 "submitPath": submit_path,
62 }
63 )
64 gwjob = GenericWorkflowJob("job2", label="label2")
65 gwjob.tags = None
67 parsl_job = ParslJob(gwjob, config, {})
68 assert parsl_job.stdout == os.path.join(submit_path, "logs/label2/job2.stdout")
69 assert parsl_job.stderr == os.path.join(submit_path, "logs/label2/job2.stderr")
72def testInitWithoutTemplate():
73 """Test ParslJob stdout/stderr init. with template."""
74 # Test doesn't actually use directory
75 submit_path = os.path.join(TESTDIR, "without_template")
76 config = BpsConfig({"subDirTemplate": "", "submitPath": submit_path})
77 gwjob = GenericWorkflowJob("job3", label="label3")
78 gwjob.tags = {"exposure": 903344}
80 parsl_job = ParslJob(gwjob, config, {})
81 assert parsl_job.stdout == os.path.join(submit_path, "logs/job3.stdout")
82 assert parsl_job.stderr == os.path.join(submit_path, "logs/job3.stderr")