internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: activeloopai/deeplake

Issue:
[FEATURE]Do not overwrite python logging configuration
## 🚨🚨 Feature Request

Be able to use both `logging` and `hub` in the same python script

### Current behavior

I found the following code has undesired behavior: when adding the line `import hub`, the logging configuration will be overwritten.

```python
import logging
import hub     # this will overwrite the logging config

logging.basicConfig(filename = "sample.log", level = logging.DEBUG,
                    format = '%(asctime)s: %(filename)s: %(levelname)s: %(message)s')

logger = logging.getLogger(__name__)

logger.debug("this is a debug message")
logger.info("this is an info message")
logger.warning("this is a warning message")
logger.error("this is an error message")

```






Discussion:

Resolving patch:
diff --git a/hub/client/log.py b/hub/client/log.py
--- a/hub/client/log.py
+++ b/hub/client/log.py
@@ -12,7 +12,17 @@
 
 def configure_logger(debug=0):
     log_level = logging.DEBUG if debug == 1 else logging.INFO
-    logging.basicConfig(format="%(message)s", level=log_level, stream=sys.stdout)
+    logger.setLevel(log_level)
+
+    stream_handler = logging.StreamHandler(stream=sys.stdout)
+    stream_handler.setLevel(log_level)
+
+    formatter = logging.Formatter("%(message)s")
+
+    stream_handler.setFormatter(formatter)
+
+    logger.addHandler(stream_handler)
+    logger.propagate = False
 
 
 configure_logger(0)


Test patch:
Repository: activeloopai/deeplake

Issue:
[BUG]
## 🐛🐛 Bug Report


### ⚗️ Current Behavior
Commiting metadata changes alone fails

**Input Code**

```python
db = hub.empty("/tmp/hubbug", overwrite=True)
db.create_tensor('image', 'image', sample_compression='jpeg')
db.info['tst'] = 42
db.commit()
db.info['tst'] += 1
# db.append(dict(image=np.zeros((16,16), np.uint8)))
db.commit()
```

The code above raises hub.util.exceptions.TensorDoesNotExistError: "Tensor 'has_head_changes' does not exist.". But if the append line is uncommented it works as expected.

**Expected behavior/code**
No exception raies and a new commit with only metadata changes made.

### ⚙️ Environment

- `Python` version(s): 3.9.2
- `OS`: Debian GNU/Linux 11 (bullseye) 
- `IDE`: None
- `Packages`: [ `hub==2.5.2`]




Discussion:

