errors.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. # KIND, either express or implied. See the License for the
  16. # specific language governing permissions and limitations
  17. # under the License.
  18. from __future__ import annotations
  19. import warnings
  20. from sqlalchemy import Column, Integer, String, Text
  21. from airflow.exceptions import RemovedInAirflow3Warning
  22. from airflow.models.base import Base
  23. from airflow.utils.sqlalchemy import UtcDateTime
  24. class ParseImportError(Base):
  25. """Stores all Import Errors which are recorded when parsing DAGs and displayed on the Webserver."""
  26. __tablename__ = "import_error"
  27. id = Column(Integer, primary_key=True)
  28. timestamp = Column(UtcDateTime)
  29. filename = Column(String(1024))
  30. stacktrace = Column(Text)
  31. processor_subdir = Column(String(2000), nullable=True)
  32. def __getattr__(name: str):
  33. # PEP-562: Lazy loaded attributes on python modules
  34. if name == "ImportError":
  35. warnings.warn(
  36. f"Model class '{__name__}.ImportError' is deprecated due to shadowing with builtin exception "
  37. f"ImportError and will be removed in the future. "
  38. f"Please consider to use '{__name__}.ParseImportError' instead.",
  39. RemovedInAirflow3Warning,
  40. stacklevel=2,
  41. )
  42. return ParseImportError
  43. raise AttributeError(f"module {__name__} has no attribute {name}")