Skip to content

Commit

Permalink
Set readonly=True by default on platform (#1583)
Browse files Browse the repository at this point in the history
  • Loading branch information
farizrahman4u committed Apr 7, 2022
1 parent 1d57e08 commit 8919292
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
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

0 comments on commit 8919292

Please sign in to comment.