C-Accel-CRIPT / Python-SDK

CRIPT Python SDK
MIT License
10 stars 5 forks source link

Fix problems with the node cache #441

Closed InnocentBug closed 8 months ago

InnocentBug commented 8 months ago

Description

Now the node UUID cache actually works as intended. Users can only have one python object with the same UUID.

Changes

Added a functionality that allows you to circumvent this cache explictly. This should be a feature that users don't really use.

Known Issues

Notes

Checklist

trunk-io[bot] commented 8 months ago

🚫 This pull request was closed and has been removed from the merge queue (details).

InnocentBug commented 8 months ago

@duboyal This fixes a bug, and allows you to load the old tree of a project for comparison as discussed. What you do is the following.

old_project_paginator = cript_api.search(node_type=cript.Project, search_mode=cript.SearchModes.UUID, value_to_search=str(new_project.uuid))
old_project_paginator.auto_load_nodes = False

old_json = next(old_project_paginator)
old_project_node, old_tree_cache = cript.load_nodes_from_json(normal_serial, _use_uuid_cache=dict())

And then you can go about it as discussed.

Key here is, that you override the normal UUID cache with an empty dictionary in the load_nodes_from_json call. And second, the cache that is returned from the call, is the UUID cache that is assembled during the load_call.

This should automatically correspond to what we called the old_tree_map that we discussed.

InnocentBug commented 8 months ago

/trunk merge