Repository: activeloopai/Hub
File: deeplake/api/dataset.py (Python)

Code before:
                "verbose": verbose,
            },
        )

        dest = convert_pathlib_to_string_if_needed(dest)

        if isinstance(src, (str, pathlib.Path)):
            src = convert_pathlib_to_string_if_needed(src)
            try:
                src_ds = deeplake.load(
                    src, read_only=True, creds=src_creds, token=token, verbose=False
                )
            except DatasetCorruptError as e:
                raise DatasetCorruptError(
                    "The source dataset is corrupted.",
                    "You can try to fix this by loading the dataset with `reset=True` "
                    "which will attempt to reset uncommitted HEAD changes and load the previous version.",
                    e.__cause__,
                )
        else:
            if not src.index.is_trivial():
                raise TypeError(
                    "Deepcopy is not supported for unmaterialized dataset views, i.e. slices of datasets. Please specify a dataset or a materialized dataset view."
                )

            if not src._is_root():
                raise TypeError(
                    "Deepcopy is not supported for individual groups. Please specify a dataset."
                )

            src_ds = src

        verify_dataset_name(dest)

        src_storage = get_base_storage(src_ds.storage)

        db_engine = parse_runtime_parameters(dest, runtime)["tensor_db"]
        dest_storage, cache_chain = get_storage_and_cache_chain(
            dest,
            db_engine=db_engine,
            creds=dest_creds,
            token=token,
            read_only=False,
            memory_cache_size=DEFAULT_MEMORY_CACHE_SIZE,
            local_cache_size=DEFAULT_LOCAL_CACHE_SIZE,
        )

        if dataset_exists(cache_chain):
            if overwrite:
                cache_chain.clear()
            else:

Review comment (bug):
we can also add a `isinstance(src, Dataset)` check here. A test is failing because a tensor is passed.

Code after:
                "verbose": verbose,
            },
        )

        dest = convert_pathlib_to_string_if_needed(dest)

        if isinstance(src, (str, pathlib.Path)):
            src = convert_pathlib_to_string_if_needed(src)
            try:
                src_ds = deeplake.load(
                    src, read_only=True, creds=src_creds, token=token, verbose=False
                )
            except DatasetCorruptError as e:
                raise DatasetCorruptError(
                    "The source dataset is corrupted.",
                    "You can try to fix this by loading the dataset with `reset=True` "
                    "which will attempt to reset uncommitted HEAD changes and load the previous version.",
                    e.__cause__,
                )
        else:
            if not isinstance(src, Dataset):
                raise TypeError(
                    f"The specified ``src`` is not an allowed type. Please specify a dataset or a materialized dataset view."
                )

            if not src.index.is_trivial():
                raise TypeError(
                    "Deepcopy is not supported for unmaterialized dataset views, i.e. slices of datasets. Please specify a dataset or a materialized dataset view."
                )

            if not src._is_root():
                raise TypeError(
                    "Deepcopy is not supported for individual groups. Please specify a dataset."
                )

            src_ds = src

        verify_dataset_name(dest)

        src_storage = get_base_storage(src_ds.storage)

        db_engine = parse_runtime_parameters(dest, runtime)["tensor_db"]
        dest_storage, cache_chain = get_storage_and_cache_chain(
            dest,
            db_engine=db_engine,
            creds=dest_creds,
            token=token,
            read_only=False,
            memory_cache_size=DEFAULT_MEMORY_CACHE_SIZE,
            local_cache_size=DEFAULT_LOCAL_CACHE_SIZE,
        )