1- from collections .abc import Callable , Mapping , Sequence
2- from dataclasses import dataclass
1+ from collections .abc import Callable , Mapping , Sequence , Set
2+ from dataclasses import dataclass , field
33from functools import partial
44from typing import cast
55
2323 SuccessResponseItems ,
2424)
2525from cognite .neat ._utils .http_client ._data_classes import APIResponse
26+ from cognite .neat ._utils .text import humanize_collection
2627from cognite .neat ._utils .useful_types import ModusOperandi , T_Reference
2728
2829from ._differ import ItemDiffer
@@ -68,6 +69,7 @@ class DeploymentOptions:
6869 drop_data : bool = False
6970 max_severity : SeverityType = SeverityType .WARNING
7071 modus_operandi : ModusOperandi = "additive"
72+ governed_spaces : Set [str ] = field (default_factory = set )
7173
7274
7375class SchemaDeployer (OnSuccessResultProducer ):
@@ -246,8 +248,7 @@ def remove_readd_modified_indexes_and_constraints(
246248 modified_diffs .append (diff )
247249 return modified_diffs
248250
249- @classmethod
250- def _skip_resource (cls , resource_id : T_ResourceId , model_space : str ) -> str | None :
251+ def _skip_resource (self , resource_id : T_ResourceId , model_space : str ) -> str | None :
251252 """Checks if a resource should be skipped based on its space.
252253
253254 Args:
@@ -259,10 +260,11 @@ def _skip_resource(cls, resource_id: T_ResourceId, model_space: str) -> str | No
259260 """
260261 if resource_id .space in COGNITE_SPACES :
261262 return f"Skipping resource as it is in the reserved Cognite space '{ resource_id .space } '."
262- elif resource_id .space != model_space :
263+ elif resource_id .space != model_space and resource_id .space not in self .options .governed_spaces :
264+ governed_spaces = {model_space } | self .options .governed_spaces
263265 return (
264266 f"Skipping resource as it is in the space '{ resource_id .space } '"
265- f" not matching data model space ' { model_space } ' ."
267+ f" not matching any of the governed spaces: { humanize_collection ( governed_spaces ) } ."
266268 )
267269 return None
268270
0 commit comments