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

Set readonly=True by default on platform #1583

Merged
merged 3 commits into from
Apr 7, 2022
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
10 changes: 7 additions & 3 deletions hub/api/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
from hub.client.client import HubBackendClient
from hub.client.log import logger
from hub.core.dataset import Dataset, dataset_factory
from hub.constants import DEFAULT_MEMORY_CACHE_SIZE, DEFAULT_LOCAL_CACHE_SIZE
from hub.constants import (
DEFAULT_MEMORY_CACHE_SIZE,
DEFAULT_LOCAL_CACHE_SIZE,
DEFAULT_READONLY,
)
from hub.util.auto import get_most_common_extension
from hub.util.bugout_reporter import feature_report_path, hub_reporter
from hub.util.delete_entry import remove_path_from_backend
Expand All @@ -32,7 +36,7 @@ class dataset:
@staticmethod
def init(
path: str,
read_only: bool = False,
read_only: bool = DEFAULT_READONLY,
overwrite: bool = False,
public: bool = False,
memory_cache_size: int = DEFAULT_MEMORY_CACHE_SIZE,
Expand Down Expand Up @@ -209,7 +213,7 @@ def empty(
@staticmethod
def load(
path: str,
read_only: bool = False,
read_only: bool = DEFAULT_READONLY,
memory_cache_size: int = DEFAULT_MEMORY_CACHE_SIZE,
local_cache_size: int = DEFAULT_LOCAL_CACHE_SIZE,
creds: Optional[dict] = None,
Expand Down
4 changes: 4 additions & 0 deletions hub/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,7 @@
_NO_LINK_UPDATE = "___!@#_no_link_update_###"

SAMPLE_INFO_TENSOR_MAX_CHUNK_SIZE = 4 * MB

DEFAULT_READONLY = (
os.environ.get("HUB_DEFAULT_READONLY", "false").strip().lower() == "true"
)
5 changes: 3 additions & 2 deletions hub/core/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
import numpy as np
from hub.api.info import load_info
from hub.client.log import logger
from hub.constants import FIRST_COMMIT_ID
from hub.constants import (
FIRST_COMMIT_ID,
DEFAULT_MEMORY_CACHE_SIZE,
DEFAULT_LOCAL_CACHE_SIZE,
MB,
SAMPLE_INFO_TENSOR_MAX_CHUNK_SIZE,
DEFAULT_READONLY,
)
from hub.core.fast_forwarding import ffw_dataset_meta
from hub.core.index import Index
Expand Down Expand Up @@ -113,7 +114,7 @@ def __init__(
storage: LRUCache,
index: Optional[Index] = None,
group_index: str = "",
read_only: bool = False,
read_only: bool = DEFAULT_READONLY,
public: Optional[bool] = False,
token: Optional[str] = None,
verbose: bool = True,
Expand Down