Resolving patch:
diff --git a/hub/util/version_control.py b/hub/util/version_control.py
--- a/hub/util/version_control.py
+++ b/hub/util/version_control.py
@@ -484,7 +484,7 @@ def current_commit_has_info_modified(
     try:
         dataset_diff_key = get_dataset_diff_key(commit_id)
         dataset_diff = storage.get_hub_object(dataset_diff_key, DatasetDiff)
-        if dataset_diff.info_modified:
+        if dataset_diff.info_updated:
             return True
     except KeyError:
         pass
@@ -493,7 +493,7 @@ def current_commit_has_info_modified(
         try:
             tensor_diff_key = get_tensor_commit_diff_key(tensor, commit_id)
             tensor_diff = storage.get_hub_object(tensor_diff_key, CommitDiff)
-            if tensor_diff.info_modified:
+            if tensor_diff.info_updated:
                 return True
         except KeyError:
             pass


Test patch:
diff --git a/hub/api/tests/test_info.py b/hub/api/tests/test_info.py
--- a/hub/api/tests/test_info.py
+++ b/hub/api/tests/test_info.py
@@ -248,3 +248,9 @@ def test_info_persistence_bug(local_ds_generator):
 
     ds = local_ds_generator()
     assert ds.xyz.info.abc == 123
+
+
+def test_info_has_head_changes_bug(local_ds):
+    with local_ds as ds:
+        ds.info["tst"] = 42
+    assert ds.has_head_changes == True
Repository: activeloopai/deeplake

Issue:
[BUG] Can't write objects to JSON
v3.0.14

```python
import pickle
t = ds.create_tensor(f"t/group/f", htype="json", chunk_compression="lz4")
t.append(pickle.dumps("test"))  # pass any pickled object into append gets error
```

```
ValueError: Circular reference detected
```

passing strings and such into this tensor works fine, but for some reason any pickled object or python object that gets pickled gives the above ValueError.


Discussion:
disabling chunk compression doesn't help. 
same issue persists in 3.0.15
@nollied thanks for noting the issue! we also observed issues writing under `lz4` compression. Let us take a deeper look at it and get back when this gets fixed. 
@davidbuniat its actually not due to lz4, this bug happens for all pickle objects even without compression (unless it always defaults to lz4 even when not specified)

Resolving patch:
diff --git a/deeplake/util/json.py b/deeplake/util/json.py
--- a/deeplake/util/json.py
+++ b/deeplake/util/json.py
@@ -201,6 +201,12 @@ def default(self, obj):
                 }
             else:
                 return self.default(obj.array)
+        elif isinstance(obj, bytes):
+            return {
+                "_hub_custom_type": "bytes",
+                "data": base64.b64encode(obj).decode(),
+            }
+
         return obj
 
 
@@ -218,4 +224,6 @@ def object_hook(self, obj):
             return Sample(
                 buffer=base64.b64decode(obj["data"]), compression=obj["compression"]
             )
+        elif hub_custom_type == "bytes":
+            return base64.b64decode(obj["data"])
         return obj


Test patch:
diff --git a/deeplake/api/tests/test_json.py b/deeplake/api/tests/test_json.py
--- a/deeplake/api/tests/test_json.py
+++ b/deeplake/api/tests/test_json.py
@@ -69,6 +69,33 @@ def test_json_with_deeplake_sample(memory_ds, compressed_image_paths):
         assert ds.json[i].data()["value"] == items[i % 2]
 
 
+def test_json_with_bytes(memory_ds):
+    ds = memory_ds
+    ds.create_tensor("json", htype="json")
+    items = [
+        [
+            {
+                "x": [1, 2, 3],
+                "y": [4, [5, 6, b"abc"]],
+            },
+            [[b"abc"]],
+            [None, 0.1],
+        ],
+        [
+            [],
+            [[[b"abc"]]],
+            {"a": [0.1, 1, "a", b"abc"]},
+        ],
+    ]
+    with ds:
+        for x in items:
+            ds.json.append(x)
+        ds.json.extend(items)
+    assert ds.json.shape == (4, 1)
+    for i in range(4):
+        assert ds.json[i].data()["value"] == items[i % 2]
+
+
 def test_json_list_basic(memory_ds):
     ds = memory_ds
     ds.create_tensor("list", htype="list")
Repository: activeloopai/deeplake

Issue:
[FEATURE] Add license in PyPI packages
## 🚨🚨 Feature Request

- [x] A new implementation (Improvement) 

### Is your feature request related to a problem?

deeplake, hub and libdeeplake currently use [Mozilla Public License](https://www.mozilla.org/en-US/MPL/) (MPL). However they do not advertise their license in their respective PyPI packages. This makes automatic license checks (`liccheck`) fail. 

### Description of the possible solution

Add license and license classifiers in `setup.cfg` for hub, deeplake and libdeeplake.
Syntax:
> setup.cfg
```
[metadata]
license = MPL 2.0
license_file = LICENSE
classifiers = 
	License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
```

References:
- https://setuptools.pypa.io/en/latest/deprecated/distutils/setupscript.html#additional-meta-data
- https://pypi.org/classifiers/
- https://github.com/SethMMorton/natsort/blob/master/setup.cfg


Discussion:
Hey there @lucasmaheo, thank you for bringing this to our attention! We'll add this to our roadmap and let you know when it will be implemented. 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -103,6 +103,10 @@ def libdeeplake_availabe():
         "Documentation": "https://docs.activeloop.ai/",
         "Source": "https://github.com/activeloopai/deeplake",
     },
+    "license": "MPL-2.0",
+    "classifiers": [
+        "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
+    ],
 }
 
 setup(**config)


Test patch:
Repository: activeloopai/deeplake

Issue:
[BUG] type of hash_id is never checked
## 🐛🐛 Bug Report


