Skip to content

Commit

Permalink
Merge pull request #8 from MI-FraunhoferIWM/fix/order-of-committing
Browse files Browse the repository at this point in the history
hotfix: change order of contents to be pushed to the dsms when commited
  • Loading branch information
MBueschelberger authored Mar 22, 2024
2 parents f6b740f + 94b0a08 commit f2ca394
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dsms/knowledge/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ def _update_kitem(kitem: "KItem") -> Response:
raise ValueError(
f"KItem with uuid `{kitem.id}` could not be updated in DSMS: {response.text}`"
)
for key, value in _get_kitem(kitem.id).__dict__.items():
if key != "attachments":
setattr(kitem, key, value)
return response


Expand All @@ -180,8 +183,8 @@ def _update_attachments(kitem: "KItem") -> None:
_upload_attachments(kitem, upload.name)
for remove in differences["remove"]:
_delete_attachments(kitem, remove.name)
new_kitem = _get_kitem(kitem.id)
kitem.attachments = new_kitem.attachments.values # pylint: disable=E1101
for key, value in _get_kitem(kitem.id).__dict__.items():
setattr(kitem, key, value)


def _upload_attachments(kitem: "KItem", attachment: "str") -> None:
Expand Down Expand Up @@ -279,16 +282,14 @@ def _commit_updated(buffer: "Dict[str, KItem]") -> None:
"""Commit the buffer for the `updated` buffers"""
for kitem in buffer.values():
if _kitem_exists(kitem):
_update_attachments(kitem)
if isinstance(kitem.hdf5, pd.DataFrame):
_update_hdf5(kitem.id, kitem.hdf5)
elif isinstance(kitem.hdf5, type(None)) and _inspect_hdf5(
kitem.id
):
_delete_hdf5(kitem.id)
_update_kitem(kitem)
for key, value in _get_kitem(kitem.id).__dict__.items():
setattr(kitem, key, value)
_update_attachments(kitem)


def _commit_deleted(buffer: "Dict[str, KItem]") -> None:
Expand Down

0 comments on commit f2ca394

Please sign in to comment.