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

9 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-23 08:14 +0000

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: 

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 : `~collections.abc.Iterable` of \ 

60 `~lsst.daf.butler.DatasetRef` or `None` 

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

62 

63 Returns 

64 ------- 

65 task : `PipelineTask` 

66 Instance of a PipelineTask class. 

67 

68 Raises 

69 ------ 

70 Any exceptions that are raised by PipelineTask constructor or its 

71 configuration class are propagated back to caller. 

72 """ 

73 raise NotImplementedError()