### ⚗️ Current Behavior
A clear and concise description of the behavior.

**Input Code**
```python
import deeplake
# load dataset
ds = deeplake.load("hub://activeloop/mnist-train")
# filter dataset
zeros = ds.filter("labels == 0")
# save view
zeros.save_view(id=10)
# fails only here: load_view
zeros = ds.load_view(id=10)
```

```python
def _get_view_info()
```

**Expected behavior/code**
type check during save.


### ⚙️ Environment

- `deeplake==3.2.17`

### 🧰 Possible Solution  (optional)
PR



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
@@ -2872,11 +2872,14 @@ def save_view(
         Raises:
             ReadOnlyModeError: When attempting to save a view inplace and the user doesn't have write access.
             DatasetViewSavingError: If HEAD node has uncommitted changes.
+            TypeError: If ``id`` is not of type ``str``.
 
         Note:
             Specifying ``path`` makes the view external. External views cannot be accessed using the parent dataset's :func:`Dataset.get_view`,
             :func:`Dataset.load_view`, :func:`Dataset.delete_view` methods. They have to be loaded using :func:`deeplake.load`.
         """
+        if id is not None and not isinstance(id, str):
+            raise TypeError(f"id {id} is of type {type(id)}, expected `str`.")
         return self._save_view(
             path,
             id,


Test patch:
Repository: wagtail/wagtail

Issue:
"Your most recent edits" shows same page multiple times
On the dashboard the "Your most recent edits" can show the same page multiple times if you've edited that single page a lot. For this UI feature to be beneficial it should show only the most recent edit for a page, allowing other pages to appear in the list too.



Discussion:

Resolving patch:
diff --git a/wagtail/wagtailadmin/views/home.py b/wagtail/wagtailadmin/views/home.py
--- a/wagtail/wagtailadmin/views/home.py
+++ b/wagtail/wagtailadmin/views/home.py
@@ -51,8 +51,13 @@ class RecentEditsPanel(object):
     def __init__(self, request):
         self.request = request
         # Last n edited pages
-        self.last_edits = PageRevision.objects.filter(user=request.user).order_by('-created_at')[:5]
-
+        self.last_edits = PageRevision.objects.raw(
+            """
+            select wp.* FROM
+                wagtailcore_pagerevision wp JOIN (
+                    SELECT max(created_at) as max_created_at, page_id FROM wagtailcore_pagerevision group by page_id 
+                ) as max_rev on max_rev.max_created_at = wp.created_at and wp.user_id = %s order by wp.created_at desc
+            """, [request.user.id])[:5]
     def render(self):
         return render_to_string('wagtailadmin/home/recent_edits.html', {
             'last_edits': self.last_edits,
diff --git a/wagtail/wagtailembeds/views/chooser.py b/wagtail/wagtailembeds/views/chooser.py
--- a/wagtail/wagtailembeds/views/chooser.py
+++ b/wagtail/wagtailembeds/views/chooser.py
@@ -25,7 +25,6 @@ def chooser_upload(request):
             error = None
             try:
                 embed_html = embed_to_editor_html(form.cleaned_data['url'])
-                print embed_html
                 return render_modal_workflow(
                     request, None, 'wagtailembeds/chooser/embed_chosen.js',
                     {'embed_html': embed_html}


Test patch:
Repository: wagtail/wagtail

Issue:
Inactive users still receiving moderation notification emails
User with role administrator is made inactive, but they continue to receive moderation notifications by email.

Expected behaviour: If user is inactive they should receive no notifications regardless of their role.



Discussion:

Resolving patch:
diff --git a/wagtail/wagtailadmin/tasks.py b/wagtail/wagtailadmin/tasks.py
--- a/wagtail/wagtailadmin/tasks.py
+++ b/wagtail/wagtailadmin/tasks.py
@@ -41,7 +41,7 @@ def users_with_page_permission(page, permission_type, include_superusers=True):
     if include_superusers:
         q |= Q(is_superuser=True)
 
-    return User.objects.filter(q).distinct()
+    return User.objects.filter(is_active=True).filter(q).distinct()
 
 
 @task


Test patch:
Repository: wagtail/wagtail

Issue:
'AnonymousUser' object has no attribute 'has_usable_password'
Visiting http://localhost:8000/admin/account/ as not logged in user gives the AttributeError above...

Traceback;

``` Environment:


Request Method: GET
Request URL: http://localhost:8000/admin/account/

Django Version: 1.6.2
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'south',
 'compressor',
 'taggit',
 'modelcluster',
 'django.contrib.admin',
 'wagtail.wagtailcore',
 'wagtail.wagtailadmin',
 'wagtail.wagtaildocs',
 'wagtail.wagtailsnippets',
 'wagtail.wagtailusers',
 'wagtail.wagtailimages',
 'wagtail.wagtailembeds',
 'wagtail.wagtailsearch',
 'wagtail.wagtailredirects')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'wagtail.wagtailcore.middleware.SiteMiddleware',
 'wagtail.wagtailredirects.middleware.RedirectMiddleware')


Traceback:
File "C:\Users\drager\developing\django-env\lib\site-packages\django\core\handlers\base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "c:\users\drager\developing\django-env\src\wagtail\wagtail\wagtailadmin\views\account.py" in account
  9.         'show_change_password': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True) and request.user.has_usable_password(),
File "C:\Users\drager\developing\django-env\lib\site-packages\django\utils\functional.py" in inner
  214.         return func(self._wrapped, *args)

Exception Type: AttributeError at /admin/account/
Exception Value: 'AnonymousUser' object has no attribute 'has_usable_password'
```



Discussion:

Resolving patch:
diff --git a/wagtail/wagtailadmin/views/account.py b/wagtail/wagtailadmin/views/account.py
--- a/wagtail/wagtailadmin/views/account.py
+++ b/wagtail/wagtailadmin/views/account.py
@@ -2,14 +2,17 @@
 from django.shortcuts import render, redirect
 from django.contrib import messages
 from django.contrib.auth.forms import SetPasswordForm
+from django.contrib.auth.decorators import permission_required
 from django.utils.translation import ugettext as _ 
 
+@permission_required('wagtailadmin.access_admin')
 def account(request):
     return render(request, 'wagtailadmin/account/account.html', {
         'show_change_password': getattr(settings, 'WAGTAIL_PASSWORD_MANAGEMENT_ENABLED', True) and request.user.has_usable_password(),
     })
 
 
+@permission_required('wagtailadmin.access_admin')
 def change_password(request):
     can_change_password = request.user.has_usable_password()
 


Test patch:
Repository: wagtail/wagtail

Issue:
Image upload: triggering validation error causes search input to disappear
Steps to reproduce:

1) Edit a page that contains an image.
2) Under the image section, click 'Choose Another Image'.
3) Click the 'Upload' tab.
4) Click the 'Upload' button without entering anything into the form fields. This should result in 'This field is required' messages being displayed.
5) Click the 'Search' tab.
-> 'Search term' input field is not visible



Discussion:

Resolving patch:
diff --git a/wagtail/wagtailimages/views/chooser.py b/wagtail/wagtailimages/views/chooser.py
--- a/wagtail/wagtailimages/views/chooser.py
+++ b/wagtail/wagtailimages/views/chooser.py
@@ -113,6 +113,8 @@ def chooser_upload(request):
     Image = get_image_model()
     ImageForm = get_image_form()
 
+    searchform = SearchForm()
+
     if request.POST:
         image = Image(uploaded_by_user=request.user)
         form = ImageForm(request.POST, request.FILES, instance=image)
@@ -138,7 +140,7 @@ def chooser_upload(request):
 
     return render_modal_workflow(
         request, 'wagtailimages/chooser/chooser.html', 'wagtailimages/chooser/chooser.js',
-        {'images': images, 'uploadform': form}
+        {'images': images, 'uploadform': form, 'searchform': searchform}
     )
 
 


Test patch:
Repository: wagtail/wagtail

Issue:
Related Links validation error
1. Start to create new page
2. Click "+" on related links
3. Delete empty related link
4. Fill all fields except one that is required (for a page)
5. Save as Draft

Now validation is saying that there are two errors (omitted field and empty related link)
When fixed ommited field error and deleteing related field the saving is successful.



Discussion:
Thanks, @utek, we'll investigate.

Related issue:

1) Edit a page that already has related links.
2) Delete a related link.
3) Delete the contents of a required field to cause a validation failure.
4) Save as draft.
-> Deleted related link reappears
5) Re-enter text into required field to  cause successful validation
6) Save as draft.
-> Related link has now been deleted.


Resolving patch:
diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py
--- a/wagtail/wagtailadmin/views/pages.py
+++ b/wagtail/wagtailadmin/views/pages.py
@@ -5,7 +5,7 @@
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.auth.decorators import permission_required
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
-from django.utils.translation import ugettext as _ 
+from django.utils.translation import ugettext as _
 from django.views.decorators.vary import vary_on_headers
 
 from wagtail.wagtailadmin.edit_handlers import TabbedInterface, ObjectList


Test patch:
Repository: wagtail/wagtail

Issue:
page.get_parent/ancestors/siblings not available when page is being previewed on create
On a project, we are using page.get_ancestors to find the current site homepage (which can exist at any level of the tree) to get the styling for each page.

This becomes a problem when we preview on create as the page doesn't exist in the tree yet.

I'm wondering if this is worth solving in wagtail itself. I think it will be quite common for people to use ancestor pages for styling.

We know whereabouts the page will exist in the tree when it is created so maybe we could solve this by just setting the path/depth attributes on the page object when we run the preview.



Discussion:

Resolving patch:
diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py
--- a/wagtail/wagtailadmin/views/pages.py
+++ b/wagtail/wagtailadmin/views/pages.py
@@ -364,6 +364,10 @@ def preview_on_create(request, content_type_app_name, content_type_model_name, p
         parent_page = get_object_or_404(Page, id=parent_page_id).specific
         page.set_url_path(parent_page)
 
+        # Set treebeard attributes
+        page.depth = parent_page.depth + 1
+        page.path = Page._get_children_path_interval(parent_page.path)[1]
+
         # This view will generally be invoked as an AJAX request; as such, in the case of
         # an error Django will return a plaintext response. This isn't what we want, since
         # we will be writing the response back to an HTML page regardless of success or


Test patch:
diff --git a/wagtail/wagtailadmin/tests/test_pages_views.py b/wagtail/wagtailadmin/tests/test_pages_views.py
--- a/wagtail/wagtailadmin/tests/test_pages_views.py
+++ b/wagtail/wagtailadmin/tests/test_pages_views.py
@@ -188,6 +188,11 @@ def test_preview_on_create(self):
         self.assertTemplateUsed(response, 'tests/simple_page.html')
         self.assertContains(response, "New page!")
 
+        # Check that the treebeard attributes were set correctly on the page object
+        self.assertEqual(response.context['self'].depth, self.root_page.depth + 1)
+        self.assertTrue(response.context['self'].path.startswith(self.root_page.path))
+        self.assertEqual(response.context['self'].get_parent(), self.root_page)
+
 
 class TestPageEdit(TestCase, WagtailTestUtils):
     def setUp(self):
Repository: wagtail/wagtail

Issue:
DOM ordering of child objects in page editor is lost on validation error
If child objects within the page editor are reordered, and then a validation error occurs when the page is saved, the form is reshown with inline objects rendered in their original (saved) ordering.



Discussion:

Resolving patch:
diff --git a/wagtail/wagtailadmin/edit_handlers.py b/wagtail/wagtailadmin/edit_handlers.py
--- a/wagtail/wagtailadmin/edit_handlers.py
+++ b/wagtail/wagtailadmin/edit_handlers.py
@@ -562,6 +562,11 @@ def __init__(self, instance=None, form=None):
                 child_edit_handler_class(instance=subform.instance, form=subform)
             )
 
+        # if this formset is valid, it may have been re-ordered; respect that
+        # in case the parent form errored and we need to re-render
+        if self.formset.can_order and self.formset.is_valid():
+            self.children = sorted(self.children, key=lambda x: x.form.cleaned_data['ORDER'])
+
         empty_form = self.formset.empty_form
         empty_form.fields['DELETE'].widget = forms.HiddenInput()
         if self.formset.can_order:


Test patch: