internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mathesar-foundation/mathesar

Issue:
Met with empty schemas page after docker-compose upgrade
## Description
* Performed a guided install of 0.1.3
  * It connects a single external user DB with 2 schemas and multiple tables.
* Upgraded to 0.1.4 following the information in the latest docs (from https://github.com/mathesar-foundation/mathesar/pull/3227).
  * Moved Postgres volumes as mentioned in docs.
* Upgrade succeeded.
* Met with the following page:
  <img width="716" alt="Screenshot 2024-01-29 at 7 17 17 PM" src="https://github.com/mathesar-foundation/mathesar/assets/11850603/eca09f3c-8024-4fd9-9b89-5ce2a87beb15">
* I repeated the upgrade twice and this happened both times.
* The database name, host, and port of the user database connection were empty.
  <img width="984" alt="Screenshot 2024-01-29 at 7 18 48 PM" src="https://github.com/mathesar-foundation/mathesar/assets/11850603/eefc7409-fedf-4663-8744-15563a889e03">




Discussion:
@pavish Can you give me a little detail about whether you started with `MATHESAR_DATABASES` (I assume yes), whether you removed it, and when you removed it?
@mathemancer I did not remove it.

* I followed the guided install script which installed Mathesar and set up the `MATHESAR_DATABASES` env variable.
  * I chose 'use existing' instead of 'create new' in the guided install DB prompt, and gave the credentials to an existing database.
* I started Mathesar, it worked fine.
* I then following the upgrade instructions as per the docs, and met with this error.

Resolving patch:
diff --git a/mathesar/migrations/0006_mathesar_databases_to_model.py b/mathesar/migrations/0006_mathesar_databases_to_model.py
new file mode 100644
--- /dev/null
+++ b/mathesar/migrations/0006_mathesar_databases_to_model.py
@@ -0,0 +1,34 @@
+from decouple import config as decouple_config
+from django.conf import settings
+from django.db import migrations
+
+
+def update_conn_info(apps, _):
+    """Add info from MATHESAR_DATABASES to new model fields."""
+    Database = apps.get_model('mathesar', 'Database')
+    django_db_key = decouple_config('DJANGO_DATABASE_KEY', default="default")
+    user_databases = [key for key in settings.DATABASES if key != django_db_key]
+    for database_key in user_databases:
+        try:
+            db = Database.current_objects.get(name=database_key)
+        except Database.DoesNotExist:
+            continue
+        db_info = settings.DATABASES[database_key]
+        if 'postgres' in db_info['ENGINE']:
+            db.name = database_key
+            db.db_name = db_info['NAME']
+            db.username = db_info['USER']
+            db.password = db_info['PASSWORD']
+            db.host = db_info['HOST']
+            db.port = db_info['PORT']
+            db.save()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('mathesar', '0005_release_0_1_4'),
+    ]
+    operations = [
+        migrations.RunPython(update_conn_info),
+    ]


Test patch:
Repository: mathesar-foundation/mathesar

Issue:
Column types not showing within shared tables and explorations
## Steps to reproduce

1. Create a table share
1. View the shared table page
1. Within the column header cells, expect to see type icons alongside the column names.
1. Instead, observe question marks for all columns.
1. Expect to see numbers right-aligned.
1. Instead, see numbers left-aligned (because they are being treated as text).

    ![image](https://github.com/mathesar-foundation/mathesar/assets/42411/e62571db-5f2a-4647-8a66-6bbfa3869e58)




Discussion:
Same root cause as https://github.com/mathesar-foundation/mathesar/issues/3452

Resolving patch:
diff --git a/mathesar/views.py b/mathesar/views.py
--- a/mathesar/views.py
+++ b/mathesar/views.py
@@ -241,7 +241,7 @@ def get_common_data_for_shared_entity(request, schema=None):
     return {
         **get_base_data_all_routes(request, database, schema),
         'schemas': serialized_schemas,
-        'databases': serialized_databases,
+        'connections': serialized_databases,
         'routing_context': 'anonymous',
     }
 


Test patch:
Repository: mathesar-foundation/mathesar

Issue:
CSRF Failed Error
## Description
The error message 
"CSRF Failed: Origin checking failed - https://internal.mathesar.org/ does not match any trusted origins."
is appearing when performing certain actions in Mathesar like creating a new internal db or saving a record. 

## Additional context
This happened while testing internal.mathesar.org


Discussion:
Here is the screenshot of the error for reference: 
<img width="699" alt="Screenshot 2024-03-20 at 2 44 34 PM" src="https://github.com/mathesar-foundation/mathesar/assets/52523023/38f07591-e18d-4ad6-8c37-30bb009a81ae">


For the sake of QA, I've temporarily fixed this by following this [SO](https://stackoverflow.com/a/71482883) answer but this issue will need to be investigated more to pinpoint the actual problem.

Resolving patch:
diff --git a/config/settings/production.py b/config/settings/production.py
--- a/config/settings/production.py
+++ b/config/settings/production.py
@@ -3,6 +3,14 @@
 # Override default settings
 DEBUG = False
 MATHESAR_MODE = 'PRODUCTION'
+
+'''
+This tells Django to trust the X-Forwarded-Proto header that comes from our proxy,
+and any time its value is 'https', then the request is guaranteed to be secure
+(i.e., it originally came in via HTTPS).
+'''
+SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
+
 # Use a local.py module for settings that shouldn't be version tracked
 try:
     from .local import * # noqa 


Test patch:
Repository: mathesar-foundation/mathesar

Issue:
Demo is broken for 0.1.6
## Description
<!-- A clear and concise description of what the bug is. -->

The demo can't be deployed with the current `master` branch (0.1.6)

The reasons are:

- We didn't add the fix to the demo settings in #3499 (just to prod), and
- We have an extra dependency in the demo setup which we need to build in but the current `Dockerfile` doesn't support that.

## Expected behavior
<!-- A clear and concise description of what you expected to happen. -->

We should be able to demo version 0.1.6 on our demo site.


Discussion:

Resolving patch:
diff --git a/demo/settings.py b/demo/settings.py
--- a/demo/settings.py
+++ b/demo/settings.py
@@ -10,6 +10,9 @@
     "demo.middleware.LiveDemoModeMiddleware",
 ]
 
+
+SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
+
 MATHESAR_MODE = 'PRODUCTION'
 MATHESAR_LIVE_DEMO = True
 MATHESAR_LIVE_DEMO_USERNAME = decouple_config('MATHESAR_LIVE_DEMO_USERNAME', default=None)


Test patch:
Repository: mathesar-foundation/mathesar

Issue:
Remove unused API docs cruft
Since we're moving to the RPC endpoint style, we need to remove the remaining pieces of the REST API documentation infrastructure.


Discussion:

Resolving patch:
diff --git a/config/settings/common_settings.py b/config/settings/common_settings.py
--- a/config/settings/common_settings.py
+++ b/config/settings/common_settings.py
@@ -42,7 +42,6 @@ def pipe_delim(pipe_string):
     "rest_framework",
     "django_filters",
     "django_property_filter",
-    "drf_spectacular",
     "modernrpc",
     "mathesar",
 ]
@@ -207,18 +206,6 @@ def pipe_delim(pipe_string):
     'TEST_REQUEST_DEFAULT_FORMAT': 'json',
     'EXCEPTION_HANDLER':
         'mathesar.exception_handlers.mathesar_exception_handler',
