Version Control¶
Version¶
deeplake.Version
¶
An atomic change within deeplake.Dataset's history
client_timestamp
property
¶
When the version was created, according to the writer's local clock.
This timestamp is not guaranteed to be accurate, and deeplake.Version.timestamp should generally be used instead.
timestamp
property
¶
The version timestamp.
This is based on the storage provider's clock, and so generally more accurate than deeplake.Version.client_timestamp.
# Get current version
version_id = ds.version
# Access specific version
version = ds.history[version_id]
print(f"Version: {version.id}")
print(f"Message: {version.message}")
print(f"Timestamp: {version.timestamp}")
# Open dataset at specific version
old_ds = version.open()
History¶
deeplake.History
¶
The version history of a deeplake.Dataset.
# View all versions
for version in ds.history:
print(f"Version {version.id}: {version.message}")
print(f"Created: {version.timestamp}")
# Get specific version
version = ds.history[version_id]
# Get version by index
first_version = ds.history[0]
latest_version = ds.history[-1]
Branching¶
Branch¶
deeplake.Branch
¶
# Create branch
ds.branch("Branch1")
# Access branch
branch = ds.branches["Branch1"]
print(f"Branch: {branch.name}")
print(f"Created: {branch.timestamp}")
print(f"Base: {branch.base}")
# Open dataset at tag
branch_ds = branch.open()
# Rename branch
branch.rename("Other Branch")
# Delete branch
branch.delete()
Branches¶
deeplake.Branches
¶
Provides access to the branches within a dataset.
It is returned by the deeplake.Dataset.branches property.
# Create branch
ds.branch("B1")
# List all branches
for name in ds.branches.names():
br = ds.branches[name]
print(f"Branch: {br.name} based on {br.base}")
# Check number of branches
num_branches = len(ds.branches)
# Access specific branch
branch = ds.branches["main"]
# Common operations with branches
branch_ds = ds.branches["B1"].open() # Open branch
# Error handling
try:
branch = ds.branches["non_existent"]
except deeplake.BranchNotFoundError:
print("Branch not found")
BranchView¶
deeplake.BranchView
¶
Describes a read-only branch within the dataset.
# Open read-only dataset
ds = deeplake.open_read_only("s3://bucket/dataset")
# Access branch view
branch_view = ds.branches["B1"]
print(f"Branch: {branch_view.name}")
print(f"Created: {branch_view.timestamp}")
# Open branch view
branch_ds = branch_view.open()
BranchesView¶
deeplake.BranchesView
¶
Provides access to the read-only branches within a dataset view.
It is returned by the deeplake.ReadOnlyDataset.branches property.
# Access read-only branches
branches_view = ds.branches
# List branch names
for name in branches_view.names():
print(f"Found branch: {name}")
# Get specific branch
branch_view = branches_view["B1"]
Tagging¶
Tag¶
deeplake.Tag
¶
Describes a tag within the dataset.
Tags are created using deeplake.Dataset.tag.
open_async
¶
Asynchronously fetches the dataset corresponding to the tag and returns a Future object.
# Create tag
ds.tag("v1.0")
# Access tagged version
tag = ds.tags["v1.0"]
print(f"Tag: {tag.name}")
print(f"Version: {tag.version}")
# Open dataset at tag
tagged_ds = tag.open()
# Rename tag
tag.rename("v1.0.0")
# Delete tag
tag.delete()
Tags¶
deeplake.Tags
¶
Provides access to the tags within a dataset.
It is returned by the deeplake.Dataset.tags property.
# Create tag
ds.tag("v1.0") # Tag current version
specific_version = ds.version
ds.tag("v2.0", version=specific_version) # Tag specific version
# List all tags
for name in ds.tags.names():
tag = ds.tags[name]
print(f"Tag {tag.name} points to version {tag.version}")
# Check number of tags
num_tags = len(ds.tags)
# Access specific tag
tag = ds.tags["v1.0"]
# Common operations with tags
latest_ds = ds.tags["v2.0"].open() # Open dataset at tag
stable_ds = ds.tags["v1.0"].open_async() # Async open
# Error handling
try:
tag = ds.tags["non_existent"]
except deeplake.TagNotFoundError:
print("Tag not found")
TagView¶
deeplake.TagView
¶
Describes a read-only tag within the dataset.
Tags are created using deeplake.Dataset.tag.
open_async
¶
Asynchronously fetches the dataset corresponding to the tag and returns a Future object.
# Open read-only dataset
ds = deeplake.open_read_only("s3://bucket/dataset")
# Access tag view
tag_view = ds.tags["v1.0"]
print(f"Tag: {tag_view.name}")
print(f"Version: {tag_view.version}")
# Open dataset at tag
tagged_ds = tag_view.open()
TagsView¶
deeplake.TagsView
¶
Provides access to the tags within a dataset.
It is returned by the deeplake.Dataset.tags property on a deeplake.ReadOnlyDataset.