Hide keyboard shortcuts

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_mpexec. 

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"""Simple unit test for cmdLineFwk module. 

23""" 

24 

25import click 

26from types import SimpleNamespace 

27import contextlib 

28import copy 

29from dataclasses import dataclass 

30import logging 

31import os 

32import pickle 

33import shutil 

34import tempfile 

35from typing import NamedTuple 

36import unittest 

37 

38from lsst.ctrl.mpexec.cmdLineFwk import CmdLineFwk 

39from lsst.ctrl.mpexec.cli.opt import run_options 

40from lsst.ctrl.mpexec.cli.utils import ( 

41 _ACTION_ADD_TASK, 

42 _ACTION_CONFIG, 

43 _ACTION_CONFIG_FILE, 

44 _ACTION_ADD_INSTRUMENT, 

45 PipetaskCommand, 

46) 

47from lsst.daf.butler import Config, Quantum, Registry 

48from lsst.daf.butler.registry import RegistryConfig 

49from lsst.obs.base import Instrument 

50import lsst.pex.config as pexConfig 

51from lsst.pipe.base import (Pipeline, PipelineTask, PipelineTaskConfig, 

52 QuantumGraph, TaskDef, TaskFactory, 

53 PipelineTaskConnections) 

54import lsst.pipe.base.connectionTypes as cT 

55import lsst.utils.tests 

56from lsst.pipe.base.tests.simpleQGraph import (AddTaskFactoryMock, makeSimpleQGraph) 

57from lsst.utils.tests import temporaryDirectory 

58 

59 

60logging.basicConfig(level=logging.INFO) 

61 

62# Have to monkey-patch Instrument.fromName() to not retrieve non-existing 

63# instrument from registry, these tests can run fine without actual instrument 

64# and implementing full mock for Instrument is too complicated. 

65Instrument.fromName = lambda name, reg: None 65 ↛ exitline 65 didn't run the lambda on line 65

66 

67 

68@contextlib.contextmanager 

69def makeTmpFile(contents=None, suffix=None): 

70 """Context manager for generating temporary file name. 

71 

72 Temporary file is deleted on exiting context. 

73 

74 Parameters 

75 ---------- 

76 contents : `bytes` 

77 Data to write into a file. 

78 """ 

79 fd, tmpname = tempfile.mkstemp(suffix=suffix) 

80 if contents: 

81 os.write(fd, contents) 

82 os.close(fd) 

83 yield tmpname 

84 with contextlib.suppress(OSError): 

85 os.remove(tmpname) 

86 

87 

88@contextlib.contextmanager 

89def makeSQLiteRegistry(create=True): 

90 """Context manager to create new empty registry database. 

91 

92 Yields 

93 ------ 

94 config : `RegistryConfig` 

95 Registry configuration for initialized registry database. 

96 """ 

97 with temporaryDirectory() as tmpdir: 

98 uri = f"sqlite:///{tmpdir}/gen3.sqlite" 

99 config = RegistryConfig() 

100 config["db"] = uri 

101 if create: 

102 Registry.createFromConfig(config) 

103 yield config 

104 

105 

106class SimpleConnections(PipelineTaskConnections, dimensions=(), 

107 defaultTemplates={"template": "simple"}): 

108 schema = cT.InitInput(doc="Schema", 

109 name="{template}schema", 

110 storageClass="SourceCatalog") 

111 

112 

113class SimpleConfig(PipelineTaskConfig, pipelineConnections=SimpleConnections): 

114 field = pexConfig.Field(dtype=str, doc="arbitrary string") 

115 

116 def setDefaults(self): 

117 PipelineTaskConfig.setDefaults(self) 

118 

119 

120class TaskOne(PipelineTask): 

121 ConfigClass = SimpleConfig 

122 _DefaultName = "taskOne" 

123 

124 

125class TaskTwo(PipelineTask): 

126 ConfigClass = SimpleConfig 

127 _DefaultName = "taskTwo" 

128 

129 

130class TaskFactoryMock(TaskFactory): 

131 def loadTaskClass(self, taskName): 

132 if taskName == "TaskOne": 

133 return TaskOne, "TaskOne" 

134 elif taskName == "TaskTwo": 

135 return TaskTwo, "TaskTwo" 

136 

