Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone records recursively before caching #27

Merged
merged 4 commits into from
Aug 9, 2021
Merged

Conversation

tokebe
Copy link
Member

@tokebe tokebe commented Aug 6, 2021

(fixes biothings/biothings_explorer#234)

This change replaces current cache_handler._copyRecord behavior to recursively clone each record, 'freezing' values from getters into standard data properties (also recursively -- if a getter returns an object, that object is recursively cloned).

Unlike #25, this change is slightly more future-proof in that no values to be saved are hard-coded. This may result in some bloating of the data being cached, however.

The following example query returns kg_nodes with biolink:undefined categories, but should work as expected with this change.

{
  "message": {
    "query_graph": {
      "nodes": {
        "n0": {
          "categories": [
            "biolink:Disease"
          ]
        },
        "n1": {
          "ids": [
            "HGNC:6284"
          ],
          "categories": [
            "biolink:Gene"
          ]
        }
      },
      "edges": {
        "e0": {
          "subject": "n0",
          "object": "n1"
        }
      }
    }
  }
}

Copy link
Member

@andrewsu andrewsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce the issue locally and confirm that this PR fixes it for two additional queries (aside from the one in the first PR comment). Also confirmed that the initial response and the cached response are identical (except for the logs).

@andrewsu andrewsu requested a review from newgene August 7, 2021 04:32
@newgene newgene merged commit abb4300 into main Aug 9, 2021
@colleenXu colleenXu deleted the recursive_cache_clone branch October 25, 2023 20:08
@colleenXu colleenXu restored the recursive_cache_clone branch October 25, 2023 20:09
@tokebe tokebe deleted the recursive_cache_clone branch November 29, 2023 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

biolink:undefined on node categories
3 participants