internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spotify/luigi

Issue:
Is there a reason python-dateutil is pinned to v2.7.5?
In this [commit](https://github.com/spotify/luigi/commit/ca0aa9afedecda539339e51974ef38cecf180d4b), I can see that python-dateutil has been pinned to version 2.7.5 -  is this strictly necessary? Version 2.8.0 was released a couple of weeks ago and It's causing `ContextualVersionConflict` errors for us.




Discussion:
@birdcolour Most likely it was the latest version available at the time. Not all projects follow semantic versioning, so where possible we often lock to a specific version.

Feel free to run tests with an updated `dateutil` version and verify they pass! 
Same issue/question here.

example to reproduce the warning I am getting:

```
$ cat setup.py
import setuptools

setuptools.setup(
    name="foobar",
    install_requires=['pandas', 'luigi']
)

$ docker run --rm -it -v $PWD:/app -w /app python:3.7-slim-stretch bash

root@35373e471b55:/app# pip install .
...
Collecting luigi (from foobar==0.0.0)
  Downloading https://files.pythonhosted.org/packages/3c/ac/28a8e7754eb4540bc5c9a3f0c831ea61dd4eae0e99d25345bd9d562f770a/luigi-2.8.3.tar.gz (1.2MB)
...
Collecting python-dateutil>=2.5.0 (from pandas->foobar==0.0.0)
  Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
...
luigi 2.8.3 has requirement python-dateutil==2.7.5, but you'll have python-dateutil 2.8.0 which is incompatible.
...

root@35373e471b55:/app# pip freeze
...
luigi==2.8.3
python-dateutil==2.8.0
...
```

FYI was introduced by https://github.com/spotify/luigi/pull/2601/files/68de9c22f0b0385b5e4117065fdaf8dcb95493c1#diff-2eeaed663bd0d25b7e608891384b7298

![Screenshot 2019-03-21 at 16 35 38](https://user-images.githubusercontent.com/44946/54764932-ece64f80-4bf8-11e9-91ce-8806f36d7c73.png)

IMHO this "securing the software supply chain" is a misguided reason to pin a dependency with `==` to a specific version (at least for libraries like luigi, for applications the story is the other way) and it will cause more issues than it might solve

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -41,7 +41,7 @@ def get_static_files(path):
     'tornado>=4.0,<5',
     # https://pagure.io/python-daemon/issue/18
     'python-daemon<2.2.0',
-    'python-dateutil==2.7.5',
+    'python-dateutil>=2.7.5,<3',
 ]
 
 # Note: To support older versions of setuptools, we're explicitly not


Test patch:
Repository: spotify/luigi

Issue:
PySparkTask fails if name contains invalid characters
PySparkTask derives run_path and run_pickle from name property, but it do not escape special characters:
1. '/' in name causes FileNotFoundError raised by mkdtemp
2. ',' is separator of files in spark-submit '--files' arg, and run_pickle is passed to 'files' arg in cluster mode.
3. ':' causes java.net.URISyntaxException

To reproduce: create PySparkTask subclass with name property containing above special characters and try to run it.



Discussion:

Resolving patch:
diff --git a/luigi/contrib/spark.py b/luigi/contrib/spark.py
--- a/luigi/contrib/spark.py
+++ b/luigi/contrib/spark.py
@@ -17,6 +17,7 @@
 
 import logging
 import os
+import re
 import sys
 import tempfile
 import shutil
@@ -298,8 +299,9 @@ def app_command(self):
         return [self.app, pickle_loc] + self.app_options()
 
     def run(self):
-        self.run_path = tempfile.mkdtemp(prefix=self.name)
-        self.run_pickle = os.path.join(self.run_path, '.'.join([self.name.replace(' ', '_'), 'pickle']))
+        path_name_fragment = re.sub(r'[^\w]', '_', self.name)
+        self.run_path = tempfile.mkdtemp(prefix=path_name_fragment)
+        self.run_pickle = os.path.join(self.run_path, '.'.join([path_name_fragment, 'pickle']))
         with open(self.run_pickle, 'wb') as fd:
             # Copy module file to run path.
             module_path = os.path.abspath(inspect.getfile(self.__class__))


Test patch:
diff --git a/test/contrib/spark_test.py b/test/contrib/spark_test.py
--- a/test/contrib/spark_test.py
+++ b/test/contrib/spark_test.py
@@ -97,6 +97,10 @@ def main(self, sc, *args):
         sc.textFile(self.input().path).saveAsTextFile(self.output().path)
 
 
+class MessyNamePySparkTask(TestPySparkTask):
+    name = 'AppName(a,b,c,1:2,3/4)'
+
+
 @attr('apache')
 class SparkSubmitTaskTest(unittest.TestCase):
     ss = 'ss-stub'
@@ -289,3 +293,10 @@ def mock_spark_submit(task):
 
         sc.textFile.assert_called_with('input')
         sc.textFile.return_value.saveAsTextFile.assert_called_with('output')
+
+    @patch('luigi.contrib.external_program.subprocess.Popen')
+    def test_name_cleanup(self, proc):
+        setup_run_process(proc)
+        job = MessyNamePySparkTask()
+        job.run()
+        assert 'AppName_a_b_c_1_2_3_4_' in job.run_path
Repository: spotify/luigi

Issue:
Throwing warning for deprecated `disable_window_seconds` 
Currently the `disable_window` function https://github.com/spotify/luigi/blob/92fe69e022989ebac6a5197fb8396042851e0497/luigi/task.py#L216 returns a reference to `disable_window_seconds` https://github.com/spotify/luigi/blob/92fe69e022989ebac6a5197fb8396042851e0497/luigi/task.py#L224

This function throws a warning which states that `disable_window_seconds` is deprecated stating that `disable_window` should be used.

This does not make much sense and causes errors when you treat warnings as errors :) 
Could we either remove the warning or actually implement the `disable_window` properly? 


Discussion:

Resolving patch:
diff --git a/luigi/task.py b/luigi/task.py
--- a/luigi/task.py
+++ b/luigi/task.py
@@ -218,12 +218,12 @@ def disable_window(self):
         Override this positive integer to have different ``disable_window`` at task level.
         Check :ref:`scheduler-config`
         """
-        return self.disable_window_seconds
+        return None
 
     @property
     def disable_window_seconds(self):
         warnings.warn("Use of `disable_window_seconds` has been deprecated, use `disable_window` instead", DeprecationWarning)
-        return None
+        return self.disable_window
 
     @property
     def owner_email(self):


Test patch:
diff --git a/test/task_test.py b/test/task_test.py
--- a/test/task_test.py
+++ b/test/task_test.py
@@ -152,6 +152,15 @@ class MockTimedelta:
         with self.assertWarnsRegex(UserWarning, 'Parameter "timedelta_param" with value ".*" is not of type timedelta.'):
             DummyTask(**params)
 
+    def test_disable_window_seconds(self):
+        """
+        Deprecated disable_window_seconds param uses disable_window value
+        """
+        class ATask(luigi.Task):
+            disable_window = 17
+        task = ATask()
+        self.assertEqual(task.disable_window_seconds, 17)
+
 
 class ExternalizeTaskTest(LuigiTestCase):
Repository: spotify/luigi

Issue:
Warnings when used with Python 3.10
When used with Python 3.10, I get the following warnings:

```
luigi/target.py:287: DeprecationWarning: non-integer arguments to randrange() have been deprecated since Python 3.10 and will be removed in a subsequent version

luigi/worker.py:161: DeprecationWarning: Seeding based on hashing is deprecated since Python 3.9 and will be removed in a subsequent version.
```


Discussion:
Instances of randrange found in target.py
![image](https://user-images.githubusercontent.com/43724421/157110404-6bc50311-a64f-4950-87bd-9df59afeea63.png)
![image](https://user-images.githubusercontent.com/43724421/157110491-e074c290-0bed-4716-8f2d-bea4555ef099.png)

Assuming this error is being generated due to the scientific notation being used to represent 10,000,000,000. Will test this out.
For the second warning, it appears the issue lies here:
![image](https://user-images.githubusercontent.com/43724421/157111687-fcfa3586-b6ce-4ac7-927d-4e2ff0e650eb.png)


I wrote some basic test code and was able to successfully replicate and resolve error

![image](https://user-images.githubusercontent.com/43724421/157111786-6e88a65b-c723-445d-881f-3b3aeb739d74.png)


Resolving patch:
diff --git a/luigi/target.py b/luigi/target.py
--- a/luigi/target.py
+++ b/luigi/target.py
@@ -284,7 +284,7 @@ def run(self):
                     with self.output().temporary_path() as self.temp_output_path:
                         run_some_external_command(output_path=self.temp_output_path)
         """