137 def makeTask(self, taskClass, config, overrides, butler): 

138 if config is None: 

139 config = taskClass.ConfigClass() 

140 if overrides: 

141 overrides.applyTo(config) 

142 return taskClass(config=config, butler=butler) 

143 

144 

145def _makeArgs(registryConfig=None, **kwargs): 

146 """Return parsed command line arguments. 

147 

148 By default butler_config is set to `Config` populated with some defaults, 

149 it can be overridden completely by keyword argument. 

150 

151 Parameters 

152 ---------- 

153 cmd : `str`, optional 

154 Produce arguments for this pipetask command. 

155 registryConfig : `RegistryConfig`, optional 

156 Override for registry configuration. 

157 **kwargs 

158 Overrides for other arguments. 

159 """ 

160 # Use a mock to get the default value of arguments to 'run'. 

161 

162 mock = unittest.mock.Mock() 

163 

164 @click.command(cls=PipetaskCommand) 

165 @run_options() 

166 def fake_run(ctx, **kwargs): 

167 """Fake "pipetask run" command for gathering input arguments. 

168 

169 The arguments & options should always match the arguments & options in 

170 the "real" command function `lsst.ctrl.mpexec.cli.cmd.run`. 

171 """ 

172 mock(**kwargs) 

173 

174 runner = click.testing.CliRunner() 

175 result = runner.invoke(fake_run) 

176 if result.exit_code != 0: 

177 raise RuntimeError(f"Failure getting default args from 'fake_run': {result}") 

178 mock.assert_called_once() 

179 args = mock.call_args[1] 

180 args["enableLsstDebug"] = args.pop("debug") 

181 if "pipeline_actions" not in args: 

182 args["pipeline_actions"] = [] 

183 args = SimpleNamespace(**args) 

184 

185 # override butler_config with our defaults 

186 args.butler_config = Config() 

187 if registryConfig: 

188 args.butler_config["registry"] = registryConfig 

189 # The default datastore has a relocatable root, so we need to specify 

190 # some root here for it to use 

191 args.butler_config.configFile = "." 

192 # override arguments from keyword parameters 

193 for key, value in kwargs.items(): 

194 setattr(args, key, value) 

195 return args 

196 

197 

198class FakeTaskDef(NamedTuple): 

199 name: str 

200 

201 

202@dataclass(frozen=True) 

203class FakeDSRef: 

204 datasetType: str 

205 dataId: tuple 

206 

207 

208def _makeQGraph(): 

209 """Make a trivial QuantumGraph with one quantum. 

210 

211 The only thing that we need to do with this quantum graph is to pickle 

212 it, the quanta in this graph are not usable for anything else. 

213 

214 Returns 

215 ------- 

216 qgraph : `~lsst.pipe.base.QuantumGraph` 

217 """ 

218 

219 # The task name in TaskDef needs to be a real importable name, use one that is sure to exist 

220 taskDef = TaskDef(taskName="lsst.pipe.base.Struct", config=SimpleConfig()) 

221 quanta = [Quantum(taskName="lsst.pipe.base.Struct", 

222 inputs={FakeTaskDef("A"): FakeDSRef("A", (1, 2))})] # type: ignore 

223 qgraph = QuantumGraph({taskDef: set(quanta)}) 

224 return qgraph 

225 

226 

227class CmdLineFwkTestCase(unittest.TestCase): 

228 """A test case for CmdLineFwk 

229 """ 

230 

231 def testMakePipeline(self): 

232 """Tests for CmdLineFwk.makePipeline method 

233 """ 

234 fwk = CmdLineFwk() 

235 

236 # make empty pipeline 

237 args = _makeArgs() 

238 pipeline = fwk.makePipeline(args) 

239 self.assertIsInstance(pipeline, Pipeline) 

240 self.assertEqual(len(pipeline), 0) 

241 

242 # few tests with serialization 

243 with makeTmpFile() as tmpname: 

244 # make empty pipeline and store it in a file 

245 args = _makeArgs(save_pipeline=tmpname) 

246 pipeline = fwk.makePipeline(args) 

247 self.assertIsInstance(pipeline, Pipeline) 

248 

249 # read pipeline from a file 

250 args = _makeArgs(pipeline=tmpname) 

251 pipeline = fwk.makePipeline(args) 

252 self.assertIsInstance(pipeline, Pipeline) 

253 self.assertEqual(len(pipeline), 0) 

254 

255 # single task pipeline 

256 actions = [ 

257 _ACTION_ADD_TASK("TaskOne:task1") 

258 ] 

259 args = _makeArgs(pipeline_actions=actions) 

260 pipeline = fwk.makePipeline(args) 

261 self.assertIsInstance(pipeline, Pipeline) 

262 self.assertEqual(len(pipeline), 1) 

263 

264 # many task pipeline 

265 actions = [ 

266 _ACTION_ADD_TASK("TaskOne:task1a"), 

267 _ACTION_ADD_TASK("TaskTwo:task2"), 

268 _ACTION_ADD_TASK("TaskOne:task1b") 

269 ] 

270 args = _makeArgs(pipeline_actions=actions) 

271 pipeline = fwk.makePipeline(args) 

272 self.assertIsInstance(pipeline, Pipeline) 

273 self.assertEqual(len(pipeline), 3) 

274 

275 # single task pipeline with config overrides, cannot use TaskOne, need 

276 # something that can be imported with `doImport()` 

277 actions = [ 

278 _ACTION_ADD_TASK("lsst.pipe.base.tests.simpleQGraph.AddTask:task"), 

279 _ACTION_CONFIG("task:addend=100") 

280 ] 

281 args = _makeArgs(pipeline_actions=actions) 

282 pipeline = fwk.makePipeline(args) 

283 taskDefs = list(pipeline.toExpandedPipeline()) 

284 self.assertEqual(len(taskDefs), 1) 

285 self.assertEqual(taskDefs[0].config.addend, 100) 

286 

287 overrides = b"config.addend = 1000\n" 

288 with makeTmpFile(overrides) as tmpname: 

289 actions = [ 

290 _ACTION_ADD_TASK("lsst.pipe.base.tests.simpleQGraph.AddTask:task"), 

291 _ACTION_CONFIG_FILE("task:" + tmpname) 

292 ] 

293 args = _makeArgs(pipeline_actions=actions) 

294 pipeline = fwk.makePipeline(args) 

295 taskDefs = list(pipeline.toExpandedPipeline()) 

296 self.assertEqual(len(taskDefs), 1) 

297 self.assertEqual(taskDefs[0].config.addend, 1000) 

298 

299 # Check --instrument option, for now it only checks that it does not crash 

300 actions = [ 

301 _ACTION_ADD_TASK("lsst.pipe.base.tests.simpleQGraph.AddTask:task"), 

302 _ACTION_ADD_INSTRUMENT("Instrument") 

303 ] 

304 args = _makeArgs(pipeline_actions=actions) 

305 pipeline = fwk.makePipeline(args) 

306 

307 def testMakeGraphFromSave(self): 

308 """Tests for CmdLineFwk.makeGraph method. 

309 

310 Only most trivial case is tested that does not do actual graph 

311 building. 

312 """ 

313 fwk = CmdLineFwk() 

314 

315 with makeTmpFile(suffix=".qgraph") as tmpname, makeSQLiteRegistry() as registryConfig: 

316 

317 # make non-empty graph and store it in a file 

318 qgraph = _makeQGraph() 

319 with open(tmpname, "wb") as saveFile: 

320 qgraph.save(saveFile) 

321 args = _makeArgs(qgraph=tmpname, registryConfig=registryConfig) 

322 qgraph = fwk.makeGraph(None, args) 

323 self.assertIsInstance(qgraph, QuantumGraph) 

324 self.assertEqual(len(qgraph), 1) 

325 

326 # will fail if graph id does not match 

327 args = _makeArgs( 

328 qgraph=tmpname, 

329 qgraph_id="R2-D2 is that you?", 

330 registryConfig=registryConfig 

331 ) 

332 with self.assertRaisesRegex(ValueError, "graphID does not match"): 

333 fwk.makeGraph(None, args) 

334 

335 # save with wrong object type 

336 with open(tmpname, "wb") as saveFile: 

337 pickle.dump({}, saveFile) 

338 args = _makeArgs(qgraph=tmpname, registryConfig=registryConfig) 

339 with self.assertRaises(ValueError): 

340 fwk.makeGraph(None, args) 

341 

342 # reading empty graph from pickle should work but makeGraph() 

343 # will return None and make a warning 

344 qgraph = QuantumGraph(dict()) 

345 with open(tmpname, "wb") as saveFile: 

346 qgraph.save(saveFile) 

347 args = _makeArgs(qgraph=tmpname, registryConfig=registryConfig) 

348 with self.assertWarnsRegex(UserWarning, "QuantumGraph is empty"): 

349 # this also tests that warning is generated for empty graph 

350 qgraph = fwk.makeGraph(None, args) 

351 self.assertIs(qgraph, None) 

352 

353 def testShowPipeline(self): 

354 """Test for --show options for pipeline. 

355 """ 

356 fwk = CmdLineFwk() 

357 

358 actions = [ 

359 _ACTION_ADD_TASK("lsst.pipe.base.tests.simpleQGraph.AddTask:task"), 

360 _ACTION_CONFIG("task:addend=100") 

361 ] 

362 args = _makeArgs(pipeline_actions=actions) 

363 pipeline = fwk.makePipeline(args) 

364 

365 args.show = ["pipeline"] 

366 fwk.showInfo(args, pipeline) 

367 args.show = ["config"] 

368 fwk.showInfo(args, pipeline) 

369 args.show = ["history=task::addend"] 

370 fwk.showInfo(args, pipeline) 

371 args.show = ["tasks"] 

372 fwk.showInfo(args, pipeline) 

373 

374 

375class CmdLineFwkTestCaseWithButler(unittest.TestCase): 

376 """A test case for CmdLineFwk 

377 """ 

378 

379 def setUp(self): 

380 super().setUpClass() 

381 self.root = tempfile.mkdtemp() 

382 

383 def tearDown(self): 

384 shutil.rmtree(self.root, ignore_errors=True) 

385 super().tearDownClass() 

386 

387 def testSimpleQGraph(self): 

388 """Test successfull execution of trivial quantum graph. 

389 """ 

390 

391 nQuanta = 5 

392 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root) 

393 

394 self.assertEqual(len(qgraph.taskGraph), 5) 

395 self.assertEqual(len(qgraph), nQuanta) 

396 

397 args = _makeArgs() 

398 fwk = CmdLineFwk() 

399 taskFactory = AddTaskFactoryMock() 

400 

401 # run whole thing 

402 fwk.runPipeline(qgraph, taskFactory, args, butler=butler) 

403 self.assertEqual(taskFactory.countExec, nQuanta) 

404 

405 def testSimpleQGraphSkipExisting(self): 

406 """Test continuing execution of trivial quantum graph with --skip-existing. 

407 """ 

408 

409 nQuanta = 5 

410 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root) 

411 

412 self.assertEqual(len(qgraph.taskGraph), 5) 

413 self.assertEqual(len(qgraph), nQuanta) 

414 

415 args = _makeArgs() 

416 fwk = CmdLineFwk() 

417 taskFactory = AddTaskFactoryMock(stopAt=3) 

418 

419 # run first three quanta 

420 with self.assertRaises(RuntimeError): 

421 fwk.runPipeline(qgraph, taskFactory, args, butler=butler) 

422 self.assertEqual(taskFactory.countExec, 3) 

423 

424 # run remaining ones 

425 taskFactory.stopAt = -1 

426 args.skip_existing = True 

427 args.no_versions = True 

428 fwk.runPipeline(qgraph, taskFactory, args, butler=butler) 

429 self.assertEqual(taskFactory.countExec, nQuanta) 

430 

431 def testSimpleQGraphPartialOutputsFail(self): 

432 """Test continuing execution of trivial quantum graph with partial 

433 outputs. 

434 """ 

435 

436 nQuanta = 5 

437 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root) 

438 

439 # should have one task and number of quanta 

440 self.assertEqual(len(qgraph), nQuanta) 

441 

442 args = _makeArgs() 

443 fwk = CmdLineFwk() 

444 taskFactory = AddTaskFactoryMock(stopAt=3) 

445 

446 # run first three quanta 

447 with self.assertRaises(RuntimeError): 

448 fwk.runPipeline(qgraph, taskFactory, args, butler=butler) 

449 self.assertEqual(taskFactory.countExec, 3) 

450 

451 # drop one of the two outputs from one task 

452 ref = butler._findDatasetRef("add2_dataset2", instrument="INSTR", detector=0) 

453 self.assertIsNotNone(ref) 

454 butler.pruneDatasets([ref], disassociate=True, unstore=True, purge=True) 

455 

456 taskFactory.stopAt = -1 

457 args.skip_existing = True 

458 args.no_versions = True 

459 excRe = "Registry inconsistency while checking for existing outputs.*" 

460 with self.assertRaisesRegex(RuntimeError, excRe): 

461 fwk.runPipeline(qgraph, taskFactory, args, butler=butler) 

462 

463 def testSimpleQGraphClobberPartialOutputs(self): 

464 """Test continuing execution of trivial quantum graph with 

465 --clobber-partial-outputs. 

466 """ 

467 

468 nQuanta = 5 

469 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root) 

470 

471 # should have one task and number of quanta 

472 self.assertEqual(len(qgraph), nQuanta) 

473 

474 args = _makeArgs() 

475 fwk = CmdLineFwk() 

476 taskFactory = AddTaskFactoryMock(stopAt=3) 

477 

478 # run first three quanta 

479 with self.assertRaises(RuntimeError): 

480 fwk.runPipeline(qgraph, taskFactory, args, butler=butler) 

481 self.assertEqual(taskFactory.countExec, 3) 

482 

483 # drop one of the two outputs from one task 

484 ref = butler._findDatasetRef("add2_dataset2", instrument="INSTR", detector=0) 

485 self.assertIsNotNone(ref) 

486 butler.pruneDatasets([ref], disassociate=True, unstore=True, purge=True) 

487 

488 taskFactory.stopAt = -1 

489 args.skip_existing = True 

490 args.clobber_partial_outputs = True 

491 args.no_versions = True 

492 fwk.runPipeline(qgraph, taskFactory, args, butler=butler) 

493 # number of executed quanta is incremented 

494 self.assertEqual(taskFactory.countExec, nQuanta + 1) 

495 

496 def testSimpleQGraphReplaceRun(self): 

497 """Test repeated execution of trivial quantum graph with 

498 --replace-run. 

499 """ 

500 

501 # need non-memory registry in this case 

502 nQuanta = 5 

503 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root, inMemory=False) 

504 

505 # should have one task and number of quanta 

506 self.assertEqual(len(qgraph), nQuanta) 

507 

508 fwk = CmdLineFwk() 

509 taskFactory = AddTaskFactoryMock() 

510 

511 # run whole thing 

512 args = _makeArgs( 

513 butler_config=self.root, 

514 input="test", 

515 output="output", 

516 output_run="output/run1") 

517 # deep copy is needed because quanta are updated in place 

518 fwk.runPipeline(copy.deepcopy(qgraph), taskFactory, args) 

519 self.assertEqual(taskFactory.countExec, nQuanta) 

520 

521 # need to refresh collections explicitly (or make new butler/registry) 

522 butler.registry._collections.refresh() 

523 collections = set(butler.registry.queryCollections(...)) 

524 self.assertEqual(collections, {"test", "output", "output/run1"}) 

525 

526 # number of datasets written by pipeline: 

527 # - nQuanta of init_outputs 

528 # - nQuanta of configs 

529 # - packages (single dataset) 

530 # - nQuanta * two output datasets 

531 # - nQuanta of metadata 

532 n_outputs = nQuanta * 5 + 1 

533 refs = butler.registry.queryDatasets(..., collections="output/run1") 

534 self.assertEqual(len(list(refs)), n_outputs) 

535 

536 # re-run with --replace-run (--inputs is not compatible) 

537 args.input = None 

538 args.replace_run = True 

539 args.output_run = "output/run2" 

540 fwk.runPipeline(copy.deepcopy(qgraph), taskFactory, args) 

541 

542 butler.registry._collections.refresh() 

543 collections = set(butler.registry.queryCollections(...)) 

544 self.assertEqual(collections, {"test", "output", "output/run1", "output/run2"}) 

545 

546 # new output collection 

547 refs = butler.registry.queryDatasets(..., collections="output/run2") 

548 self.assertEqual(len(list(refs)), n_outputs) 

549 

550 # old output collection is still there 

