Skip to content

Commit

Permalink
resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
huan233usc committed Feb 16, 2024
1 parent 25c0eb0 commit ea69464
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion python/src/space/core/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def add_branch(self, branch: str):
self._storage.add_branch(branch)

def remove_branch(self, branch: str):
"""Remove tag branch a dataset."""
"""Remove branch for a dataset."""
self._storage.remove_branch(branch)

def set_current_branch(self, branch: str):
Expand Down
13 changes: 6 additions & 7 deletions python/src/space/core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
_INIT_SNAPSHOT_ID = 0
# Name for the main branch, by default the read write are using this branch.
_MAIN_BRANCH = "main"
# Sets of reference that could not be added as branches or tags by user.
_RESERVED_REFERENCE = [_MAIN_BRANCH]


Expand Down Expand Up @@ -83,9 +84,9 @@ def __init__(self,
self._physical_schema)

self._primary_keys = set(self._metadata.schema.primary_keys)
self._current_branch = current_branch
self._current_branch = current_branch if current_branch else _MAIN_BRANCH
self._max_snapshot_id = max(
[ref[1].snapshot_id for ref in self._metadata.refs.items()] +
[ref.snapshot_id for ref in self._metadata.refs.values()] +
[self._metadata.current_snapshot_id])

@property
Expand All @@ -96,9 +97,6 @@ def metadata(self) -> meta.StorageMetadata:
@property
def current_branch(self) -> str:
"""Return the current branch."""
if not self._current_branch:
return _MAIN_BRANCH

return self._current_branch

@property
Expand Down Expand Up @@ -241,15 +239,16 @@ def add_branch(self, branch: str) -> None:

def set_current_branch(self, branch: str):
"""Set current branch for the snapshot."""
if branch != "main":
if branch != _MAIN_BRANCH:
snapshot_ref = self.lookup_reference(branch)
if snapshot_ref.type != meta.SnapshotReference.BRANCH:
raise errors.UserInputError("{branch} is not a branch.")

self._current_branch = branch

def _add_reference(self,
ref_name: str,
ref_type: meta.SnapshotReference.ReferenceType.ValueType,
ref_type: meta.SnapshotReference.ReferenceType,
snapshot_id: Optional[int] = None) -> None:
"""Add reference to a snapshot"""
if snapshot_id is None:
Expand Down

0 comments on commit ea69464

Please sign in to comment.