Skip to content

Commit

Permalink
Add env var to disable cache
Browse files Browse the repository at this point in the history
  • Loading branch information
sir-sigurd committed Mar 5, 2021
1 parent 99ece37 commit 059132b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
17 changes: 11 additions & 6 deletions api/python/quilt3/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import jsonlines
from tqdm import tqdm

from . import workflows
from . import util, workflows
from .backends import get_package_registry
from .data_transfer import (
calculate_sha256,
Expand Down Expand Up @@ -499,10 +499,11 @@ def install(cls, name, registry=None, top_hash=None, dest=None, dest_registry=No
# Copy the datafiles in the package.
physical_key = entry.physical_key

# Try a local cache.
cached_file = ObjectPathCache.get(str(physical_key))
if cached_file is not None:
physical_key = PhysicalKey.from_path(cached_file)
if util.IS_CACHE_ENABLED:
# Try a local cache.
cached_file = ObjectPathCache.get(str(physical_key))
if cached_file is not None:
physical_key = PhysicalKey.from_path(cached_file)

new_physical_key = dest_parsed.join(logical_key)
if physical_key != new_physical_key:
Expand All @@ -512,7 +513,11 @@ def _maybe_add_to_cache(old: PhysicalKey, new: PhysicalKey, _):
if not old.is_local() and new.is_local():
ObjectPathCache.set(str(old), new.path)

copy_file_list(file_list, callback=_maybe_add_to_cache, message="Copying objects")
copy_file_list(
file_list,
callback=_maybe_add_to_cache if util.IS_CACHE_ENABLED else None,
message="Copying objects",
)

pkg._build(name, registry=dest_registry, message=message)
if top_hash is None:
Expand Down
9 changes: 8 additions & 1 deletion api/python/quilt3/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
import yaml
from appdirs import user_cache_dir, user_data_dir


def get_bool_from_env(var_name: str):
return os.getenv(var_name, '').lower() == 'true'


APP_NAME = "Quilt"
APP_AUTHOR = "QuiltData"
BASE_DIR = user_data_dir(APP_NAME, APP_AUTHOR)
Expand All @@ -30,8 +35,10 @@
OPEN_DATA_URL = "https://open.quiltdata.com"

PACKAGE_NAME_FORMAT = r"([\w-]+/[\w-]+)(?:/(.+))?$"
DISABLE_TQDM = os.getenv('QUILT_MINIMIZE_STDOUT', '').lower() == 'true'
DISABLE_TQDM = get_bool_from_env('QUILT_MINIMIZE_STDOUT')
PACKAGE_UPDATE_POLICY = {'incoming', 'existing'}
IS_CACHE_ENABLED = not get_bool_from_env('QUILT_DISABLE_CACHE')


# CONFIG_TEMPLATE
# Must contain every permitted config key, as well as their default values (which can be 'null'/None).
Expand Down

0 comments on commit 059132b

Please sign in to comment.