Skip to content

Main

cognite.neat._issues.warnings #

All warnings raised by the neat package are defined here. Note this module is called 'warnings' which conflicts with the built-in Python warnings module. However, it is expected to always be used in an absolute import, and should thus not cause a naming conflict.

DefaultWarning dataclass #

Bases: NeatWarning

{category}: {warning}

Source code in cognite/neat/_issues/_base.py
@dataclass(unsafe_hash=True)
class DefaultWarning(NeatWarning):
    """{category}: {warning}"""

    extra = "Source: {source}"

    warning: str
    category: str
    source: str | None = None

    @classmethod
    def from_warning_message(cls, warning: WarningMessage) -> NeatWarning:
        if isinstance(warning.message, NeatWarning):
            return warning.message

        return cls(
            warning=str(warning.message),
            category=warning.category.__name__,
            source=warning.source,
        )

    def as_message(self) -> str:
        return str(self.warning)

FileItemNotSupportedWarning dataclass #

Bases: NeatWarning

The item {item} in {filepath} is not supported. The item will be skipped

Source code in cognite/neat/_issues/warnings/_external.py
@dataclass(unsafe_hash=True)
class FileItemNotSupportedWarning(NeatWarning):
    """The item {item} in {filepath} is not supported. The item will be skipped"""

    item: str
    filepath: Path

FileMissingRequiredFieldWarning dataclass #

Bases: NeatWarning

Missing required {field_name} in {filepath}: {field}. The file will be skipped

Source code in cognite/neat/_issues/warnings/_external.py
@dataclass(unsafe_hash=True)
class FileMissingRequiredFieldWarning(NeatWarning):
    """Missing required {field_name} in {filepath}: {field}. The file will be skipped"""

    filepath: Path
    field_name: str
    field: str

FileReadWarning dataclass #

Bases: NeatWarning

Error when reading file, {filepath}: {reason}

Source code in cognite/neat/_issues/warnings/_external.py
@dataclass(unsafe_hash=True)
class FileReadWarning(NeatWarning):
    """Error when reading file, {filepath}: {reason}"""

    filepath: Path
    reason: str

FileTypeUnexpectedWarning dataclass #

Bases: NeatWarning

Unexpected file type: {filepath}. Expected format: {expected_format}

Source code in cognite/neat/_issues/warnings/_external.py
@dataclass(unsafe_hash=True)
class FileTypeUnexpectedWarning(NeatWarning):
    """Unexpected file type: {filepath}. Expected format: {expected_format}"""

    extra = "Error: {error_message}"

    filepath: Path
    expected_format: frozenset[str]
    error_message: str | None = None

NeatValueWarning dataclass #

Bases: NeatWarning

{value}

Source code in cognite/neat/_issues/warnings/_general.py
@dataclass(unsafe_hash=True)
class NeatValueWarning(NeatWarning):
    """{value}"""

    value: str

NotSupportedWarning dataclass #

Bases: NeatWarning

{feature} is not supported

Source code in cognite/neat/_issues/warnings/_general.py
@dataclass(unsafe_hash=True)
class NotSupportedWarning(NeatWarning):
    """{feature} is not supported"""

    feature: str

RegexViolationWarning dataclass #

Bases: NeatWarning

The value '{value}' of {identifier} does not match the {pattern_name} pattern '{pattern}'

Source code in cognite/neat/_issues/warnings/_general.py
@dataclass(unsafe_hash=True)
class RegexViolationWarning(NeatWarning):
    """The value '{value}' of {identifier} does not match the {pattern_name} pattern '{pattern}'"""

    extra = "{motivation}"
    value: str
    pattern: str
    identifier: str
    pattern_name: str
    motivation: str | None = None

BreakingModelingPrincipleWarning dataclass #

Bases: NeatWarning, ABC

{warning_class}: {specific} violates the {principle} principle. See {url} for more information.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class BreakingModelingPrincipleWarning(NeatWarning, ABC):
    """{warning_class}: {specific} violates the {principle} principle.
    See {url} for more information."""

    url: ClassVar[str]
    specific: str

    def as_message(self) -> str:
        principle = type(self).__name__.removesuffix("Warning")
        url = f"{_BASE_URL}#{self.url}"
        return (self.__doc__ or "").format(
            warning_class=BreakingModelingPrincipleWarning.__name__,
            specific=self.specific,
            principle=principle,
            url=url,
        )

CDFNotSupportedWarning dataclass #

Bases: NeatWarning, ABC

