Skip to content

Version Control

Version

deeplake.Version

An atomic change within deeplake.Dataset's history

client_timestamp property
client_timestamp: datetime

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.

id property
id: str

The unique version identifier

message property
message: str | None

The description of the version provided at commit time.

open
open() -> ReadOnlyDataset

Fetches the dataset corresponding to the version

timestamp property
timestamp: datetime

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.

__getitem__
__getitem__(offset: int) -> Version
__getitem__(version: str) -> Version
__getitem__(input: int | str) -> Version
__iter__
__iter__() -> Iterator[Version]

Iterate over the history, starting at the initial version

__len__
__len__() -> int

The number of versions within the history

# 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

Describes a branch within the dataset.

Branches are created using deeplake.Dataset.branch.

__hash__ class-attribute
__hash__: None = None
base property
base: tuple[str, str] | None

The base branch id and version

delete
delete() -> None

Deletes the branch from the dataset

id property
id: str

The unique identifier of the branch

name property
name: str

The name of the branch

open
open() -> Dataset

Opens corresponding branch of the dataset

rename
rename(new_name: str) -> None

Renames the branch within the dataset

timestamp property
timestamp: datetime

The branch creation timestamp

# 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.

__str__
__str__() -> str
__getitem__
__getitem__(name: str) -> Branch

Return a branch by name or id

__len__
__len__() -> int

The number of branches in the dataset

names
names() -> list[str]

Return a list of branch names

# 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.

__hash__ class-attribute
__hash__: None = None
base property
base: tuple[str, str] | None

The base branch id and version

id property
id: str

The unique identifier of the branch

name property
name: str

The name of the branch

open
open() -> ReadOnlyDataset

Opens corresponding branch of the dataset

timestamp property
timestamp: datetime

The branch creation timestamp

# 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.

__getitem__
__getitem__(name: str) -> BranchView

Return a branch by name or id

__len__
__len__() -> int

The number of branches in the dataset

names
names() -> list[str]

Return a list of branch names

# 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.

delete
delete() -> None

Deletes the tag from the dataset

id property
id: str

The unique identifier of the tag

name property
name: str

The name of the tag

open
open() -> DatasetView

Fetches the dataset corresponding to the tag

open_async
open_async() -> Future

Asynchronously fetches the dataset corresponding to the tag and returns a Future object.

rename
rename(new_name: str) -> None

Renames the tag within the dataset

version property
version: str

The version that has been tagged

# 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.

__getitem__
__getitem__(name: str) -> Tag

Return a tag by name

__len__
__len__() -> int

The total number of tags in the dataset

names
names() -> list[str]

Return a list of tag names

# 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.

id property
id: str

The unique identifier of the tag

name property
name: str

The name of the tag

open
open() -> DatasetView

Fetches the dataset corresponding to the tag

open_async
open_async() -> Future

Asynchronously fetches the dataset corresponding to the tag and returns a Future object.

version property
version: str

The version that has been tagged

# 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.

__getitem__
__getitem__(name: str) -> TagView

Return a tag by name

__len__
__len__() -> int

The total number of tags in the dataset

names
names() -> list[str]

Return a list of tag names

# Access read-only tags
tags_view = ds.tags

# List tag names
for name in tags_view.names():
    print(f"Found tag: {name}")

# Get specific tag
tag_view = tags_view["v1.0"]