551 refs = butler.registry.queryDatasets(..., collections="output/run1") 

552 self.assertEqual(len(list(refs)), n_outputs) 

553 

554 # re-run with --replace-run and --prune-replaced=unstore 

555 args.input = None 

556 args.replace_run = True 

557 args.prune_replaced = "unstore" 

558 args.output_run = "output/run3" 

559 fwk.runPipeline(copy.deepcopy(qgraph), taskFactory, args) 

560 

561 butler.registry._collections.refresh() 

562 collections = set(butler.registry.queryCollections(...)) 

563 self.assertEqual(collections, {"test", "output", "output/run1", "output/run2", "output/run3"}) 

564 

565 # new output collection 

566 refs = butler.registry.queryDatasets(..., collections="output/run3") 

567 self.assertEqual(len(list(refs)), n_outputs) 

568 

569 # old output collection is still there, and it has all datasets but 

570 # they are not in datastore 

571 refs = butler.registry.queryDatasets(..., collections="output/run2") 

572 refs = list(refs) 

573 self.assertEqual(len(refs), n_outputs) 

574 with self.assertRaises(FileNotFoundError): 

575 butler.get(refs[0], collections="output/run2") 

576 

577 # re-run with --replace-run and --prune-replaced=purge 

578 args.input = None 

579 args.replace_run = True 

580 args.prune_replaced = "purge" 

581 args.output_run = "output/run4" 

582 fwk.runPipeline(copy.deepcopy(qgraph), taskFactory, args) 

583 

584 butler.registry._collections.refresh() 

585 collections = set(butler.registry.queryCollections(...)) 

586 # output/run3 should disappear now 

587 self.assertEqual(collections, {"test", "output", "output/run1", "output/run2", "output/run4"}) 

588 

589 # new output collection 

590 refs = butler.registry.queryDatasets(..., collections="output/run4") 

591 self.assertEqual(len(list(refs)), n_outputs) 

592 

593 def testSubgraph(self): 

594 """Test successfull execution of trivial quantum graph. 

595 """ 

596 nQuanta = 5 

597 nNodes = 2 

598 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root) 

599 

600 # Select first two nodes for execution. This depends on node ordering 

601 # which I assume is the same as execution order. 

602 nodeIds = [node.nodeId.number for node in qgraph] 

603 nodeIds = nodeIds[:nNodes] 

604 

605 self.assertEqual(len(qgraph.taskGraph), 5) 

606 self.assertEqual(len(qgraph), nQuanta) 

607 

608 with makeTmpFile(suffix=".qgraph") as tmpname, makeSQLiteRegistry() as registryConfig: 

609 with open(tmpname, "wb") as saveFile: 

610 qgraph.save(saveFile) 

611 

612 args = _makeArgs(qgraph=tmpname, qgraph_node_id=nodeIds, registryConfig=registryConfig) 

613 fwk = CmdLineFwk() 

614 

615 # load graph, should only read a subset 

616 qgraph = fwk.makeGraph(pipeline=None, args=args) 

617 self.assertEqual(len(qgraph), nNodes) 

618 

619 def testShowGraph(self): 

620 """Test for --show options for quantum graph. 

621 """ 

622 fwk = CmdLineFwk() 

623 

624 nQuanta = 2 

625 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root) 

626 

627 args = _makeArgs(show=["graph"]) 

628 fwk.showInfo(args, pipeline=None, graph=qgraph) 

629 

630 def testShowGraphWorkflow(self): 

631 fwk = CmdLineFwk() 

632 

633 nQuanta = 2 

634 butler, qgraph = makeSimpleQGraph(nQuanta, root=self.root) 

635 

636 args = _makeArgs(show=["workflow"]) 

637 fwk.showInfo(args, pipeline=None, graph=qgraph) 

638 

639 # TODO: cannot test "uri" option presently, it instanciates 

640 # butler from command line options and there is no way to pass butler 

641 # mock to that code. 

642 

643 

644class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase): 

645 pass 

646 

647 

648def setup_module(module): 

649 lsst.utils.tests.init() 

650 

651 

652if __name__ == "__main__": 652 ↛ 653line 652 didn't jump to line 653, because the condition on line 652 was never true

653 lsst.utils.tests.init() 

654 unittest.main()