Diff#
TensorBay supports showing changes between commits or drafts.
Before operating the diff, a dataset client instance with commits is needed. See more details in Draft and Commit
Get Diff#
TensorBay SDK allows getting the dataset diff through basehead. Currently, only obtaining the diff between the head and its parent commit is supported; that is, the head is the given version(commit or draft) while the base is parent commit of the head.
diff = dataset_client.get_diff(head=head)
The type of the head indicates the version status: string
for commit, int
for draft.
Get Diff on Revision#
For example, the following diff records the difference between the commit whose id is "3bc35d806e0347d08fc23564b82737dc"
and its parent commit.
diff = dataset_client.get_diff(head="3bc35d806e0347d08fc23564b82737dc")
Get Diff on Draft Number#
For example, the following diff records the difference between the draft whose draft number is 1
and its parent commit.
diff = dataset_client.get_diff(head=1)
Diff Object#
The structure of the returning DatasetDiff
looks like:
dataset_diff
├── segment_diff
│ ├── action
│ │ └── <str>
│ ├── data_diff
│ │ ├── file_diff
│ │ │ └── action
│ │ │ └── <str>
│ │ └── label_diff
│ │ └── action
│ │ └── <str>
│ └── ...
├── segment_diff
│ ├── action
│ │ └── <str>
│ ├── data_diff
│ │ ├── file_diff
│ │ │ └── action
│ │ │ └── <str>
│ │ └── label_diff
│ │ └── action
│ │ └── <str>
│ └── ...
└── ...
The DatasetDiff
is a list which is composed of SegmentDiff
recording the changes of the segment. The SegmentDiff
is a lazy-load sequence
which is composed of DataDiff
recording the changes of data.
The attribute “action” represents the status difference of the relative resource. It is an enum which includes:
unmodify
add
delete
modify