Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index: introduce Storage.read_only #491

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading