Coverage for dataexcept/__init__.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-27 14:44 +0000

1"""Top-level package for DataExcept. 

2 

3Every exception the package defines is importable straight from here:: 

4 

5 from dataexcept import ValidationError, ModelTrainingError 

6 

7They all derive from :class:`DataExceptError`, so one clause catches every 

8operational exception this package raises:: 

9 

10 except DataExceptError: 

11 ... 

12 

13The domain modules (``datascience_exceptions``, ``pipeline_exceptions`` and so 

14on) remain importable and export the same objects, so both spellings work and 

15refer to the same classes. 

16""" 

17 

18from pathlib import Path 

19 

20try: # Python >=3.11 

21 import tomllib # type: ignore 

22except ModuleNotFoundError: # pragma: no cover - fallback for Python <3.11 

23 import tomli as tomllib # type: ignore 

24 

25from importlib import metadata 

26 

27from . import ( # noqa: F401 

28 broker_exceptions, 

29 database_exceptions, 

30 dataengineering_exceptions, 

31 datascience_exceptions, 

32 exceptions, 

33 io_exceptions, 

34 logging_helpers, 

35 network_exceptions, 

36 pandas_exceptions, 

37 pipeline_exceptions, 

38 security_exceptions, 

39) 

40from .base import DataExceptError, UnpicklableCause, UnpicklableValue 

41from .broker_exceptions import ( 

42 BrokerConnectionError, 

43 BrokerTimeoutError, 

44 MessageAcknowledgementError, 

45 MessageBrokerError, 

46 MessageConsumeError, 

47 MessagePublishError, 

48) 

49from .database_exceptions import ( 

50 DatabaseConnectionError, 

51 DatabaseError, 

52 QueryExecutionError, 

53 TransactionError, 

54) 

55from .dataengineering_exceptions import ( 

56 BatchProcessingError, 

57 DataEngineeringError, 

58 DataTransformationError, 

59 DataWarehouseConnectionError, 

60 ETLJobError, 

61 MissingPartitionError, 

62 SchemaEvolutionError, 

63) 

64from .datascience_exceptions import ( 

65 BiasDetectionError, 

66 ConvergenceError, 

67 CrossValidationError, 

68 DataAugmentationError, 

69 DataDriftError, 

70 DataExportError, 

71 DataFormatError, 

72 DataImbalanceError, 

73 DataLeakageError, 

74 DataLoadingError, 

75 DataNormalizationError, 

76 DataScienceError, 

77 DataValidationError, 

78 DeploymentError, 

79 DimensionalityReductionError, 

80 EarlyStoppingError, 

81 ExperimentTrackingError, 

82 ExplainabilityError, 

83 FeatureEngineeringError, 

84 FeatureScalingError, 

85 FeatureSelectionError, 

86 GPUOutOfMemoryError, 

87 HyperparameterError, 

88 HyperparameterTuningError, 

89 MissingDataError, 

90 ModelCompatibilityError, 

91 ModelEvaluationError, 

92 ModelInferenceError, 

93 ModelSerializationError, 

94 ModelTrainingError, 

95 OutlierDetectionError, 

96 OverfittingError, 

97 PredictionError, 

98 ResourceLimitError, 

99 SchemaMismatchError, 

100 TrainingTimeoutError, 

101 UnderfittingError, 

102) 

103from .exceptions import ( 

104 AuthenticationError, 

105 AuthorizationError, 

106 ConfigurationError, 

107 CronExpressionError, 

108 DependencyError, 

109 DeserializationError, 

110 EmailError, 

111 JobCancellationError, 

112 JobError, 

113 NotificationError, 

114 OperationTimeoutError, 

115 ParsingError, 

116 ResourceNotFoundError, 

117 ScheduleConflictError, 

118 SerializationError, 

119 ServiceConnectionError, 

120 ValidationError, 

121 WebhookError, 

122) 

123from .failure_metadata import FailureKind, FailureMetadata 

124from .io_exceptions import CustomIOError, FileLockError, FileReadError, FileWriteError 

125from .logging_helpers import Context, log_and_raise, log_exception, log_then_raise 

126from .network_exceptions import ( 

127 ConnectionTimeoutError, 

128 HostUnreachableError, 

129 NetworkError, 

130 ProtocolError, 

131) 

132from .observability import OperationContext, exception_to_observability_event 

133from .pandas_exceptions import ( 

134 DtypeMismatchError, 

135 IndexAlignmentError, 

136 MergeKeyError, 

137 MissingColumnError, 

138 PandasError, 

139 PandasIOError, 

140) 

141from .pino import envelope_to_pino, exception_to_pino 

142from .pipeline_exceptions import ( 

143 ApiError, 

144 DataFetchError, 

145 ExternalServiceError, 

146 FeaturePreprocessingError, 

147 PipelineError, 

148 PipelineNotificationError, 

149 PreprocessingError, 

150 RetryLimitExceededError, 

151 ServiceAuthenticationError, 

152 ServiceAuthorizationError, 

153 ServiceTimeoutError, 

154 StorageError, 

155 TimeDeltaTooLargeError, 

156 TypeCheckError, 

157) 

158from .schema import ( 

159 ENVELOPE_SCHEMA_ID, 

160 ENVELOPE_SCHEMA_VERSION, 

161 PINO_PROFILE_ID, 

162 PINO_PROFILE_VERSION, 

163 envelope_schema, 

164 pino_profile_schema, 

165) 

