internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: cookiecutter/cookiecutter-django

Issue:
Missing env variable when deploying to production using Sendgrid
## What happened?
Error while deploying to production: `django.core.exceptions.ImproperlyConfigured: Set the SENDGRID_GENERATE_MESSAGE_ID environment variable`

It looks like non-essential env config was added without defaults.

## What should've happened instead?
Deploy without errors


## Solution
Add defaults to Sendgrid config.
Change the following:
```
ANYMAIL = {
    "SENDGRID_API_KEY": env("SENDGRID_API_KEY"),
    "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID",
    "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"),
    "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"),
}
```

To:
```
ANYMAIL = {
    "SENDGRID_API_KEY": env("SENDGRID_API_KEY"),
    "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID", default=True),
    "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT", default=None),
    "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"),
}
```



Discussion:
@charleshan I can make a patch. For the `SENDGRID_MERGE_FIELD_FORMAT `, it says it's for legacy SendGrid. Perhaps it's best if that's removed instead? https://anymail.readthedocs.io/en/stable/esps/sendgrid/#settings
> For the `SENDGRID_MERGE_FIELD_FORMAT `, it says it's for legacy SendGrid. Perhaps it's best if that's removed instead?

Agree, let's drop it 👍🏻 

Do we need `SENDGRID_GENERATE_MESSAGE_ID`? This seems optional as well and will default to `True` if not specified.
Hi, is this issue still open? i'd to make my first contribution
@rakhazachrie Sure, please do. By the way, no need to ask for permissions, any open issue is up for grab 😉 

If an open issue looks no longer valid, making a comment to state it explaining why is also super valuable. 
@browniebroke Please assign this issue to me. I am happy to work on this :)
Again, no need to "assign" the issue to anyone. If you want to fix it, send us a pull request with the changes.

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py
--- a/{{cookiecutter.project_slug}}/config/settings/production.py
+++ b/{{cookiecutter.project_slug}}/config/settings/production.py
@@ -189,8 +189,6 @@
 EMAIL_BACKEND = "anymail.backends.sendgrid.EmailBackend"
 ANYMAIL = {
     "SENDGRID_API_KEY": env("SENDGRID_API_KEY"),
-    "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID"),
-    "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"),
     "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"),
 }
 {%- elif cookiecutter.mail_service == 'SendinBlue' %}


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Project incorrectly generated if a Pycharm is picked as Editor
## What happened?
I generated a cookiecutter-django project with PyCharm selected as my Editor, but the initial run configurations for my PyCharm editor were unexpectedly absent.

## What should've happened instead?
The initial run configuration for PyCharm should have been present.

## Additional details
It seems that the only thing related to my specific issue is a typo in recent changes. I opened a PR #4441  hopefully fixing it.




Discussion:

Resolving patch:
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -80,7 +80,7 @@ def remove_docker_files():
     file_names = ["local.yml", "production.yml", ".dockerignore"]
     for file_name in file_names:
         os.remove(file_name)
-    if "{{ cookiecutter.editor }}".lower() == "PyCharm":
+    if "{{ cookiecutter.editor }}" == "PyCharm":
         file_names = ["docker_compose_up_django.xml", "docker_compose_up_docs.xml"]
         for file_name in file_names:
             os.remove(os.path.join(".idea", "runConfigurations", file_name))
@@ -428,7 +428,7 @@ def main():
     if "{{ cookiecutter.username_type }}" == "username":
         remove_custom_user_manager_files()
 
-    if "{{ cookiecutter.editor }}".lower() != "PyCharm":
+    if "{{ cookiecutter.editor }}" != "PyCharm":
         remove_pycharm_files()
 
     if "{{ cookiecutter.use_docker }}".lower() == "y":


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Unused gulp dependency added to package.json when Webpack is chosen
## What happened?
package.json has reference to `"gulp-concat": "^2.6.1"` even though it is not used when Webpack has been chosen

## What should've happened instead?
No reference to gulp-concat at all when using Webpack

## Additional details

    Host system configuration:
        Cookiecutter 2.1.1
        Ventura 13.5
        Python 3.11.4
        Docker version 24.0.2, build cb74dfc
        Docker Compose version v2.19.1



Discussion:
Good catch! For anyone who wants to contribute to the project, the value should be added here:
 https://github.com/cookiecutter/cookiecutter-django/blob/master/hooks/post_gen_project.py#L182-L192
Tks, will directly send a pull request next time then👍🏼On 11 Aug 2023, at 15:02, Bruno Alla ***@***.***> wrote:﻿
Good catch! For anyone who wants to contribute to the project, the value should be added here:
https://github.com/cookiecutter/cookiecutter-django/blob/master/hooks/post_gen_project.py#L182-L192

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>

Resolving patch:
diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py
--- a/hooks/post_gen_project.py
+++ b/hooks/post_gen_project.py
@@ -183,6 +183,7 @@ def handle_js_runner(choice, use_docker, use_async):
             "browser-sync",
             "cssnano",
             "gulp",
+            "gulp-concat",
             "gulp-imagemin",
             "gulp-plumber",
             "gulp-postcss",


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Replace mailhog with mailpit
## Description

Since a long time we rely on mailhog in development without much of a hassle. Although mailhog isn't maintained anymore it seems to work fine for Django and this particular project

In another (non Django) project we experience some issues with the [parsing of multipart](https://github.com/mailhog/MailHog/issues/411) headers.

The successor of mailhog, [mailpit](https://github.com/axllent/mailpit/) doesn't have this issue and is actively maintained. 

## Rationale

I would like to propose to replace mailhog with mailpit so even our mail container is actively maintained. 



Discussion:
I didn't know mailhog was no longer maintained, I'm not using much myself... Looking at the repo activity, I think you're right: issues and PR are being opened but receive little attention, no many commits in past years.

I don't have any objections to move to something else, especially since you're bringing a good reason to do so. PR welcome. Should hopefully be an easy one? 

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py
--- a/{{cookiecutter.project_slug}}/config/settings/local.py
+++ b/{{cookiecutter.project_slug}}/config/settings/local.py
@@ -25,12 +25,12 @@
 
 # EMAIL
 # ------------------------------------------------------------------------------
-{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'y' -%}
+{% if cookiecutter.use_mailpit == 'y' and cookiecutter.use_docker == 'y' -%}
 # https://docs.djangoproject.com/en/dev/ref/settings/#email-host
-EMAIL_HOST = env("EMAIL_HOST", default="mailhog")
+EMAIL_HOST = env("EMAIL_HOST", default="mailpit")
 # https://docs.djangoproject.com/en/dev/ref/settings/#email-port
 EMAIL_PORT = 1025
-{%- elif cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' -%}
+{%- elif cookiecutter.use_mailpit == 'y' and cookiecutter.use_docker == 'n' -%}
 # https://docs.djangoproject.com/en/dev/ref/settings/#email-host
 EMAIL_HOST = "localhost"
 # https://docs.djangoproject.com/en/dev/ref/settings/#email-port


Test patch:
diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py
--- a/tests/test_cookiecutter_generation.py
+++ b/tests/test_cookiecutter_generation.py
@@ -115,8 +115,8 @@ def context():
     {"frontend_pipeline": "Webpack"},
     {"use_celery": "y"},
     {"use_celery": "n"},
-    {"use_mailhog": "y"},
-    {"use_mailhog": "n"},
+    {"use_mailpit": "y"},
+    {"use_mailpit": "n"},
     {"use_sentry": "y"},
     {"use_sentry": "n"},
     {"use_whitenoise": "y"},
Repository: cookiecutter/cookiecutter-django

Issue:
Implement django-allauth's MFA
## Description

Can we add this?

## Rationale

For added security for the project


Discussion:
Related #2320 
> Related #2320

It's unrelated. Here's how to implement it. https://stackoverflow.com/questions/77186177/how-to-use-new-django-allauth-mfa
Hi folks,
I'm newbie to open source contribution. Can someone elaborate the issue and what I'm supposed to do.
Also will it be ok to get started with this issue ?
> Hi folks, I'm newbie to open source contribution. Can someone elaborate the issue and what I'm supposed to do. Also will it be ok to get started with this issue ?

Add django-allauth's MFA with styling.

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py
--- a/{{cookiecutter.project_slug}}/config/settings/base.py
+++ b/{{cookiecutter.project_slug}}/config/settings/base.py
@@ -84,6 +84,7 @@
     "crispy_bootstrap5",
     "allauth",
     "allauth.account",
+    "allauth.mfa",
     "allauth.socialaccount",
 {%- if cookiecutter.use_celery == 'y' %}
     "django_celery_beat",


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
Why doesn't add RunServerPlus options for reload in windows when using docker?
## Description

What are you proposing? How should it be implemented?

Add this code when window = y when generating project, for reloading django code in window.

```
end of base.py
# RunServerPlus
# ------------------------------------------------------------------------------
{% if cookiecutter.windows == 'y' %}
# After how many seconds auto-reload should scan for updates in poller-mode
RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 5

# Werkzeug reloader type [auto, watchdog, or stat]
RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'
{% endif %}
```

## Rationale

Why should this feature be implemented?
In window with docker, somehow(might be filesytem problem) reload doens't work with default RELOADER_TYPE.
So we should add above code but when the first time using cookiecutter, all of users don't realize what happens like me.
So it should be set by default when windows option as y in generating project step.


Discussion:
This would definitely help, can you submit a PR? 
> This would definitely help, can you submit a PR? 

Yeah. It is honor to me. I will make a pr soon. I hope you review my code. 😀

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py
--- a/{{cookiecutter.project_slug}}/config/settings/local.py
+++ b/{{cookiecutter.project_slug}}/config/settings/local.py
@@ -83,6 +83,15 @@
         # The node container isn't started (yet?)
         pass
     {%- endif %}
+    {%- if cookiecutter.windows == 'y' %}
+    # RunServerPlus
+    # ------------------------------------------------------------------------------
+    # This is a custom setting for RunServerPlus to fix reloader issue in Windows docker environment
+    # Werkzeug reloader type [auto, watchdog, or stat]
+    RUNSERVERPLUS_POLLER_RELOADER_TYPE = 'stat'
+    # If you have CPU and IO load issues, you can increase this poller interval e.g) 5
+    RUNSERVERPLUS_POLLER_RELOADER_INTERVAL = 1
+    {%- endif %}
 {%- endif %}
 
 # django-extensions


Test patch:
Repository: cookiecutter/cookiecutter-django

Issue:
ValueError: Another profiling tool is already active
## What happened?
By upgrading to python 3.12 we inherited a bug from django-debug-toolbar
Here's the issue:
https://github.com/jazzband/django-debug-toolbar/issues/1875




Discussion:
I fixed with 
exec python manage.py runserver_plus 0.0.0.0:8000 --nothreading

can't provide a PR atm, github seems kind of down
See https://github.com/cookiecutter/cookiecutter-django/issues/4644#issuecomment-2082235125 for a potential solution, PR welcome

Resolving patch:
diff --git a/{{cookiecutter.project_slug}}/config/settings/local.py b/{{cookiecutter.project_slug}}/config/settings/local.py
--- a/{{cookiecutter.project_slug}}/config/settings/local.py
+++ b/{{cookiecutter.project_slug}}/config/settings/local.py
@@ -64,7 +64,12 @@
 MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
 # https://django-debug-toolbar.readthedocs.io/en/latest/configuration.html#debug-toolbar-config
 DEBUG_TOOLBAR_CONFIG = {
-    "DISABLE_PANELS": ["debug_toolbar.panels.redirects.RedirectsPanel"],
+    "DISABLE_PANELS": [
+        "debug_toolbar.panels.redirects.RedirectsPanel",
+        # Disable profiling panel due to an issue with Python 3.12:
+        # https://github.com/jazzband/django-debug-toolbar/issues/1875
+        "debug_toolbar.panels.profiling.ProfilingPanel",
+    ],
     "SHOW_TEMPLATE_CONTEXT": True,
 }
 # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips


Test patch:
Repository: pingcap/docs

Issue:
Connectors and APIs need updating
## Change Request

https://docs.pingcap.com/tidb/stable/connectors-and-apis

Issues:
- Not referenced in the TOC
- Outdated info
- Overlapping and contradicting the info on https://docs.pingcap.com/appdev/dev/app-dev-overview





Discussion:

Resolving patch:
diff --git a/scripts/check-unreachable.py b/scripts/check-unreachable.py
new file mode 100755
--- /dev/null
+++ b/scripts/check-unreachable.py
@@ -0,0 +1,27 @@
+#!/bin/python3
+import glob
+import subprocess
+
+allowlist = {
+    "_index.md",
+    "TOC.md",
+}
+
+for mdfile in glob.iglob("**/*.md", recursive=True):
+    if mdfile.startswith("node_modules/"):
+        continue
+
+    # There are quite a few dangling documents in the benchmarks,
+    # but those are more likely to be referenced from outside of the docs
+    # and might have historical relevance
+    if mdfile.startswith("benchmark/"):
+        continue
+
+    if mdfile in allowlist:
+        continue
+
+    p = subprocess.run(
+        ["git", "grep", "-l", f"/{mdfile}"], capture_output=True, encoding="utf-8"
+    )
+    if p.stdout == "":
+        print(f"File {mdfile} has NO matches")


Test patch:
Repository: d2l-ai/d2l-en

Issue:
test accuracy is evaluated with dropout
In the torch code in section 4.6.4.2, an instance variable `is_training` is defined, but is kept constant during training, so the test accuracy is evaluated with dropout enabled which is probably not intended.

There is an instance variable `training` inherited from `nn.Module` (used by the `nn.Dropout` layer) that could be used instead. See https://pytorch.org/docs/stable/nn.html#torch.nn.Module.train.


Discussion:
@AnirudhDagar 

Resolving patch:
diff --git a/d2l/torch.py b/d2l/torch.py
--- a/d2l/torch.py
+++ b/d2l/torch.py
@@ -231,6 +231,8 @@ def accuracy(y_hat, y):  #@save
 # Defined in file: ./chapter_linear-networks/softmax-regression-scratch.md
 def evaluate_accuracy(net, data_iter):  #@save
     """Compute the accuracy for a model on a dataset."""
+    if isinstance(net, torch.nn.Module):
+        net.eval()  # Set the model to evaluation mode
     metric = Accumulator(2)  # No. of correct predictions, no. of predictions
     for _, (X, y) in enumerate(data_iter):
         metric.add(accuracy(net(X), y), sum(y.shape))
@@ -324,6 +326,8 @@ def train_ch3(net, train_iter, test_iter, loss, num_epochs, updater):  #@save
     animator = Animator(xlabel='epoch', xlim=[1, num_epochs], ylim=[0.3, 0.9],
                         legend=['train loss', 'train acc', 'test acc'])
     for epoch in range(num_epochs):
+        if isinstance(net, torch.nn.Module):
+            net.train()  # Set the model to training mode
         train_metrics = train_epoch_ch3(net, train_iter, loss, updater)
         test_acc = evaluate_accuracy(net, test_iter)
         animator.add(epoch + 1, train_metrics + (test_acc,))
@@ -450,6 +454,7 @@ def corr2d(X, K):  #@save
 
 # Defined in file: ./chapter_convolutional-neural-networks/lenet.md
 def evaluate_accuracy_gpu(net, data_iter, device=None): #@save
+    net.eval()  # Set the model to evaluation mode
     if not device:
         device = next(iter(net.parameters())).device
     metric = d2l.Accumulator(2)  # num_corrected_examples, num_examples


Test patch:
Repository: d2l-ai/d2l-en

Issue:
pytorch 10.3 transformer
*Description of changes:*


By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.



Discussion:
Thanks for rectifying that mistake. ndarray.md was not supposed to be part of the commit. One of the cells is timing out now. I'll check and see what I can do about this.
The final training block for pytorch is taking 10x the time taken by the mxnet implementation. I've not been able to find the root cause for this yet. There is not any significant differences in the implementation. The major difference in pytorch and mxnet implementation is that the input values for each linear layer needs to be provided explicitly for pytorch. 
@ypandya any updates on this?
> @ypandya any updates on this?

I have matched the mxnet and pytorch models in detail. There is no difference in the architecture. My early guess was that there maybe difference in the layer norm implementation in pytorch and mxnet. But the training takes the same amount of time even when I experimented with replacing layernorm with batchnorm. I could not find any reason for the difference which can cause the torch training to take 10x the time taken by mxnet. It would be really helpful if someone with more knowledge of mxnet can take a look at this. 
Thanks! I see, I'll try to look at the PyTorch code if I can find the difference.
Maybe @astonzhang or @mli can have a look to spot the problem and to find a fix. 

Resolving patch:
diff --git a/d2l/torch.py b/d2l/torch.py
--- a/d2l/torch.py
+++ b/d2l/torch.py
@@ -973,10 +973,11 @@ def forward(self, X, state):
 
 # Defined in file: ./chapter_recurrent-modern/seq2seq.md
 def sequence_mask(X, valid_len, value=0):
-    output = X.clone()
-    for count, matrix in enumerate(output):
-        matrix[int(valid_len[count]):]=value
-    return output
+    maxlen = X.size(1)
+    mask = torch.arange((maxlen), dtype=torch.float32,
+                        device=X.device)[None, :] < valid_len[:, None]    
+    X[~mask] = value
+    return X
 
 
 # Defined in file: ./chapter_recurrent-modern/seq2seq.md


Test patch:
Repository: d2l-ai/d2l-en

Issue:
The training process of CNN implemented by Pytorch may have something wrong on the master branch.
In [7.6.2](http://preview.d2l.ai.s3-website-us-west-2.amazonaws.com/d2l-en/master/chapter_convolutional-neural-networks/lenet.html#training), [8.1.3](http://preview.d2l.ai.s3-website-us-west-2.amazonaws.com/d2l-en/master/chapter_convolutional-modern/alexnet.html#training), [8.2.3](http://preview.d2l.ai.s3-website-us-west-2.amazonaws.com/d2l-en/master/chapter_convolutional-modern/vgg.html#training), [8.3.3](http://preview.d2l.ai.s3-website-us-west-2.amazonaws.com/d2l-en/master/chapter_convolutional-modern/nin.html#training), and [8.4.3](http://preview.d2l.ai.s3-website-us-west-2.amazonaws.com/d2l-en/master/chapter_convolutional-modern/googlenet.html#training), the loss of CNN implemented by Pytorch has not decreased at all or has not decreased in the first few epochs, which is different from the results of Mxnet and Tensorflow.


Discussion:
Hi, @AnirudhDagar , these problems have not been solved.
Hi @nnnnnzy, we know that these are a few issues. We'll definitely fix them before our next release. You can refer to the last stable release https://d2l.ai till the time.

Resolving patch:
diff --git a/d2l/torch.py b/d2l/torch.py
--- a/d2l/torch.py
+++ b/d2l/torch.py
@@ -1780,7 +1780,7 @@ def __init__(self, is_train, crop_size, voc_dir):
         print('read ' + str(len(self.features)) + ' examples')
 
     def normalize_image(self, img):
-        return self.transform(img.float()/255)
+        return self.transform(img.float() / 255)
 
     def filter(self, imgs):
         return [img for img in imgs if (
@@ -2583,6 +2583,14 @@ def evaluate_accuracy_gpu(net, data_iter, device=None):
     return metric[0] / metric[1]
 
 
+def init_cnn_weights(layer):
+    """Initialize weights for CNNs.
+
+    Defined in :numref:`sec_utils`"""
+    if type(layer) == nn.Linear or type(layer) == nn.Conv2d:
+        nn.init.xavier_uniform_(layer.weight)
+
+
 def train_ch6(net, train_iter, test_iter, num_epochs, lr, device):
     """Train a model with a GPU (defined in Chapter 6).
 


Test patch:
Repository: d2l-ai/d2l-en

Issue:
ModuleNotFoundError when running the official pytorch colab notebook
![image](https://user-images.githubusercontent.com/33608782/184685789-951935c7-1725-4a23-944d-8d48b32bf76c.png)

I can replicate the error at multiple official pytorch colab notebooks, e.g. 

https://colab.research.google.com/github/d2l-ai/d2l-pytorch-colab/blob/master/chapter_linear-classification/image-classification-dataset.ipynb#scrollTo=ee445cce





Discussion:
As a result, all of the following code cells cannot run because the the name 'd2l' is not defined. 

For example,

![image](https://user-images.githubusercontent.com/33608782/184687484-f918a909-6bf4-4640-920f-84aea2c5cb1e.png)

Thanks for the report @gab-chen. This is quite weird. I was able to reproduce the problem on all the frameworks. 

Just two days ago, I was testing the same notebook on colab to fix #2247. It seems like colab has dropped `matplotlib_inline` package support or I'm missing something here. This will then need a manual install or adding it as a dep in d2l.

cc @astonzhang 
> Thanks for the report @gab-chen. This is quite weird. I was able to reproduce the problem on all the frameworks.
> 
> Just two days ago, I was testing the same notebook on colab to fix #2247. It seems like colab has dropped `matplotlib_inline` package support or I'm missing something here. This will then need a manual install or adding it as a dep in d2l.
> 
> cc @astonzhang

Thanks for your prompt response. 
I confirm that yesterday I could import `d2l` and run the official pytorch notebooks without any error. 
For anyone who is blocked by the error, 
you can manually install like below to avoid the error. 
`!pip install matplotlib-inline`
![image](https://user-images.githubusercontent.com/33608782/184924270-b1cfd6b1-c48e-4120-bb91-7a077d990388.png)


But it is time-consuming and error-prone to update all of the D2L pytorch notebooks on reader side. 
@AnirudhDagar Please consider adding it as a dep in d2l ASAP.
@gab-chen we'll try to fix this in our next release, maybe we can create a patch release this week to fix this problem. @astonzhang WDYT?

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -2,6 +2,7 @@
 import d2l
 
 requirements = [
+    'ipython>=7.23',
     'jupyter',
     'numpy',
     'matplotlib',


Test patch: