deckhand.engine.revision_diff module

deckhand.engine.revision_diff.revision_diff(revision_id, comparison_revision_id, deepdiff=False)[source]

Generate the diff between two revisions.

Generate the diff between the two revisions: revision_id and comparison_revision_id. a. When deepdiff=False: A basic comparison of the revisions in terms of how the buckets involved have changed is generated. Only buckets with existing documents in either of the two revisions in question will be reported. b. When deepdiff=True: Along with basic comparision, It will generate deep diff between revisions’ modified buckets.

Only in case of diff, The ordering of the two revision IDs is interchangeable, i.e. no matter the order, the same result is generated.

The differences include:

  • “created”: A bucket has been created between the revisions.
  • “deleted”: A bucket has been deleted between the revisions.
  • “modified”: A bucket has been modified between the revisions.
    When deepdiff is enabled, It also includes deep difference between the revisions.
  • “unmodified”: A bucket remains unmodified between the revisions.
Parameters:
  • revision_id – ID of the first revision.
  • comparison_revision_id – ID of the second revision.
  • deepdiff – Whether deepdiff needed or not.
Returns:

A dictionary, keyed with the bucket IDs, containing any of the differences enumerated above.

Examples Diff:

# GET /api/v1.0/revisions/6/diff/3
bucket_a: created
bucket_b: deleted
bucket_c: modified
bucket_d: unmodified

# GET /api/v1.0/revisions/0/diff/6
bucket_a: created
bucket_c: created
bucket_d: created

# GET /api/v1.0/revisions/6/diff/6
bucket_a: unmodified
bucket_c: unmodified
bucket_d: unmodified

# GET /api/v1.0/revisions/0/diff/0
{}

Examples DeepDiff:

# GET /api/v1.0/revisions/3/deepdiff/4
bucket_a: modified
bucket_a diff:
  document_changed:
    count: 1
    details:
      ('example/Kind/v1', 'doc-b'):
        data_changed:
          values_changed:
            root['foo']: {new_value: 3, old_value: 2}
        metadata_changed: {}

# GET /api/v1.0/revisions/2/deepdiff/3
bucket_a: modified
bucket_a diff:
  document_added:
    count: 1
    details:
    - [example/Kind/v1, doc-c]

# GET /api/v1.0/revisions/0/deepdiff/0
{}

# GET /api/v1.0/revisions/0/deepdiff/3
bucket_a: created