166from .security_exceptions import ( 

167 DecryptionError, 

168 EncryptionError, 

169 InvalidTokenError, 

170 SecurityError, 

171) 

172from .sentry import enrich_sentry_event 

173from .serialization import exception_to_dict, exception_to_json 

174from .wrapping import wrap, wrapping 

175 

176__all__ = [ 

177 "DataExceptError", 

178 "UnpicklableCause", 

179 "UnpicklableValue", 

180 "FailureKind", 

181 "FailureMetadata", 

182 "ApiError", 

183 "AuthenticationError", 

184 "AuthorizationError", 

185 "BatchProcessingError", 

186 "BiasDetectionError", 

187 "BrokerConnectionError", 

188 "BrokerTimeoutError", 

189 "ConfigurationError", 

190 "ConnectionTimeoutError", 

191 "ConvergenceError", 

192 "CronExpressionError", 

193 "CrossValidationError", 

194 "CustomIOError", 

195 "DataAugmentationError", 

196 "DataDriftError", 

197 "DataEngineeringError", 

198 "DataExportError", 

199 "DataFetchError", 

200 "DataFormatError", 

201 "DataImbalanceError", 

202 "DataLeakageError", 

203 "DataLoadingError", 

204 "DataNormalizationError", 

205 "DataScienceError", 

206 "DataTransformationError", 

207 "DataValidationError", 

208 "DataWarehouseConnectionError", 

209 "DatabaseConnectionError", 

210 "DatabaseError", 

211 "DecryptionError", 

212 "DependencyError", 

213 "DeploymentError", 

214 "DeserializationError", 

215 "DimensionalityReductionError", 

216 "DtypeMismatchError", 

217 "ETLJobError", 

218 "EarlyStoppingError", 

219 "EmailError", 

220 "EncryptionError", 

221 "ExperimentTrackingError", 

222 "ExplainabilityError", 

223 "ExternalServiceError", 

224 "FeatureEngineeringError", 

225 "FeaturePreprocessingError", 

226 "FeatureScalingError", 

227 "FeatureSelectionError", 

228 "FileLockError", 

229 "FileReadError", 

230 "FileWriteError", 

231 "GPUOutOfMemoryError", 

232 "HostUnreachableError", 

233 "HyperparameterError", 

234 "HyperparameterTuningError", 

235 "IndexAlignmentError", 

236 "InvalidTokenError", 

237 "JobCancellationError", 

238 "JobError", 

239 "MergeKeyError", 

240 "MessageAcknowledgementError", 

241 "MessageBrokerError", 

242 "MessageConsumeError", 

243 "MessagePublishError", 

244 "MissingColumnError", 

245 "MissingDataError", 

246 "MissingPartitionError", 

247 "ModelCompatibilityError", 

248 "ModelEvaluationError", 

249 "ModelInferenceError", 

250 "ModelSerializationError", 

251 "ModelTrainingError", 

252 "NetworkError", 

253 "NotificationError", 

254 "OperationTimeoutError", 

255 "OutlierDetectionError", 

256 "OverfittingError", 

257 "PandasError", 

258 "PandasIOError", 

259 "ParsingError", 

260 "PipelineError", 

261 "PipelineNotificationError", 

262 "PredictionError", 

263 "PreprocessingError", 

264 "ProtocolError", 

265 "QueryExecutionError", 

266 "ResourceLimitError", 

267 "ResourceNotFoundError", 

268 "RetryLimitExceededError", 

269 "ScheduleConflictError", 

270 "SchemaEvolutionError", 

271 "SchemaMismatchError", 

272 "SecurityError", 

273 "SerializationError", 

274 "ServiceAuthenticationError", 

275 "ServiceAuthorizationError", 

276 "ServiceConnectionError", 

277 "ServiceTimeoutError", 

278 "StorageError", 

279 "TimeDeltaTooLargeError", 

280 "TrainingTimeoutError", 

281 "TransactionError", 

282 "TypeCheckError", 

283 "UnderfittingError", 

284 "ValidationError", 

285 "WebhookError", 

286 "wrap", 

287 "wrapping", 

288 "exception_to_dict", 

289 "exception_to_json", 

290 "exception_to_observability_event", 

291 "OperationContext", 

292 "ENVELOPE_SCHEMA_ID", 

293 "ENVELOPE_SCHEMA_VERSION", 

294 "envelope_schema", 

295 "PINO_PROFILE_ID", 

296 "PINO_PROFILE_VERSION", 

297 "pino_profile_schema", 

298 "envelope_to_pino", 

299 "exception_to_pino", 

300 "enrich_sentry_event", 

301 "Context", 

302 "log_and_raise", 

303 "log_exception", 

304 "log_then_raise", 

305 "broker_exceptions", 

306 "database_exceptions", 

307 "dataengineering_exceptions", 

308 "datascience_exceptions", 

309 "exceptions", 

310 "io_exceptions", 

311 "logging_helpers", 

312 "network_exceptions", 

313 "pandas_exceptions", 

314 "pipeline_exceptions", 

315 "security_exceptions", 

316] 

317 

318try: 

319 __version__ = metadata.version("DataExcept") 

320except metadata.PackageNotFoundError: # pragma: no cover - fallback during dev 

321 _root = Path(__file__).resolve().parents[1] 

322 with open(_root / "pyproject.toml", "rb") as _f: 

323 __version__ = tomllib.load(_f)["project"]["version"]