-    'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema'
-}
-SPECTACULAR_SETTINGS = {
-    'TITLE': 'Mathesar API',
-    'DESCRIPTION': '',
-    'VERSION': '1.0.0',
-    'SERVE_INCLUDE_SCHEMA': False,
-    'PREPROCESSING_HOOKS': ['config.settings.openapi.custom_preprocessing_hook'],
-    'POSTPROCESSING_HOOKS': [
-        'config.settings.openapi.remove_url_prefix_hook',
-    ],
-    # OTHER SETTINGS
 }
 FRIENDLY_ERRORS = {
     'FIELD_ERRORS': {
diff --git a/config/settings/openapi.py b/config/settings/openapi.py
deleted file mode 100644
--- a/config/settings/openapi.py
+++ /dev/null
@@ -1,28 +0,0 @@
-def custom_preprocessing_hook(endpoints):
-    prefixes = [
-        "/api/db/v0/databases/",
-        "/api/db/v0/data_files/",
-        "/api/db/v0/schemas/",
-        "/api/db/v0/tables/",
-        "/api/db/v0/links/",
-        "/api/db/v0/queries/",
-        "/api/ui/v0/databases/",
-        "/api/ui/v0/users/",
-        "/api/ui/v0/database_roles/"
-    ]
-    filtered = [(path, path_regex, method, callback) for path, path_regex, method, callback in endpoints if any(path.startswith(prefix) for prefix in prefixes)]
-    return filtered
-
-
-def remove_url_prefix_hook(result, **kwargs):
-    # Remove namespace and version URL prefix from the operation Id of the generated API schema
-    for path, path_info in result['paths'].items():
-        for method, operation in path_info.items():
-            operation_id = operation.get('operationId')
-            if operation_id:
-                if path.startswith('/api/db/v0/'):
-                    operation['operationId'] = operation_id.replace('db_v0_', '')
-                elif path.startswith('/api/ui/v0/'):
-                    operation['operationId'] = operation_id.replace('ui_v0_', '')
-
-    return result


Test patch:
Repository: cfpb/consumerfinance.gov

Issue:
Centering on mobile
`the-bureau` page contains media blocks whose content (image & body) becomes centered at mobile sizes via a `media__centered` class. The `office` index page, however, introduces a new pattern of media blocks whose image centers on mobile while the body remains left-aligned. 

It seems like it would be more useful to add a general-purpose `.centered-on-mobile` class (or two classes, one for inline & the other for block elements) that could be applied to the appropriate parts of the media object rather than handle this behavior through .`media` modifiers. 

Thoughts? Preferences?



Discussion:
Sounds good to me.


Resolving patch:
diff --git a/_lib/wordpress_office_processor.py b/_lib/wordpress_office_processor.py
--- a/_lib/wordpress_office_processor.py
+++ b/_lib/wordpress_office_processor.py
@@ -55,17 +55,17 @@ def process_office(item):
     
     # create list of office resource dicts
     item['resources'] = []
-    for x in xrange(1,4):
+    for x in xrange(0,4):
         resource = {}
-        fields = ['head', 'desc', 'icon', 'link_0']
+        fields = ['head', 'desc', 'icon', 'link']
         for field in fields:
-            field_name = 'resource%s_%s' % (str(x), field)
+            field_name = 'resource_%s_%s' % (str(x), field)
             if field_name in custom_fields and custom_fields[field_name][0] != '':
-                if field == 'link_0':
-                    resource['link'] = custom_fields[field_name]
+                if field == 'link':
+                    resource[field] = custom_fields[field_name]
                 else:
                     resource[field] = custom_fields[field_name][0]
-                            
+                    
         if resource:
             item['resources'].append(resource)
 


Test patch:
Repository: open-mmlab/mmengine

Issue:
用户设置完了paramwise_cfg，如何知道是否符合预期，这个是否也要提供相应的脚本，用户运行后可以很容易的知道哪些参数被 frozen，不太参数组超参的不同。暂时没有时间开发的话，可以作为未来一个需求吧
用户设置完了，如何知道是否符合预期，这个是否也要提供相应的脚本，用户运行后可以很容易的知道哪些参数被 frozen，不太参数组超参的不同。暂时没有时间开发的话，可以作为未来一个需求吧

_Originally posted by @hhaAndroid in https://github.com/open-mmlab/mmengine/pull/25#discussion_r809786760_


Discussion:
OptimizerConstructor should be able to print out which parameter's LR/weight_decay are modified from what to what.
See examples in https://github.com/open-mmlab/mmselfsup/blob/master/mmselfsup/core/optimizer/constructor.py#L74

Resolving patch:
diff --git a/mmengine/optim/optimizer/default_constructor.py b/mmengine/optim/optimizer/default_constructor.py
--- a/mmengine/optim/optimizer/default_constructor.py
+++ b/mmengine/optim/optimizer/default_constructor.py
@@ -5,6 +5,7 @@
 import torch
 import torch.nn as nn
 from torch.nn import GroupNorm, LayerNorm
+from mmengine.mmengine.logging.logger import print_log
 
 from mmengine.registry import OPTIMIZER_CONSTRUCTORS, OPTIMIZERS
 from mmengine.utils import is_list_of, mmcv_full_available
@@ -226,6 +227,13 @@ def add_params(self,
                         param_group[
                             'weight_decay'] = self.base_wd * bias_decay_mult
             params.append(param_group)
+            for key, value in param_group.items():
+                if key == 'params':
+                    continue
+                full_name = f'{prefix}.{name}' if prefix else name
+                print_log(
+                    f'paramwise_options -- {full_name}:{key}={value}',
+                    logger='current')
 
         if mmcv_full_available():
             from mmcv.ops import DeformConv2d, ModulatedDeformConv2d


Test patch:
Repository: open-mmlab/mmengine

Issue:
ValueError when use `--resume` because of the dataset meta comparsion
When I used `--resume` in `tools/train.py`, the program will check whether the dataset meta in the loaded checkpoint file and the dataset meta built from the config are the same, like the code here:

https://github.com/open-mmlab/mmengine/blob/ac8686e28bb7285fe9d8fcd97e588406d4a6f164/mmengine/runner/runner.py#L1920

But when my dataset contains some type that is not Python-builtin type, like numpy.ndarray, the comparison function will raise the following error:

```
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
    and dataset_meta != self.train_dataloader.dataset.metainfo):
```

Do you have any solution for this? Thanks~



Discussion:

Resolving patch:
diff --git a/mmengine/runner/runner.py b/mmengine/runner/runner.py
--- a/mmengine/runner/runner.py
+++ b/mmengine/runner/runner.py
@@ -3,6 +3,7 @@
 import logging
 import os
 import os.path as osp
+import pickle
 import platform
 import time
 import warnings
@@ -1910,7 +1911,11 @@ def resume(self,
 
         resumed_dataset_meta = checkpoint['meta'].get('dataset_meta', None)
         dataset_meta = getattr(self.train_dataloader.dataset, 'metainfo', None)
-        if resumed_dataset_meta != dataset_meta:
+
+        # `resumed_dataset_meta` and `dataset_meta` could be object like
+        # np.ndarray, which cannot be directly judged as equal or not,
+        # therefore we just compared their dumped results.
+        if pickle.dumps(resumed_dataset_meta) != pickle.dumps(dataset_meta):
             warnings.warn(
                 'The dataset metainfo from the resumed checkpoint is '
                 'different from the current training dataset, please '


Test patch:
Repository: open-mmlab/mmengine

Issue:
config/utils.py haven't mmyolo
![aa791cf4fdac9e12eccfd0e54bb7136](https://user-images.githubusercontent.com/25839884/200160438-d0631694-003e-4ecc-ba77-e518d2ee96b2.png)



Discussion:
We'll add it ASAP

Resolving patch:
diff --git a/mmengine/config/utils.py b/mmengine/config/utils.py
--- a/mmengine/config/utils.py
+++ b/mmengine/config/utils.py
@@ -25,6 +25,7 @@
     'mmhuman3d': 'mmhuman3d',
     'mmrotate': 'mmrotate',
     'mmselfsup': 'mmselfsup',
+    'mmyolo': 'mmyolo',
 }
 
 


Test patch:
Repository: open-mmlab/mmengine

Issue:
[Bug] A bug in get_model_complexity_info()
### Prerequisite

- [X] I have searched [Issues](https://github.com/open-mmlab/mmengine/issues) and [Discussions](https://github.com/open-mmlab/mmengine/discussions) but cannot get the expected help.
- [X] The bug has not been fixed in the latest version(https://github.com/open-mmlab/mmengine).

### Environment

- 

### Reproduces the problem - code sample

-

### Reproduces the problem - command or script

-

### Reproduces the problem - error message

-

### Additional information

In https://github.com/open-mmlab/mmengine/blob/f1aca8e307c32d4195ca065e18536b23b20c668c/mmengine/analysis/print_helper.py#L708, when `inputs=None`, `get_model_complexity_info()` will create a random tensor on `cpu`, which leads to an error when the model is on `cuda`


Discussion:

Resolving patch:
diff --git a/mmengine/analysis/print_helper.py b/mmengine/analysis/print_helper.py
--- a/mmengine/analysis/print_helper.py
+++ b/mmengine/analysis/print_helper.py
@@ -725,14 +725,15 @@ def get_model_complexity_info(
         raise ValueError('"input_shape" and "inputs" cannot be both set.')
 
     if inputs is None:
+        device = next(model.parameters()).device
         if is_tuple_of(input_shape, int):  # tuple of int, construct one tensor
-            inputs = (torch.randn(1, *input_shape), )
+            inputs = (torch.randn(1, *input_shape).to(device), )
         elif is_tuple_of(input_shape, tuple) and all([
                 is_tuple_of(one_input_shape, int)
                 for one_input_shape in input_shape  # type: ignore
         ]):  # tuple of tuple of int, construct multiple tensors
             inputs = tuple([
-                torch.randn(1, *one_input_shape)
+                torch.randn(1, *one_input_shape).to(device)
                 for one_input_shape in input_shape  # type: ignore
             ])
         else:


Test patch:
Repository: scikit-image/scikit-image

Issue:
message about unit tests not available
If scikits-image is installed without nose, a message is printed about unit tests not being available is printed on import but it is a little bit distracting to the casual end-user.



Discussion:

Resolving patch:
diff --git a/skimage/__init__.py b/skimage/__init__.py
--- a/skimage/__init__.py
+++ b/skimage/__init__.py
@@ -72,26 +72,20 @@ def _setup_test(verbose=False):
     try:
         import nose as _nose
     except ImportError:
-        print("Could not load nose.  Unit tests not available.")
-        return None
+        def broken_test_func():
+            """This would invoke the skimage test suite, but nose couldn't be
+            imported so the test suite can not run.
+            """
+            raise ImportError("Could not load nose.  Unit tests not available.")
+        return broken_test_func
     else:
         f = functools.partial(_nose.run, 'skimage', argv=args)
         f.__doc__ = 'Invoke the skimage test suite.'
         return f
 
-test = _setup_test()
-if test is None:
-    try:
-        del test
-    except NameError:
-        pass
 
+test = _setup_test()
 test_verbose = _setup_test(verbose=True)
-if test_verbose is None:
-    try:
-        del test
-    except NameError:
-        pass
 
 
 def get_log(name=None):


Test patch:
Repository: scikit-image/scikit-image

Issue:
ImageViewer does not allow continuation of program execution?
```
from skimage.viewer import ImageViewer
from skimage.viewer.widgets import Slider
from skimage.viewer.plugins.overlayplugin import OverlayPlugin

from skimage import data, filter

image = data.coins()

viewer = ImageViewer(image)

plugin = OverlayPlugin(image_filter=filter.canny)
plugin += Slider('sigma', 0, 5, update_on='release')
viewer += plugin

viewer.show()

print "Asd"
```

No "Asd" is ever printed.



Discussion:

Resolving patch:
diff --git a/skimage/viewer/viewers/core.py b/skimage/viewer/viewers/core.py
--- a/skimage/viewer/viewers/core.py
+++ b/skimage/viewer/viewers/core.py
@@ -126,7 +126,7 @@ def show(self):
         for p in self.plugins:
             p.show()
         super(ImageViewer, self).show()
-        sys.exit(qApp.exec_())
+        qApp.exec_()
 
     def redraw(self):
         self.canvas.draw_idle()


Test patch:
Repository: scikit-image/scikit-image

Issue:
missing doctring (dilate and erode in morphology)
I don't know how to fix this.

In morphology, cmorph.pyx contains 2 functions (dilate and erode) without docstring.
But, it appears that a wrapper is defined in grey.py (dilation and erosion) and it is fully documentated. 

I would suggest to add a dostring and rename dilate to _dilate. Is it the conventional way?

BTW, I have two questions (might not be the right place, I ask anyway):
- How sphinx knows that he should read/ignore docstrings. Is it related to **all** list in **init**.py ?
- Some *.py or *.pyx start with an underscore (_). Why?

Thanks :)



Discussion:
Although those Cython functions are not visible to the user since they are not defined in `__all__`, they should be renamed to have a leading underscore.

.pyx and .py files have a leading underscore if functions with the same name exist. According to @stefanv conflicting names would lead to faulty "nose-testing".

As for how Sphinx discovers docstrings, my guess is the following method in `ApiDocWriter`:

https://github.com/scikit-image/scikit-image/blob/master/doc/tools/apigen.py#L306

If not there, it's almost certainly somewhere in the module.

The motivation was that I want to be able to access the internal implementation as well.  If we call the `.py` file `xyz.py` and the function `xyz`, then how do you import `skimage.morphology.xyz(.py)`?

@tonysyu That's right.


Resolving patch:
diff --git a/skimage/morphology/grey.py b/skimage/morphology/grey.py
--- a/skimage/morphology/grey.py
+++ b/skimage/morphology/grey.py
@@ -58,8 +58,8 @@ def erosion(image, selem, out=None, shift_x=False, shift_y=False):
         raise NotImplementedError("In-place erosion not supported!")
     image = img_as_ubyte(image)
     selem = img_as_ubyte(selem)
-    return cmorph.erode(image, selem, out=out,
-                        shift_x=shift_x, shift_y=shift_y)
+    return cmorph._erode(image, selem, out=out,
+                         shift_x=shift_x, shift_y=shift_y)
 
 
 def dilation(image, selem, out=None, shift_x=False, shift_y=False):
@@ -111,8 +111,8 @@ def dilation(image, selem, out=None, shift_x=False, shift_y=False):
         raise NotImplementedError("In-place dilation not supported!")
     image = img_as_ubyte(image)
     selem = img_as_ubyte(selem)
-    return cmorph.dilate(image, selem, out=out,
-                         shift_x=shift_x, shift_y=shift_y)
+    return cmorph._dilate(image, selem, out=out,
+                          shift_x=shift_x, shift_y=shift_y)
 
 
 def opening(image, selem, out=None):


Test patch: