biothings / biothings.api

BioThings API framework - Making high-performance API for biological annotation data
https://biothings.io
Apache License 2.0
45 stars 25 forks source link

ReleaseManager does not read "move" operation from jsondiff results #237

Open erikyao opened 2 years ago

erikyao commented 2 years ago

1. Problem

Involved method: analyze_diff

Code example:

from biothings.utils.jsondiff import make as jsondiff

old_mapping = {
  "clinvar": {
    "properties": {
      "gene": {
        "properties": {
          #############
          # OLD FIELD #
          #############
          "gene_id": {
            "type": "long"
          }
        }
      },
    }
  }
}

new_mapping = {
  "clinvar": {
    "properties": {
      "gene": {
        "properties": {
          ###############
          # NEW FIELD 1 #
          ###############
          "id": {
            "type": "long"
          },
          ###############
          # NEW FIELD 2 #
          ###############
          "new_id": {
            "type": "long"
          }
        }
      },
    }
  },
}

diff_result = jsondiff(old_mapping, new_mapping)
print(diff_result)

Output:

[{'op': 'move',
  'path': '/clinvar/properties/gene/properties/id',
  'from': '/clinvar/properties/gene/properties/gene_id'},
 {'op': 'add',
  'path': '/clinvar/properties/gene/properties/new_id',
  'value': {'type': 'long'}}]

However, 'op': 'move' is not handled in analyze_diff. It's better to split move(path="id", from="gene_id") => add(path="id") + remove(path="gene_id") when generating the release notes.

2. Reference

Accoding to rfc6902, add, remove, replace, move are all valid operations.

erikyao commented 2 years ago

To be fixed along with https://github.com/biothings/myvariant.info/issues/103

erikyao commented 1 year ago

Now the involved code are at https://github.com/biothings/biothings.api/blob/master/biothings/hub/datarelease/releasenote.py#L212