This is a base class for warnings for modeling issues that will likely lead to the CDF API rejecting the model.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class CDFNotSupportedWarning(NeatWarning, ABC):
    """This is a base class for warnings for modeling issues that will
    likely lead to the CDF API rejecting the model."""

    ...

NotSupportedHasDataFilterLimitWarning dataclass #

Bases: CDFNotSupportedWarning

The view {view_id} uses a hasData filter applied to {count} containers, which is more than the limit {limit}.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class NotSupportedHasDataFilterLimitWarning(CDFNotSupportedWarning):
    """The view {view_id} uses a hasData filter applied to {count} containers, which is more than the limit {limit}."""

    fix = "Do not map to more than {limit} containers."

    view_id: ViewId
    count: int
    limit: int = DMS_VIEW_CONTAINER_SIZE_LIMIT

NotSupportedViewContainerLimitWarning dataclass #

Bases: CDFNotSupportedWarning

The view {view_id} maps, {count} containers, which is more than the limit {limit}.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class NotSupportedViewContainerLimitWarning(CDFNotSupportedWarning):
    """The view {view_id} maps, {count} containers, which is more than the limit {limit}."""

    fix = "Reduce the number of containers the view maps to." ""

    view_id: ViewId
    count: int
    limit: int = DMS_VIEW_CONTAINER_SIZE_LIMIT

PrincipleMatchingSpaceAndVersionWarning dataclass #

Bases: BreakingModelingPrincipleWarning

{warning_class}: {specific} violates the {principle} principle. See {url} for more information.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class PrincipleMatchingSpaceAndVersionWarning(BreakingModelingPrincipleWarning):
    """{warning_class}: {specific} violates the {principle} principle.
    See {url} for more information."""

    url = "all-views-of-a-data-models-have-the-same-version-and-space-as-the-data-model"

PrincipleOneModelOneSpaceWarning dataclass #

Bases: BreakingModelingPrincipleWarning

{warning_class}: {specific} violates the {principle} principle. See {url} for more information.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class PrincipleOneModelOneSpaceWarning(BreakingModelingPrincipleWarning):
    """{warning_class}: {specific} violates the {principle} principle.
    See {url} for more information."""

    url = "all-data-models-are-kept-in-its-own-space"

PrincipleSolutionBuildsOnEnterpriseWarning dataclass #

Bases: BreakingModelingPrincipleWarning

{warning_class}: {specific} violates the {principle} principle. See {url} for more information.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class PrincipleSolutionBuildsOnEnterpriseWarning(BreakingModelingPrincipleWarning):
    """{warning_class}: {specific} violates the {principle} principle.
    See {url} for more information."""

    url = "solution-data-models-should-always-be-referencing-the-enterprise-data-model"

UserModelingWarning dataclass #

Bases: NeatWarning, ABC

This is a generic warning for user modeling issues. These warnings will not cause the resulting model to be invalid, but will likely lead to suboptimal performance, unnecessary complexity, or other issues.

Source code in cognite/neat/_issues/warnings/_models.py
@dataclass(unsafe_hash=True)
class UserModelingWarning(NeatWarning, ABC):
    """This is a generic warning for user modeling issues.
    These warnings will not cause the resulting model to be invalid, but
    will likely lead to suboptimal performance, unnecessary complexity, or other issues."""

    ...

PropertyDefinitionDuplicatedWarning dataclass #

Bases: PropertyWarning[T_Identifier]

Got multiple values for the {resource_type} {identifier}.{property_name} {values}.

Source code in cognite/neat/_issues/warnings/_properties.py
@dataclass(unsafe_hash=True)
class PropertyDefinitionDuplicatedWarning(PropertyWarning[T_Identifier]):
    """Got multiple values for the {resource_type} {identifier}.{property_name} {values}.
    {default_action}"""

    extra = "Recommended action: {recommended_action}"

    values: frozenset[str]
    default_action: str
    recommended_action: str | None = None

PropertyNotFoundWarning dataclass #

Bases: PropertyWarning, Generic[T_Identifier, T_ReferenceIdentifier]

The {resource_type} with identifier {identifier} does not have a property {property_name} referred to by {referred_type} {referred_by} does not exist. This will be ignored.

Source code in cognite/neat/_issues/warnings/_properties.py
@dataclass(unsafe_hash=True)
class PropertyNotFoundWarning(PropertyWarning, Generic[T_Identifier, T_ReferenceIdentifier]):
    """The {resource_type} with identifier {identifier} does not have a property {property_name} referred
    to by {referred_type} {referred_by} does not exist. This will be ignored.
    """

    fix = "Ensure the {resource_type} {identifier} has a {property_name} property"
    referred_by: T_ReferenceIdentifier
    referred_type: ResourceType

PropertyTypeNotSupportedWarning dataclass #

Bases: PropertyWarning[T_Identifier]

The {resource_type} with identifier {identifier} has a property {property_name} of unsupported type {property_type}. This will be ignored.

Source code in cognite/neat/_issues/warnings/_properties.py
@dataclass(unsafe_hash=True)
class PropertyTypeNotSupportedWarning(PropertyWarning[T_Identifier]):
    """The {resource_type} with identifier {identifier} has a property {property_name}
    of unsupported type {property_type}. This will be ignored."""

    property_type: str

PropertyValueTypeUndefinedWarning dataclass #

Bases: PropertyWarning[T_Identifier]

The {resource_type} with identifier {identifier} has a property {property_name} which has undefined value type. This may result in unexpected behavior when exporting rules.

Source code in cognite/neat/_issues/warnings/_properties.py
@dataclass(unsafe_hash=True)
class PropertyValueTypeUndefinedWarning(PropertyWarning[T_Identifier]):
    """The {resource_type} with identifier {identifier} has a property {property_name}
    which has undefined value type. This may result in unexpected behavior when exporting rules.
    {default_action}"""

    extra = "Recommended action: {recommended_action}"

    default_action: str
    recommended_action: str | None = None

ResourceNeatWarning dataclass #

Bases: NeatWarning, Generic[T_Identifier]

Base class for resource warnings {resource_type} with identifier {identifier}

Source code in cognite/neat/_issues/warnings/_resources.py
@dataclass(unsafe_hash=True)
class ResourceNeatWarning(NeatWarning, Generic[T_Identifier]):
    """Base class for resource warnings {resource_type} with identifier {identifier}"""

    identifier: T_Identifier
    resource_type: ResourceType

ResourceNotFoundWarning dataclass #

Bases: ResourceNeatWarning, Generic[T_Identifier, T_ReferenceIdentifier]

The {resource_type} with identifier {identifier} referred by {referred_type} {referred_by} does not exist. This will be ignored.

Source code in cognite/neat/_issues/warnings/_resources.py
@dataclass(unsafe_hash=True)
class ResourceNotFoundWarning(ResourceNeatWarning, Generic[T_Identifier, T_ReferenceIdentifier]):
    """The {resource_type} with identifier {identifier} referred by {referred_type} {referred_by} does not exist.
    This will be ignored."""

    fix = "Create the {resource_type}"

    referred_by: T_ReferenceIdentifier
    referred_type: str

ResourceRetrievalWarning dataclass #

Bases: NeatWarning, Generic[T_Identifier]

Failed to retrieve {resource_type} with identifiers {resources}. Continuing without these resources.

Source code in cognite/neat/_issues/warnings/_resources.py
@dataclass(unsafe_hash=True)
class ResourceRetrievalWarning(NeatWarning, Generic[T_Identifier]):
    """Failed to retrieve {resource_type} with identifiers {resources}. Continuing without
    these resources."""

    extra = "The error was: {error}"

    fix = "Check the error."

    resources: frozenset[T_Identifier]
    resource_type: ResourceType
    error: str | None = None

ResourcesDuplicatedWarning dataclass #

Bases: NeatWarning, Generic[T_Identifier]

Duplicated {resource_type} with identifiers {resources} were found. {default_action}

Source code in cognite/neat/_issues/warnings/_resources.py
@dataclass(unsafe_hash=True)
class ResourcesDuplicatedWarning(NeatWarning, Generic[T_Identifier]):
    """Duplicated {resource_type} with identifiers {resources} were found. {default_action}"""

    fix = "Remove the duplicate resources"

    resources: frozenset[T_Identifier]
    resource_type: ResourceType
    default_action: str

ResourceTypeNotSupportedWarning dataclass #

Bases: ResourceNeatWarning[T_Identifier]

The {resource_type} with identifier {identifier} is not supported. This will be ignored.

Source code in cognite/neat/_issues/warnings/_resources.py
class ResourceTypeNotSupportedWarning(ResourceNeatWarning[T_Identifier]):
    """The {resource_type} with identifier {identifier} is not supported. This will be ignored."""

    resource_type: str  # type: ignore[assignment]