Skip to content

Commit

Permalink
index: introduce Storage.read_only
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Dec 28, 2023
1 parent 0f79e6e commit c7ad6f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dvc_data/index/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def collect( # noqa: C901, PLR0912
cache = storage_info.cache if storage != "cache" else None
remote = storage_info.remote if storage != "remote" else None

if not data:
if not data or (push and data.read_only):
continue

try:
Expand Down
9 changes: 6 additions & 3 deletions src/dvc_data/index/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ def close(self):


class Storage(ABC):
def __init__(self, key: "DataIndexKey"):
def __init__(self, key: "DataIndexKey", read_only: bool = False):
self.key = key
self.read_only = read_only

@property
@abstractmethod
Expand Down Expand Up @@ -176,10 +177,11 @@ def __init__(
key: "DataIndexKey",
odb: "HashFileDB",
index: Optional["DataIndex"] = None,
read_only: bool = False,
):
self.odb = odb
self.index = index
super().__init__(key)
super().__init__(key, read_only=read_only)

@property
def fs(self):
Expand Down Expand Up @@ -235,12 +237,13 @@ def __init__(
path: "str",
index: Optional["DataIndex"] = None,
prefix: Optional["DataIndexKey"] = None,
read_only: bool = False,
):
self._fs = fs
self._path = path
self.index = index
self.prefix = prefix if prefix is not None else key
super().__init__(key)
super().__init__(key, read_only=read_only)

@property
def fs(self):
Expand Down

0 comments on commit c7ad6f2

Please sign in to comment.