-        num = random.randrange(0, 1e10)
+        num = random.randrange(0, 10000000000)
         slashless_path = self.path.rstrip('/').rstrip("\\")
         _temp_path = '{}-luigi-tmp-{:010}{}'.format(
             slashless_path,
@@ -328,7 +328,7 @@ def close(self):
         self.move_to_final_destination()
 
     def generate_tmp_path(self, path):
-        return os.path.join(tempfile.gettempdir(), 'luigi-s3-tmp-%09d' % random.randrange(0, 1e10))
+        return os.path.join(tempfile.gettempdir(), 'luigi-s3-tmp-%09d' % random.randrange(0, 10000000000))
 
     def move_to_final_destination(self):
         raise NotImplementedError()
diff --git a/luigi/worker.py b/luigi/worker.py
--- a/luigi/worker.py
+++ b/luigi/worker.py
@@ -158,7 +158,9 @@ def run(self):
 
         if self.use_multiprocessing:
             # Need to have different random seeds if running in separate processes
-            random.seed((os.getpid(), time.time()))
+            processID = os.getpid()
+            currentTime = time.time()
+            random.seed((processID, currentTime))
 
         status = FAILED
         expl = ''


Test patch:
Repository: akvo/akvo-rsr

Issue:
v3 Release notes



Discussion:

Resolving patch:
diff --git a/akvo/rsr/views/organisation.py b/akvo/rsr/views/organisation.py
--- a/akvo/rsr/views/organisation.py
+++ b/akvo/rsr/views/organisation.py
@@ -11,11 +11,16 @@
 from ...utils import pagination, filter_query_string
 
 from django.shortcuts import get_object_or_404, render
+from django.template import RequestContext
 
 
 def directory(request):
     qs = remove_empty_querydict_items(request.GET)
-    f = OrganisationFilter(qs, queryset=Organisation.objects.all())
+    if request.rsr_page:
+        organisations = RequestContext(request)['projects_qs'].all_partners()
+    else:
+        organisations = Organisation.objects.all()
+    f = OrganisationFilter(qs, queryset=organisations)
 
     # Instead of true or false, adhere to bootstrap3 class names to simplify
     show_filters = "in"
diff --git a/akvo/rsr/views/project.py b/akvo/rsr/views/project.py
--- a/akvo/rsr/views/project.py
+++ b/akvo/rsr/views/project.py
@@ -12,7 +12,6 @@
 from ..filters import remove_empty_querydict_items, ProjectFilter
 from ..models import Invoice, Project, ProjectUpdate
 from ...utils import pagination, filter_query_string
-from akvo.codelists.models import SectorCategory
 
 from django.contrib.auth.decorators import login_required
 from django.core.exceptions import PermissionDenied
@@ -285,6 +284,11 @@ def set_update(request, project_id, edit_mode=False, form_class=ProjectUpdateFor
     if not project.is_published() and not request.user.has_perm('rsr.change_project', project):
         raise PermissionDenied
 
+    # Check if user is allowed to place updates for this project
+    allow_update = False
+    if request.user.has_perm('rsr.post_updates', project):
+        allow_update = True
+
     updates = project.updates_desc()[:5]
     update = None
 
@@ -313,6 +317,7 @@ def set_update(request, project_id, edit_mode=False, form_class=ProjectUpdateFor
         'update': update,
         'updateform': updateform,
         'edit_mode': edit_mode,
+        'allow_update': allow_update
     }
 
     return render(request, 'update_add.html', context)
diff --git a/akvo/rsr/views/project_update.py b/akvo/rsr/views/project_update.py
--- a/akvo/rsr/views/project_update.py
+++ b/akvo/rsr/views/project_update.py
@@ -10,11 +10,16 @@
 from ...utils import pagination, filter_query_string
 
 from django.shortcuts import get_object_or_404, render
+from django.template import RequestContext
 
 
 def directory(request):
     qs = remove_empty_querydict_items(request.GET)
-    f = ProjectUpdateFilter(qs, queryset=ProjectUpdate.objects.all())
+    if request.rsr_page:
+        updates = RequestContext(request)['projects_qs'].all_updates()
+    else:
+        updates = ProjectUpdate.objects.all()
+    f = ProjectUpdateFilter(qs, queryset=updates)
 
     show_filters = "in"
     available_filters = ['continent', 'status', 'organisation', 'focus_area', ]


Test patch:
Repository: akvo/akvo-rsr

Issue:
Minor issue - missing thumbnails for video updates on some pages
When an update contains a video, we show the thumbnail on certain screens but not others. For example the latest updates list has the thumbnail correctly displayed:

![screen shot 2015-04-14 at 13 01 34](https://cloud.githubusercontent.com/assets/3003031/7201311/b5e12412-e4fd-11e4-980d-4b8705288342.png)

However the previous updates side bar (when a user is adding a new update) does not have the thumbnail:

![screen shot 2015-04-14 at 13 01 46](https://cloud.githubusercontent.com/assets/3003031/7201327/d2a2b9d0-e4fd-11e4-9801-46c3a9a63aac.png)



Discussion:

Resolving patch:
diff --git a/akvo/rsr/templatetags/rsr_utils.py b/akvo/rsr/templatetags/rsr_utils.py
--- a/akvo/rsr/templatetags/rsr_utils.py
+++ b/akvo/rsr/templatetags/rsr_utils.py
@@ -1,10 +1,10 @@
 # -*- coding: utf-8 -*-
+"""Akvo RSR is covered by the GNU Affero General Public License.
+
+See more details in the license.txt file located at the root folder of the Akvo RSR module.
+For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
 """
-    Akvo RSR is covered by the GNU Affero General Public License.
-    See more details in the license.txt file located at the root folder of the
-    Akvo RSR module. For additional details on the GNU license please
-    see < http://www.gnu.org/licenses/agpl.html >.
-"""
+
 from __future__ import absolute_import, print_function
 
 from django import template
@@ -15,8 +15,7 @@
 
 @register.inclusion_tag('rsr_utils/img.html', takes_context=True)
 def img(context, obj, width, height, alt):
-    """Standard way to show image"""
-
+    """Standard way to show image."""
     geometry = '{}x{}'.format(width, height)
 
     # Based on type get image
@@ -40,10 +39,10 @@ def img(context, obj, width, height, alt):
             'geometry': geometry,
             'width': width}
 
+
 @register.inclusion_tag('rsr_utils/vid_img.html', takes_context=True)
 def vid_img(context, obj, width, height, alt):
-    """Standard way to show video thumbnail"""
-
+    """Standard way to show video thumbnail."""
     geometry = '{}x{}'.format(width, height)
 
     # Based on type get video


Test patch:
Repository: akvo/akvo-rsr

Issue:
Add organisation filter for maps API resources



Discussion:

Resolving patch:
diff --git a/akvo/rest/views/organisation_location.py b/akvo/rest/views/organisation_location.py
--- a/akvo/rest/views/organisation_location.py
+++ b/akvo/rest/views/organisation_location.py
@@ -22,9 +22,9 @@ class MapOrganisationLocationViewSet(BaseRSRViewSet):
     """Returns a resource tailored for generating a map of organisation locations.
 
     Allowed parameters are:
-    limit (default 100 / max 500),
-    location_target (filter on organisation ID), and
-    country (filter on country ID)
+    __limit__ (default 100 / max 500),
+    __location_target__ (filter on organisation ID), and
+    __country__ (filter on country ID)
     """
 
     filter_fields = ('location_target', 'country')
diff --git a/akvo/rest/views/project_location.py b/akvo/rest/views/project_location.py
--- a/akvo/rest/views/project_location.py
+++ b/akvo/rest/views/project_location.py
@@ -22,12 +22,17 @@ class MapProjectLocationViewSet(BaseRSRViewSet):
     """Returns a resource tailored for generating a map of project locations.
 
     Allowed parameters are:
-    limit (default 100 / max 500),
-    location_target (filter on project ID), and
-    country (filter on country ID)
+    __limit__ (default 100 / max 500),
+    __location_target__ (filter on project ID),
+    __location_target\__partners__ (filter on organisation ID), and
+    __country__ (filter on country ID)
     """
 
-    filter_fields = ('location_target', 'country')
+    filter_fields = (
+        'location_target',
+        'location_target__partners',
+        'country'
+    )
     max_paginate_by = 500
     paginate_by = 100
     queryset = ProjectLocation.objects.select_related(
diff --git a/akvo/rest/views/project_update_location.py b/akvo/rest/views/project_update_location.py
--- a/akvo/rest/views/project_update_location.py
+++ b/akvo/rest/views/project_update_location.py
@@ -23,11 +23,18 @@ class MapProjectUpdateLocationViewSet(BaseRSRViewSet):
     """Returns a resource tailored for generating a map of update locations.
 
     Allowed parameters are:
-    limit (default 100 / max 500), and
-    location_target__project (filter on project ID)
+    __limit__ (default 100 / max 500),
+    __location_target\__project__ (filter on project ID),
+    __location_target\__project\__partners__
+    (filter on organisation ID of the projects' organisations),
+    __location_target\__user\__employers__ (filter on organisation ID of the users' organisations)
     """
 
-    filter_fields = ('location_target__project', )
+    filter_fields = (
+        'location_target__project',
+        'location_target__project__partners',
+        'location_target__user__employers'
+    )
     max_paginate_by = 500
     paginate_by = 100
     queryset = ProjectUpdateLocation.objects.select_related(


Test patch:
Repository: akvo/akvo-rsr

Issue:
Unsupported operand type |
See http://sentry.support.akvo-ops.org/rsr/test/group/390/



Discussion:

Resolving patch:
diff --git a/akvo/rsr/models/project.py b/akvo/rsr/models/project.py
--- a/akvo/rsr/models/project.py
+++ b/akvo/rsr/models/project.py
@@ -562,10 +562,7 @@ def all_updates(self):
 
         #the following 6 methods return organisation querysets!
         def _partners(self, partner_type=None):
-            from ..models import Organisation
-            orgs = Organisation.objects.none()
-            for project in self:
-                orgs = orgs | project.partners
+            orgs = Organisation.objects.filter(partnerships__project__in=self)
             if partner_type:
                 orgs = orgs.filter(partnerships__partner_type=partner_type)
             return orgs.distinct()


Test patch:
Repository: akvo/akvo-rsr

Issue:
Validation on iati organisation type
This one could just be an issue with me not entering the correct information - but I've tried various combinations of organisation & iati organisation types and nothing seems to pass the validation. (note that the field is pre-populated when adding an org). This didn't seem to be an issue on the original Flying Fish cove release, not sure what's causing it.

![screen shot 2015-05-07 at 11 53 25](https://cloud.githubusercontent.com/assets/3003031/7513867/c8dc6eca-f4af-11e4-9426-00c1d1e28cfc.png)



Discussion:

Resolving patch:
diff --git a/akvo/rsr/models/organisation.py b/akvo/rsr/models/organisation.py
--- a/akvo/rsr/models/organisation.py
+++ b/akvo/rsr/models/organisation.py
@@ -95,9 +95,9 @@ def org_type_from_iati_type(cls, iati_type):
     )
     new_organisation_type = models.IntegerField(
         _(u'IATI organisation type'), db_index=True,
-        choices=codelist_choices(IATI_LIST_ORGANISATION_TYPE), default=22,
-        help_text=_(u'Check that this field is set to an organisation type that matches '
-                    u'your organisation.'),
+        choices=[(int(c[0]), c[1]) for c in codelist_choices(IATI_LIST_ORGANISATION_TYPE)],
+        default=22, help_text=_(u'Check that this field is set to an organisation type that '
+                                u'matches your organisation.'),
     )
     iati_org_id = ValidXMLCharField(
         _(u'IATI organisation ID'), max_length=75, blank=True, null=True, db_index=True, unique=True


Test patch:
Repository: akvo/akvo-rsr

Issue:
Finance info not clear 
Looking at http://rsr.akvo.org/project/2506/finance/ there are a few unclarities. 
See screenshot below. 
![screen shot 2015-05-04 at 12 12 31](https://cloud.githubusercontent.com/assets/4179989/7451921/ea2affa2-f256-11e4-8c4c-5d7999f34537.png)
- The project budget is 6600. It says funds needed 3511.23. It is not clear who funded the 3088.77. 
- Curren funder is Wilde Ganzen. But what is the amount? 
- The donations at this moment are a total of 2498.77. But is this money part of the 3088.77 funded?
- What is the total amount of the project that needs to be still funded? 3511,23? Or 3511,23 minus 2498,77?
## Test plan

GIVEN the financial information page of a project
WHEN viewing the 'Funded' part under the 'Project funding' header
THEN this should be the sum of the amount(s) of the funding partner(s) and the donations

GIVEN a project with pending donations and an incorrect amount of 'Funded'
WHEN a partnership is edited (that re-calculates the funds)
THEN the 'Funded' part should state the correct amount



Discussion:

Resolving patch:
diff --git a/akvo/rsr/models/project.py b/akvo/rsr/models/project.py
--- a/akvo/rsr/models/project.py
+++ b/akvo/rsr/models/project.py
@@ -384,8 +384,8 @@ def get_pledged(self):
         ).aggregate(Sum('funding_amount'))['funding_amount__sum'] or 0
 
     def get_funds(self):
-        """ All money given to a project, including pending donations"""
-        return self.get_donations() + self.get_pending_donations() + self.get_pledged()
+        """ All money given to a project"""
+        return self.get_donations() + self.get_pledged()
 
     def update_funds(self):
         "Update de-normalized field"


Test patch:
Repository: akvo/akvo-rsr

Issue:
Add content_owner to organisation REST API filters



Discussion:

Resolving patch:
diff --git a/akvo/rest/views/organisation.py b/akvo/rest/views/organisation.py
--- a/akvo/rest/views/organisation.py
+++ b/akvo/rest/views/organisation.py
@@ -70,7 +70,7 @@ class OrganisationViewSet(BaseRSRViewSet):
     queryset = Organisation.objects.all()
     serializer_class = OrganisationSerializer
     parser_classes = (AkvoOrganisationParser, JSONParser,)
-    filter_fields = ('name', 'long_name', 'iati_org_id', )
+    filter_fields = ('name', 'long_name', 'iati_org_id', 'content_owner')
 
     def get_queryset(self):
         """ Enable filtering of Organisations on iati_org_id or name


Test patch: