ynput / ayon-python-api

Apache License 2.0
8 stars 3 forks source link

Operations enhancements #128

Closed iLLiCiTiT closed 4 months ago

iLLiCiTiT commented 5 months ago

Description

Added helper function prepare_changes to make simple diff for updates. Function new_hero_version_entity reuse new_version_entity Fix duplicated assignment of data variable.

kalisp commented 5 months ago

Not sure if I understand what this function should be for.

I tested it with:

from ayon_core.client import get_version_by_id
from ayon_api.operations import prepare_changes

orig_ver_doc = get_version_by_id ("ayon_test", "7039cfd5c5d711ee83b2d88083815492")

ver_doc = get_version_by_id ("ayon_test", "7039cfd5c5d711ee83b2d88083815492")
ver_doc["author"] = "different author"

changes = (orig_ver_doc, ver_doc, "version")
print(changes)

and only see change in author key, but got, what it seems, full version doc.

iLLiCiTiT commented 5 months ago

I tested it with:

You forgot to call the function. changes = (orig_ver_doc, ver_doc, "version") > changes = prepare_changes(orig_ver_doc, ver_doc, "version")

full version doc.

I would start to call them entities instead of docs. They were called docs because they were mongo documents in OpenPype.