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

30 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-24 10:00 +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 

22import sys 

23from collections import Counter 

24from typing import Any 

25 

26import pydantic 

27 

28from .quantumNode import BuildId 

29 

30__all__ = ("QgraphSummary", "QgraphTaskSummary") 

31 

32 

33class QgraphTaskSummary(pydantic.BaseModel): 

34 """Quanta information summarized for single PipelineTask.""" 

35 

36 taskLabel: str | None = None 

37 """PipelineTask label.""" 

38 

39 numQuanta: int = 0 

40 """Number of Quanta for this PipelineTask in this QuantumGraph.""" 

41 

42 numInputs: dict[str, int] = Counter() 

43 """Total number of inputs per dataset type name for this PipelineTask.""" 

44 

45 numOutputs: dict[str, int] = Counter() 

46 """Total number of outputs per dataset type name for this PipelineTask.""" 

47 

48 # Work around the fact that Sphinx chokes on Pydantic docstring formatting, 

49 # when we inherit those docstrings in our public classes. 

50 if "sphinx" in sys.modules: # pragma: no cover 

51 

52 def copy(self, *args: Any, **kwargs: Any) -> Any: 

53 """See `pydantic.BaseModel.copy`.""" 

54 return super().copy(*args, **kwargs) 

55 

56 def model_dump(self, *args: Any, **kwargs: Any) -> Any: 

57 """See `pydantic.BaseModel.model_dump`.""" 

58 return super().model_dump(*args, **kwargs) 

59 

60 def model_dump_json(self, *args: Any, **kwargs: Any) -> Any: 

61 """See `pydantic.BaseModel.model_dump_json`.""" 

62 return super().model_dump_json(*args, **kwargs) 

63 

64 def model_copy(self, *args: Any, **kwargs: Any) -> Any: 

65 """See `pydantic.BaseModel.model_copy`.""" 

66 return super().model_copy(*args, **kwargs) 

67 

68 @classmethod 

69 def model_json_schema(cls, *args: Any, **kwargs: Any) -> Any: 

70 """See `pydantic.BaseModel.model_json_schema`.""" 

71 return super().model_json_schema(*args, **kwargs) 

72 

73 

74class QgraphSummary(pydantic.BaseModel): 

75 """Report for the QuantumGraph creation or reading.""" 

76 

77 graphID: BuildId 

78 """QuantumGraph ID.""" 

79 

80 cmdLine: str | None = None 

81 """Command line for creation of original QuantumGraph.""" 

82 

83 creationUTC: str | None = None 

84 """Time of creation.""" 

85 

86 inputCollection: list[str] | None = None 

87 """Input collection.""" 

88 

89 outputCollection: str | None = None 

90 """Output collection.""" 

91 

92 outputRun: str | None = None 

93 """Output run collection.""" 

94 

95 qgraphTaskSummaries: dict[str, QgraphTaskSummary] = {} 

96 """Quanta information summarized per PipelineTask.""" 

97 

98 # Work around the fact that Sphinx chokes on Pydantic docstring formatting, 

99 # when we inherit those docstrings in our public classes. 

100 if "sphinx" in sys.modules: # pragma: no cover 

101 

102 def copy(self, *args: Any, **kwargs: Any) -> Any: 

103 """See `pydantic.BaseModel.copy`.""" 

104 return super().copy(*args, **kwargs) 

105 

106 def model_dump(self, *args: Any, **kwargs: Any) -> Any: 

107 """See `pydantic.BaseModel.model_dump`.""" 

108 return super().model_dump(*args, **kwargs) 

109 

110 def model_dump_json(self, *args: Any, **kwargs: Any) -> Any: 

111 """See `pydantic.BaseModel.model_dump_json`.""" 

112 return super().model_dump_json(*args, **kwargs) 

113 

114 def model_copy(self, *args: Any, **kwargs: Any) -> Any: 

115 """See `pydantic.BaseModel.model_copy`.""" 

116 return super().model_copy(*args, **kwargs) 

117 

118 @classmethod 

119 def model_json_schema(cls, *args: Any, **kwargs: Any) -> Any: 

120 """See `pydantic.BaseModel.model_json_schema`.""" 

121 return super().model_json_schema(*args, **kwargs)