Skip to content

Commit

Permalink
[CDF-23338] Notification create/update bug (#1220)
Browse files Browse the repository at this point in the history
* [CDF-23338] Notification create/update bug

* restore from debugging

* Update cognite_toolkit/_cdf_tk/loaders/_resource_loaders/transformation_loaders.py

Co-authored-by: Anders Albert <[email protected]>

---------

Co-authored-by: Anders Albert <[email protected]>
  • Loading branch information
ronpal and doctrino authored Nov 20, 2024
1 parent e101594 commit d5c1366
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"args": [
"deploy",
"--dry-run",
"--verbose"
],
"console": "integratedTerminal",
"justMyCode": false
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.cdf-tk.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Changes are grouped as follows:
- In `cdf build` when loading `config.[env].yaml` the Toolkit now correctly prefers variables deeper, more
specific, in the hierarchy over more general variables.
- [Alpha feature] `cdf build` will no longer copy content `YAML` files to the build directory.
- A bug caused the comparison with existing Tranformation Notifications to fail. This is now fixed.

### Improved

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,19 @@ def dump_id(cls, id: str) -> dict[str, Any]:
"destination": destination,
}

def _are_equal(
self,
local: TransformationNotificationWrite,
cdf_resource: TransformationNotification,
return_dumped: bool = False,
) -> bool | tuple[bool, dict[str, Any], dict[str, Any]]:
local_dumped = local.dump()
cdf_dumped = cdf_resource.as_write().dump()
cdf_dumped.pop("transformationId")
cdf_dumped["transformationExternalId"] = local.transformation_external_id

return self._return_are_equal(local_dumped, cdf_dumped, return_dumped)

@classmethod
def get_required_capability(
cls, items: TransformationNotificationWriteList | None, read_only: bool
Expand All @@ -508,11 +521,17 @@ def retrieve(self, ids: SequenceNotStr[str]) -> TransformationNotificationList:
result = self.client.transformations.notifications.list(
transformation_external_id=transformation_external_id, destination=destination, limit=-1
)
# list() does not return the transformation_external_id on items
for notification in result:
notification.transformation_external_id = transformation_external_id

except CogniteAPIError:
# The notification endpoint gives a 500 if the notification does not exist.
# The issue has been reported to the service team.
continue

retrieved.extend(result)

return retrieved

def update(self, items: TransformationNotificationWriteList) -> TransformationNotificationList:
Expand Down

0 comments on commit d5c1366

Please sign in to comment.