Repository: activeloopai/deeplake

Issue:
[BUG] `create_tensor(exist_ok=True)` breaks for text htypes
### Severity

P0 - Critical breaking issue or missing functionality

### Current Behavior

Creating text tensor twice with exist_ok throws an exception
```
.../deeplake/core/dataset/dataset.py:685), in Dataset.create_tensor(self, name, htype, dtype, sample_compression, chunk_compression, hidden, create_sample_info_tensor, create_shape_tensor, create_id_tensor, verify, exist_ok, verbose, downsampling, tiling_threshold, **kwargs)
    619 """Creates a new tensor in the dataset.
    620 
    621 Examples:
   (...)
    671     ValueError: If an illegal argument is specified.
    672 """
    674 deeplake_reporter.feature_report(
    675     feature_name="create_tensor",
    676     parameters={
...
    746         )
    747     return tensor
    748 elif name in self.version_state["full_tensors"]:

ValueError: Tensor f142c364-03bb-4e2a-8fed-368a7ffb00b6 already exists with different configuration. Current config: {'htype': 'text', 'dtype': 'str', 'sample_compression': 'unspecified', 'chunk_compression': 'unspecified', 'hidden': False, 'is_link': False, 'is_sequence': False}. New config: {'htype': 'text', 'dtype': 'unspecified', 'sample_compression': 'unspecified', 'chunk_compression': 'unspecified', 'hidden': False, 'is_link': False, 'is_sequence': False}
111

### Steps to Reproduce

```python
import deeplake 
import uuid

deeplake_path = 'hub://new/dataset/path' 

ds: deeplake.Dataset = deeplake.dataset(deeplake_path)
name = str(uuid.uuid4())
ds.create_tensor(name, htype="text", exist_ok=True)
ds.create_tensor(name, htype="text", exist_ok=True)
```

### Expected/Desired Behavior

No exceptions

### Python Version

_No response_

### OS

_No response_

### IDE

_No response_

### Packages

_No response_

### Additional Context

_No response_

### Possible Solution

_No response_

### Are you willing to submit a PR?

- [ ] I'm willing to submit a PR (Thank you!)


Discussion:

Resolving patch:
diff --git a/deeplake/core/dataset/dataset.py b/deeplake/core/dataset/dataset.py
--- a/deeplake/core/dataset/dataset.py
+++ b/deeplake/core/dataset/dataset.py
@@ -67,6 +67,7 @@
     UNSPECIFIED,
     verify_htype_key_value,
 )
+from deeplake.compression import COMPRESSION_ALIASES
 from deeplake.integrations import dataset_to_tensorflow
 from deeplake.util.bugout_reporter import deeplake_reporter, feature_report_path
 from deeplake.util.dataset import try_flushing
@@ -736,12 +737,20 @@ def _create_tensor(
             new_config = {
                 "htype": htype,
                 "dtype": dtype,
-                "sample_compression": sample_compression,
-                "chunk_compression": chunk_compression,
+                "sample_compression": COMPRESSION_ALIASES.get(
+                    sample_compression, sample_compression
+                ),
+                "chunk_compression": COMPRESSION_ALIASES.get(
+                    chunk_compression, chunk_compression
+                ),
                 "hidden": hidden,
                 "is_link": is_link,
                 "is_sequence": is_sequence,
             }
+            base_config = HTYPE_CONFIGURATIONS.get(htype, {}).copy()
+            for key in new_config:
+                if new_config[key] == UNSPECIFIED:
+                    new_config[key] = base_config.get(key) or UNSPECIFIED
             if current_config != new_config:
                 raise ValueError(
                     f"Tensor {name} already exists with different configuration. "


Test patch:
diff --git a/.github/langchain-tests/test_activeloop_deeplake.py b/.github/langchain-tests/test_activeloop_deeplake.py
--- a/.github/langchain-tests/test_activeloop_deeplake.py
+++ b/.github/langchain-tests/test_activeloop_deeplake.py
@@ -101,10 +101,7 @@ def test():
 
     embedding = OpenAIEmbeddings()
     db = DeepLake.from_documents(
-        docs,
-        dataset_path=dataset_path,
-        embedding=embeddings,
-        overwrite=True
+        docs, dataset_path=dataset_path, embedding=embeddings, overwrite=True
     )
 
     db.vectorstore.summary()
diff --git a/deeplake/api/tests/test_api.py b/deeplake/api/tests/test_api.py
--- a/deeplake/api/tests/test_api.py
+++ b/deeplake/api/tests/test_api.py
@@ -1942,6 +1942,36 @@ def test_exist_ok(local_ds):
         ds.create_group("grp", exist_ok=True)
 
 
+def test_exist_ok_htype(local_ds):
+    with local_ds as ds:
+        ds.create_tensor("test1", htype="text")
+        with pytest.raises(TensorAlreadyExistsError):
+            ds.create_tensor("test1")
+        ds.create_tensor("test1", htype="text", exist_ok=True)
+
+        ds.create_tensor("test2", htype="bbox")
+        with pytest.raises(TensorAlreadyExistsError):
+            ds.create_tensor("test2")
+        ds.create_tensor("test2", htype="bbox", exist_ok=True)
+
+        ds.create_tensor("test3", htype="polygon")
+        with pytest.raises(TensorAlreadyExistsError):
+            ds.create_tensor("test3")
+        ds.create_tensor("test3", htype="polygon", exist_ok=True)
+
+        ds.create_tensor("test4", htype="image", sample_compression="jpg")
+        with pytest.raises(TensorAlreadyExistsError):
+            ds.create_tensor("test4")
+        ds.create_tensor(
+            "test4", htype="image", sample_compression="jpg", exist_ok=True
+        )
+
+        ds.create_tensor("test5", htype="class_label")
+        with pytest.raises(TensorAlreadyExistsError):
+            ds.create_tensor("test5")
+        ds.create_tensor("test5", htype="class_label", exist_ok=True)
+
+
 def verify_label_data(ds):
     text_labels = [
         ["airplane"],