Skip to content

Commit 20340e5

Browse files
committed
refactor: added option to SchemaDeployer
1 parent 3ce89c6 commit 20340e5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cognite/neat/_data_model/deployer/deployer.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
33
from functools import partial
44
from typing import cast
55

@@ -23,6 +23,7 @@
2323
SuccessResponseItems,
2424
)
2525
from cognite.neat._utils.http_client._data_classes import APIResponse
26+
from cognite.neat._utils.text import humanize_collection
2627
from cognite.neat._utils.useful_types import ModusOperandi, T_Reference
2728

2829
from ._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

7375
class 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

Comments
 (0)