Skip to content

Commit

Permalink
Disable locks progressbar in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nvoxland committed Aug 15, 2023
1 parent 39f238f commit 63dee3c
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 31 deletions.
14 changes: 8 additions & 6 deletions deeplake/api/dataset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os

from deeplake import constants

import deeplake
import pathlib
import posixpath
Expand Down Expand Up @@ -1101,7 +1103,7 @@ def deepcopy(
token=None,
num_workers: int = 0,
scheduler="threaded",
progressbar=True,
progressbar=constants.PROGRESSBAR_ENABLED_DEFAULT,
public: bool = False,
verbose: bool = True,
**kwargs,
Expand Down Expand Up @@ -1402,7 +1404,7 @@ def ingest_coco(
src_creds: Optional[Union[str, Dict]] = None,
dest_creds: Optional[Union[str, Dict]] = None,
inspect_limit: int = 1000000,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
shuffle: bool = False,
num_workers: int = 0,
token: Optional[str] = None,
Expand Down Expand Up @@ -1524,7 +1526,7 @@ def ingest_yolo(
dest_creds: Optional[Union[str, Dict]] = None,
image_creds_key: Optional[str] = None,
inspect_limit: int = 1000,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
shuffle: bool = False,
num_workers: int = 0,
token: Optional[str] = None,
Expand Down Expand Up @@ -1648,7 +1650,7 @@ def ingest_classification(
image_params: Optional[Dict] = None,
label_params: Optional[Dict] = None,
dest_creds: Optional[Union[str, Dict]] = None,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
summary: bool = True,
num_workers: int = 0,
shuffle: bool = True,
Expand Down Expand Up @@ -1805,7 +1807,7 @@ def ingest_kaggle(
images_compression: str = "auto",
dest_creds: Optional[Union[str, Dict]] = None,
kaggle_credentials: Optional[dict] = None,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
summary: bool = True,
shuffle: bool = True,
**dataset_kwargs,
Expand Down Expand Up @@ -1885,7 +1887,7 @@ def ingest_dataframe(
src_creds: Optional[Union[str, Dict]] = None,
dest_creds: Optional[Union[str, Dict]] = None,
creds_key: Optional[Dict] = None,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
token: Optional[str] = None,
connect_kwargs: Optional[Dict] = None,
**dataset_kwargs,
Expand Down
4 changes: 2 additions & 2 deletions deeplake/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def test_dataset_rename(ds_generator, path, hub_token, convert_to_pathlib):
indirect=True,
)
@pytest.mark.parametrize("num_workers", [2])
@pytest.mark.parametrize("progressbar", [True])
@pytest.mark.parametrize("progressbar", [False])
def test_dataset_deepcopy(path, hub_token, num_workers, progressbar):
src_path = "_".join((path, "src1"))
dest_path = "_".join((path, "dest1"))
Expand Down Expand Up @@ -1877,7 +1877,7 @@ def test_hidden_tensors(local_ds_generator):


@pytest.mark.parametrize("num_workers", [0, 2])
@pytest.mark.parametrize("progressbar", [True, False])
@pytest.mark.parametrize("progressbar", [False])
@pytest.mark.parametrize(
"index", [slice(None), slice(5, None, None), slice(None, 8, 2), 7]
)
Expand Down
6 changes: 4 additions & 2 deletions deeplake/auto/structured/dataframe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from .base import StructuredDataset
from deeplake import Dataset
from deeplake import Dataset, constants
from deeplake import read, link
from deeplake.htype import HTYPE_SUPPORTED_COMPRESSIONS
from deeplake.util.exceptions import IngestionError
Expand Down Expand Up @@ -146,7 +146,9 @@ def _get_extend_values(self, tensor_params: dict, key: str): # type: ignore

return extend_values

def fill_dataset(self, ds: Dataset, progressbar: bool = True) -> Dataset:
def fill_dataset(
self, ds: Dataset, progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT
) -> Dataset:
"""Fill dataset with data from the dataframe - one tensor per column
Args:
Expand Down
7 changes: 6 additions & 1 deletion deeplake/auto/unstructured/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from abc import ABC, abstractmethod

from deeplake import constants

from deeplake.util.path import find_root
from pathlib import Path

Expand All @@ -14,5 +17,7 @@ def __init__(self, source: str):
"""

@abstractmethod
def structure(ds, progressbar: bool = True, **kwargs):
def structure(
ds, progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT, **kwargs
):
pass
3 changes: 2 additions & 1 deletion deeplake/auto/unstructured/coco/coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from typing import List, Union, Dict, Optional
from itertools import chain
from deeplake import constants

from deeplake.core.dataset import Dataset
from deeplake.core.tensor import Tensor
Expand Down Expand Up @@ -139,7 +140,7 @@ def prepare_structure(self, inspect_limit: int = 1000000) -> DatasetStructure:
self._structure = structure
return structure

def structure(self, ds: Dataset, progressbar: bool = True, num_workers: int = 0, shuffle: bool = True): # type: ignore
def structure(self, ds: Dataset, progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT, num_workers: int = 0, shuffle: bool = True): # type: ignore
image_files = self.images.supported_images

if shuffle:
Expand Down
4 changes: 3 additions & 1 deletion deeplake/auto/unstructured/image_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import glob
from typing import List, Tuple, Union

from deeplake import constants

from deeplake.util.auto import ingestion_summary
from deeplake.util.exceptions import (
InvalidPathException,
Expand Down Expand Up @@ -92,7 +94,7 @@ def get_class_names(self) -> List[str]:
def structure( # type: ignore
self,
ds: Dataset,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
generate_summary: bool = True,
shuffle: bool = True,
image_tensor_args: dict = {},
Expand Down
11 changes: 9 additions & 2 deletions deeplake/auto/unstructured/yolo/yolo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from deeplake import constants

import deeplake

from pathlib import Path
Expand Down Expand Up @@ -218,7 +220,12 @@ def _add_images_tensor(self, structure: DatasetStructure):
)
)

def _ingest_data(self, ds: Dataset, progressbar: bool = True, num_workers: int = 0):
def _ingest_data(
self,
ds: Dataset,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
num_workers: int = 0,
):
"""Functions appends the the data to the dataset object using deeplake.compute"""

if self.image_creds_key is not None:
Expand Down Expand Up @@ -298,7 +305,7 @@ def append_data_polygon(data, sample_out, tensor_meta: Dict = tensor_meta):
num_workers=num_workers,
)

def structure(self, ds: Dataset, progressbar: bool = True, num_workers: int = 0, shuffle: bool = True): # type: ignore
def structure(self, ds: Dataset, progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT, num_workers: int = 0, shuffle: bool = True): # type: ignore
# Set class names in the dataset
if self.data.class_names:
ds[self.label_params["name"]].info["class_names"] = self.data.class_names
Expand Down
1 change: 1 addition & 0 deletions deeplake/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
PYTEST_ENABLED = os.environ.get("DEEPLAKE_PYTEST_ENABLED", "").lower().strip() == "true"

SPINNER_ENABLED = not PYTEST_ENABLED
PROGRESSBAR_ENABLED_DEFAULT = not PYTEST_ENABLED

LOCK_LOCAL_DATASETS = not PYTEST_ENABLED

Expand Down
8 changes: 5 additions & 3 deletions deeplake/core/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import pathlib
import numpy as np
from time import time, sleep

from deeplake import constants
from tqdm import tqdm # type: ignore

import deeplake
Expand Down Expand Up @@ -2167,7 +2169,7 @@ def filter(
function: Union[Callable, str],
num_workers: int = 0,
scheduler: str = "threaded",
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
save_result: bool = False,
result_path: Optional[str] = None,
result_ds_args: Optional[dict] = None,
Expand Down Expand Up @@ -2874,7 +2876,7 @@ def rechunk(
tensors: Optional[Union[str, List[str]]] = None,
num_workers: int = 0,
scheduler: str = "threaded",
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
):
"""Rewrites the underlying chunks to make their sizes optimal.
This is usually needed in cases where a lot of updates have been made to the data.
Expand Down Expand Up @@ -3752,7 +3754,7 @@ def load_view(
tensors: Optional[List[str]] = None,
num_workers: int = 0,
scheduler: str = "threaded",
progressbar: Optional[bool] = True,
progressbar: Optional[bool] = constants.PROGRESSBAR_ENABLED_DEFAULT,
):
"""Loads the view and returns the :class:`~deeplake.core.dataset.dataset.Dataset` by id. Equivalent to ds.get_view(id).load().
Expand Down
8 changes: 5 additions & 3 deletions deeplake/core/query/filter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from typing import Callable, List, Optional, Sequence, Dict
from uuid import uuid4

from deeplake import constants

import deeplake

from deeplake.core.io import SampleStreaming
Expand Down Expand Up @@ -64,7 +66,7 @@ def filter_dataset(
filter_function: Callable[[deeplake.Dataset], bool],
num_workers: int = 0,
scheduler: str = "threaded",
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
save_result: bool = False,
result_path: Optional[str] = None,
result_ds_args: Optional[dict] = None,
Expand Down Expand Up @@ -155,7 +157,7 @@ def filter_with_compute(
filter_function: Callable,
num_workers: int,
scheduler: str,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
query_text: Optional[str] = None,
vds: Optional[deeplake.Dataset] = None,
) -> List[int]:
Expand Down Expand Up @@ -346,7 +348,7 @@ def query_dataset(
query: str,
num_workers: int = 0,
scheduler: str = "threaded",
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
save_result: bool = False,
result_path: Optional[str] = None,
result_ds_args: Optional[Dict] = None,
Expand Down
4 changes: 2 additions & 2 deletions deeplake/core/query/test/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def test_query_scheduler(local_ds):
f1 = "labels % 2 == 0"
f2 = lambda s: s.labels.numpy() % 2 == 0

view1 = ds.filter(f1, num_workers=2, progressbar=True)
view2 = ds.filter(f2, num_workers=2, progressbar=True)
view1 = ds.filter(f1, num_workers=2)
view2 = ds.filter(f2, num_workers=2)

np.testing.assert_array_equal(view1.labels.numpy(), view2.labels.numpy())

Expand Down
9 changes: 6 additions & 3 deletions deeplake/core/transform/transform.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from uuid import uuid4

from deeplake import constants

import deeplake
from typing import Callable, List, Optional
from itertools import repeat
Expand Down Expand Up @@ -57,7 +60,7 @@ def eval(
ds_out: Optional[deeplake.Dataset] = None,
num_workers: int = 0,
scheduler: str = "threaded",
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
skip_ok: bool = False,
check_lengths: bool = True,
pad_data_in: bool = False,
Expand Down Expand Up @@ -135,7 +138,7 @@ def eval(
ds_out: Optional[deeplake.Dataset] = None,
num_workers: int = 0,
scheduler: str = "threaded",
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
skip_ok: bool = False,
check_lengths: bool = True,
pad_data_in: bool = False,
Expand Down Expand Up @@ -340,7 +343,7 @@ def run(
compute: ComputeProvider,
num_workers: int,
scheduler: str,
progressbar: bool = True,
progressbar: bool = constants.PROGRESSBAR_ENABLED_DEFAULT,
overwrite: bool = False,
skip_ok: bool = False,
read_only: bool = False,
Expand Down
2 changes: 0 additions & 2 deletions deeplake/core/vectorstore/test_deeplake_vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,6 @@ def test_ingestion(local_path, capsys):
vector_store = DeepLakeVectorStore(
path=local_path,
overwrite=True,
verbose=True,
)

with pytest.raises(Exception):
Expand Down Expand Up @@ -1210,7 +1209,6 @@ def test_ingestion_images(local_path):
path=local_path,
tensor_params=tensor_params,
overwrite=True,
verbose=True,
)

ids = vector_store.add(image=images, embedding=embeddings, return_ids=True)
Expand Down
5 changes: 4 additions & 1 deletion deeplake/integrations/huggingface/huggingface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pathlib
from typing import Dict, Set

from deeplake import constants

from deeplake.core.dataset import Dataset
import posixpath
import deeplake
Expand Down Expand Up @@ -69,7 +72,7 @@ def _create_tensor_from_feature(key, feature, src, ds):
def ingest_huggingface(
src,
dest,
use_progressbar=True,
use_progressbar=constants.PROGRESSBAR_ENABLED_DEFAULT,
token: Optional[str] = None,
connect_kwargs: Optional[Dict] = None,
**dataset_kwargs,
Expand Down
Loading

0 comments on commit 63dee3c

Please sign in to comment.