Coverage for python/lsst/pipe/base/taskFactory.py: 69%

14 statements  

« prev     ^ index     » next       coverage.py v7.2.3, created at 2023-04-22 02:19 -0700

1# This file is part of pipe_base. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://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 <http://www.gnu.org/licenses/>. 

21 

22"""Module defining TaskFactory interface. 

23""" 

24 

25from __future__ import annotations 

26 

27__all__ = ["TaskFactory"] 

28 

29from abc import ABCMeta, abstractmethod 

30from collections.abc import Iterable 

31from typing import TYPE_CHECKING 

32 

33if TYPE_CHECKING: 33 ↛ 34line 33 didn't jump to line 34, because the condition on line 33 was never true

34 from lsst.daf.butler import DatasetRef, LimitedButler 

35 

36 from .pipeline import TaskDef 

37 from .pipelineTask import PipelineTask 

38 

39 

40class TaskFactory(metaclass=ABCMeta): 

41 """Abstract base class for task factory. 

42 

43 Task factory is responsible for creating instances of PipelineTask 

44 subclasses. 

45 """ 

46 

47 @abstractmethod 

48 def makeTask( 

49 self, taskDef: TaskDef, butler: LimitedButler, initInputRefs: Iterable[DatasetRef] | None 

50 ) -> PipelineTask: 

51 """Create new PipelineTask instance from its `~lsst.pipe.base.TaskDef`. 

52 

53 Parameters 

54 ---------- 

55 taskDef : `~lsst.pipe.base.TaskDef` 

56 Task definition structure. 

57 butler : `lsst.daf.butler.LimitedButler` 

58 Butler instance used to obtain initialization inputs for task. 

59 initInputRefs : `Iterable` of `~lsst.daf.butler.DatasetRef` or `None` 

60 List of resolved dataset references for init inputs for this task. 

61 

62 Returns 

63 ------- 

64 task : `PipelineTask` 

65 Instance of a PipelineTask class. 

66 

67 Raises 

68 ------ 

69 Any exceptions that are raised by PipelineTask constructor or its 

70 configuration class are propagated back to caller. 

71 """ 

72 raise NotImplementedError()