-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
181 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright 2021 Graviti. Licensed under MIT License. | ||
# | ||
|
||
# pylint: disable=wrong-import-position | ||
# pylint: disable=wrong-import-order | ||
# pylint: disable=not-callable | ||
# pylint: disable=ungrouped-imports | ||
# pylint: disable=import-error | ||
# pylint: disable=pointless-string-statement | ||
# pylint: disable=invalid-name | ||
|
||
|
||
"""This file includes the python code of diff.rst.""" | ||
|
||
"""Authorize a Dataset Client Instance""" | ||
from tensorbay import GAS | ||
|
||
ACCESS_KEY = "Accesskey-*****" | ||
gas = GAS(ACCESS_KEY) | ||
dataset_client = gas.create_dataset("DatasetName") | ||
dataset_client.create_draft("draft-1") | ||
# Add some data to the dataset. | ||
dataset_client.commit("commit-1", tag="V1") | ||
commit_id_1 = dataset_client.status.commit_id | ||
|
||
dataset_client.create_draft("draft-2") | ||
# Do some modifications to the dataset. | ||
dataset_client.commit("commit-2", tag="V2") | ||
commit_id_2 = dataset_client.status.commit_id | ||
|
||
dataset_client.create_draft("draft-3") | ||
draft_number_3 = dataset_client.status.draft_number | ||
head = "" | ||
|
||
"""""" | ||
|
||
"""Get Diff""" | ||
diff = dataset_client.get_diff(head=head) | ||
"""""" | ||
|
||
"""Get Diff on Commit""" | ||
diff = dataset_client.get_diff(head="3bc35d806e0347d08fc23564b82737dc") | ||
"""""" | ||
|
||
"""Get Diff on Draft""" | ||
diff = dataset_client.get_diff(head=1) | ||
"""""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ tensorbay.client | |
status | ||
struct | ||
version | ||
diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
tensorbay.client.diff | ||
====================== | ||
|
||
.. automodule:: tensorbay.client.diff | ||
:members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
###### | ||
Diff | ||
###### | ||
|
||
TensorBay supports showing changes between commits or drafts. | ||
|
||
Before operating the :ref:`reference/glossary:diff`, a dataset client instance with commits is needed. | ||
See more details in :ref:`version_control/draft_and_commit:Draft and Commit` | ||
|
||
********** | ||
Get Diff | ||
********** | ||
|
||
TensorBay SDK allows getting the dataset :ref:`reference/glossary:diff` | ||
through :ref:`reference/glossary:basehead`. Currently, only obtaining the :ref:`reference/glossary: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. | ||
|
||
.. literalinclude:: ../../../docs/code/diff.py | ||
:language: python | ||
:start-after: """Get Diff""" | ||
:end-before: """""" | ||
|
||
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. | ||
|
||
.. literalinclude:: ../../../docs/code/diff.py | ||
:language: python | ||
:start-after: """Get Diff on Commit""" | ||
:end-before: """""" | ||
|
||
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. | ||
|
||
.. literalinclude:: ../../../docs/code/diff.py | ||
:language: python | ||
:start-after: """Get Diff on Draft""" | ||
:end-before: """""" | ||
|
||
Diff Object | ||
=========== | ||
|
||
The structure of the returning :class:`~tensorbay.client.diff.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 :class:`~tensorbay.client.diff.DatasetDiff` is a list which is composed of :class:`~tensorbay.client.diff.SegmentDiff` | ||
recording the changes of the segment. The :class:`~tensorbay.client.diff.SegmentDiff` is a lazy-load sequence | ||
which is composed of :class:`~tensorbay.client.diff.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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters