internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: medtagger/MedTagger

Issue:
Scans with low number of Slices are not properly loaded on Labeling page
## Current Behavior

When Scan has less than 10 Slices, Scan Viewer keeps displaying spinner indicator and never gets to displaying actual Scan.

## Expected Behavior

Scan should be displayed properly, no matter how many Slices it has.

## Steps to Reproduce the Problem

  1. Upload less than 10 Slices.
  2. Go to Labelling page.
  3. Voi'la, Scan is not displayed, instead you're presented with spinner indicator that doesn't dissapear.

## Additional comment (optional)

Reason for that happening is that `SLICE_BATCH_SIZE` (`validation-page.component.ts`, Line 23) is fixed to 10. When we upload Scan that has less than `SLICE_BATCH_SIZE` slices, method `slice.isLastInBatch()` (`marker-page.component.ts`, Line 101) will always return `false`, because it will never hit slice with id = 9 (because there isn't one...). Therefore, Slice download will never be marked as completed.



Discussion:

Resolving patch:
diff --git a/backend/medtagger/api/scans/service_web_socket.py b/backend/medtagger/api/scans/service_web_socket.py
--- a/backend/medtagger/api/scans/service_web_socket.py
+++ b/backend/medtagger/api/scans/service_web_socket.py
@@ -26,10 +26,10 @@ def on_request_slices(self, request: Dict) -> None:
         self._raise_on_invalid_request_slices(count, orientation)
 
         orientation = SliceOrientation[orientation]
-        slices = business.get_slices_for_scan(scan_id, begin, count, orientation=orientation)
-        slices_to_send = reversed(list(enumerate(slices))) if reversed_order else enumerate(slices)
-        last_in_batch = begin if reversed_order else begin + count - 1
-        for index, (_slice, image) in slices_to_send:
+        slices = list(business.get_slices_for_scan(scan_id, begin, count, orientation=orientation))
+        slices_to_send = list(reversed(slices)) if reversed_order else slices
+        last_in_batch = begin if reversed_order else begin + len(slices_to_send) - 1
+        for index, (_slice, image) in enumerate(slices_to_send):
             emit('slice', {
                 'scan_id': scan_id,
                 'index': begin + index,


Test patch:
Repository: medtagger/MedTagger

Issue:
Sending Label with Brush Selection doesn't work 
## Current Behavior

Sending Label with Brush Selection doesn't work.

## Expected Behavior

Label with Brush Selection should be sent correctly.

## Steps to Reproduce the Problem

  1. Go to labeling page and use Brush Tool
  2. Send label
  3. "Can't send scan" appeared




Discussion:

Resolving patch:
diff --git a/backend/medtagger/api/scans/business.py b/backend/medtagger/api/scans/business.py
--- a/backend/medtagger/api/scans/business.py
+++ b/backend/medtagger/api/scans/business.py
@@ -110,8 +110,8 @@ def validate_label_payload(elements: List[Dict], files: Dict[str, bytes]) -> Non
     :param elements: List of JSONs describing elements for a single label
     :param files: mapping of uploaded files (name and content)
     """
-    _validate_files(files)
     _validate_label_elements(elements, files)
+    _validate_files(files)
     _validate_tool(elements)
 
 


Test patch:
Repository: medtagger/MedTagger

Issue:
Getting random scan for non-existing task key results in 500
## Current Behavior

Providing non existing task key results in 500 HTTP code.

## Expected Behavior

Backend should handle this situation appropriate and return 404 HTTP code.

## Steps to Reproduce the Problem

  1. Perform a GET `scans/random?task=<task_key>` and provide non existing key.



Discussion:

Resolving patch:
diff --git a/backend/medtagger/repositories/tasks.py b/backend/medtagger/repositories/tasks.py
--- a/backend/medtagger/repositories/tasks.py
+++ b/backend/medtagger/repositories/tasks.py
@@ -21,7 +21,7 @@ def get_task_by_key(key: str) -> Task:
     :return: Task object
     """
     with db_session() as session:
-        task = session.query(Task).filter(Task.key == key).one()
+        task = session.query(Task).filter(Task.key == key).first()
     return task
 
 


Test patch:
Repository: medtagger/MedTagger

Issue:
Bump Python to 3.7.0
## Expected Behavior

MedTagger should always use the latest version of Python technologies and follow the rabbit instead of leaving technical dept :)

## Actual Behavior

We've got Python 3.6.x right now.

## Additional comment

Remember about Makefiles, Dockerfiles, TravisCI and more(?).

**WATCH OUT!** It's relatively new. Some of our dependencies may not work properly! Find out if `numpy` and other libs supports it!

**BLOCKED BY:**
- [SimpleITK](https://github.com/SimpleITK/SimpleITK/releases) - next release (>1.1.0) will be fine to use with Python3.7.


Discussion:

Resolving patch:
diff --git a/backend/scripts/convert_dicoms_to_png.py b/backend/scripts/convert_dicoms_to_png.py
--- a/backend/scripts/convert_dicoms_to_png.py
+++ b/backend/scripts/convert_dicoms_to_png.py
@@ -7,7 +7,7 @@
 
 Then, place these data (unzipped) anywhere on your computer and run this script by:
 
-    (venv) $ python3.6 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/
+    (venv) $ python3.7 scripts/dicoms_to_png.py --input=./dir_with_scans/ --output=./dir_with_scans/converted/
 
 Name of the converted Dicom file is a position of the scan on the z axis.
 """
diff --git a/backend/scripts/import_data.py b/backend/scripts/import_data.py
--- a/backend/scripts/import_data.py
+++ b/backend/scripts/import_data.py
@@ -7,7 +7,7 @@
 
 Then, place these data (unzipped) anywhere on your computer and run this script by:
 
-    (venv) $ python3.6 scripts/import_data.py --source=./dir_with_scans/
+    (venv) $ python3.7 scripts/import_data.py --source=./dir_with_scans/
 
 Please keep all scans with given structure:
 


Test patch:
Repository: medtagger/MedTagger

Issue:
Add information about Dataset to Tasks endpoint
## Current Behavior

Tasks endpoint returns list of all Tasks **without** information about their Datasets.

## Expected Behavior

Each Task returned by this endpoint should also contain information about its Dataset.

## Tasks to do

- [ ] Add Dataset key to the Task returned by Tasks endpoint.

## Additional comment

Dataset key will be fine only if there will be an endpoint that will return all Datasets available in MedTagger.


Discussion:

Resolving patch:
diff --git a/backend/medtagger/api/tasks/serializers.py b/backend/medtagger/api/tasks/serializers.py
--- a/backend/medtagger/api/tasks/serializers.py
+++ b/backend/medtagger/api/tasks/serializers.py
@@ -27,6 +27,7 @@
     'name': fields.String(),
     'image_path': fields.String(),
     'tags': fields.List(fields.Nested(out__label_tag), attribute='available_tags'),
+    'datasets_keys': fields.List(fields.String(), attribute=lambda task: [dataset.key for dataset in task.datasets]),
 })
 
 in__task = api.model('New Task model', {


Test patch:
diff --git a/backend/tests/functional_tests/test_tasks.py b/backend/tests/functional_tests/test_tasks.py
--- a/backend/tests/functional_tests/test_tasks.py
+++ b/backend/tests/functional_tests/test_tasks.py
@@ -42,6 +42,7 @@ def test_add_task(prepare_environment: Any) -> None:
     assert json_response['name'] == 'Mark nodules'
     assert json_response['image_path'] == 'assets/icon/my_icon.svg'
     assert len(json_response['tags']) == 2
+    assert len(json_response['datasets_keys']) == 2
 
     # Step 3. Check for available Datasets through the REST API
     response = api_client.get('/api/v1/scans/datasets', headers=get_headers(token=user_token, json=True))
Repository: medtagger/MedTagger

Issue:
Enable E2E tests automation on Travis CI
## Current Behavior

We've got E2E tests but they can only be run on a local setup.

## Expected Behavior

E2E tests should run after each commit merge to master and on schedule (eg. each day at midnight).

## Tasks to do

- [ ] Prepare separate Docker-Compose configuration for E2E Tests
- [ ] Automate setup and tests in similar fashion that it is currently done in Backend functional tests
- [ ] Add E2E Tests to Travis CI configuration
- [ ] Update documentation for testing



Discussion:

Resolving patch:
diff --git a/backend/scripts/sync_configuration.py b/backend/scripts/sync_configuration.py
--- a/backend/scripts/sync_configuration.py
+++ b/backend/scripts/sync_configuration.py
@@ -1,4 +1,5 @@
 """Script for MedTagger's configuration synchronization."""
+import argparse
 import logging.config
 from typing import Dict
 
@@ -17,7 +18,7 @@
 logging.config.fileConfig('logging.conf')
 logger = logging.getLogger(__name__)
 
-CONFIGURATION_FILE_NAME = '.medtagger.yml'
+DEFAULT_CONFIGURATION_FILE_NAME = '.medtagger.yml'
 
 
 def sync_configuration(configuration: Dict) -> None:
@@ -178,8 +179,12 @@ def _add_label_tag(tag: Dict, db_task_id: TaskID) -> None:
 
 def run() -> None:
     """Entry point for this script."""
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--configuration', type=str, default=DEFAULT_CONFIGURATION_FILE_NAME)
+    arguments = parser.parse_args()
+
     try:
-        with open(CONFIGURATION_FILE_NAME) as config_file:
+        with open(arguments.configuration) as config_file:
             configuration = yaml.load(config_file)
             sync_configuration(configuration)
     except yaml.YAMLError:


Test patch:
diff --git a/.travis/run_tests_if_subproject_changed.py b/.travis/run_tests_if_subproject_changed.py
--- a/.travis/run_tests_if_subproject_changed.py
+++ b/.travis/run_tests_if_subproject_changed.py
@@ -19,6 +19,7 @@
 def get_root_dir(path):
     return os.path.dirname(path).split('/')[0]
 
+
 def run(command):
     logging.info('Let\'s run the CI!')
     p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
@@ -32,6 +33,7 @@ def run(command):
     return_code = p.wait()
     exit(return_code)
 
+
 def do_not_run():
     logging.info('This subproject does not contain changes.')
     exit(0)
Repository: medtagger/MedTagger

Issue:
Check for sent Label in E2E Tests
## Current Behavior

There are no checks on Labels sent to REST API.

## Expected Behavior

E2E Tests should also check if Label on the backend side was properly created.


Discussion:

Resolving patch:
diff --git a/backend/medtagger/api/exceptions.py b/backend/medtagger/api/exceptions.py
--- a/backend/medtagger/api/exceptions.py
+++ b/backend/medtagger/api/exceptions.py
@@ -5,28 +5,28 @@
 class BaseHTTPException(MedTaggerException):
     """Base class for all HTTP Exceptions."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
 
 
 class UnauthorizedException(BaseHTTPException):
     """Exception designed to use once there was an authorization error during business logic processing."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
 
 
 class NotFoundException(BaseHTTPException):
     """Exception designed to use while the object that user was looking for could not be found."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
 
 
 class InvalidArgumentsException(BaseHTTPException):
     """Exception designed to use with invalid arguments (400 status code)."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
 
 
 class AccessForbiddenException(BaseHTTPException):
     """Exception designed to use while the user does not have a privilege to perform action."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
diff --git a/backend/medtagger/config.py b/backend/medtagger/config.py
--- a/backend/medtagger/config.py
+++ b/backend/medtagger/config.py
@@ -6,10 +6,6 @@
 class AppConfiguration:
     """Class that represents application configuration."""
 
-    def __init__(self) -> None:
-        """Initialize application configuration."""
-        pass
-
     @staticmethod
     def get(namespace: str, key: str, fallback: Any = None) -> Any:
         """Return value of a given configuration entry.
diff --git a/backend/medtagger/exceptions.py b/backend/medtagger/exceptions.py
--- a/backend/medtagger/exceptions.py
+++ b/backend/medtagger/exceptions.py
@@ -4,22 +4,22 @@
 class MedTaggerException(Exception):
     """Base class for all HTTP Exceptions."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
 
 
 class UnsupportedActionException(MedTaggerException):
     """Exception for unsupported Action."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
 
 
 class InvalidResponseException(MedTaggerException):
     """Exception for invalid Response."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass
 
 
 class InternalErrorException(MedTaggerException):
     """Exception designed to use to indicate internal errors (like DB/Storage error)."""
 
-    pass
+    pass  # pylint: disable=unnecessary-pass


Test patch:
Repository: fedora-infra/bodhi

Issue:
Warn if maintainers are about to step on eachothers toes
I discussed this idea with Richard Hughes at Flock today.

If a package gets submitted as an update when there is already a different build of it in testing _and_ the submitters are different, then we should display a warning.



Discussion:

Resolving patch:
diff --git a/bodhi/models/models.py b/bodhi/models/models.py
--- a/bodhi/models/models.py
+++ b/bodhi/models/models.py
@@ -744,6 +744,10 @@ def obsolete_older_updates(self, request):
                 # Ensure the same number of builds are present
                 if len(oldBuild.update.builds) != len(self.builds):
                     obsoletable = False
+                    if oldBuild.update.submitter.name != self.user.name:
+                        request.session.flash('Please be aware that %s is'
+                                'part of a multi-build update that is currently '
+                                'in testing' % oldBuild.nvr)
                     break
 
                 # Ensure that all of the packages in the old update are


Test patch:
diff --git a/bodhi/tests/functional/test_updates.py b/bodhi/tests/functional/test_updates.py
--- a/bodhi/tests/functional/test_updates.py
+++ b/bodhi/tests/functional/test_updates.py
@@ -1185,3 +1185,34 @@ def test_new_update_with_existing_build(self):
         resp = self.app.post_json('/updates/', args)
 
         eq_(resp.json['title'], 'bodhi-2.0.0-3.fc17')
+
+    def test_update_with_older_build_in_testing_from_different_submitter(self):
+        """
+        Test submitting an update for a package that has an older build within
+        a multi-build update currently in testing submitted by a different
+        maintainer.
+
+        https://github.com/fedora-infra/bodhi/issues/78
+        """
+        session = DBSession()
+        title = u'bodhi-2.0-2.fc17 python-3.0-1.fc17'
+        args = self.get_update(title)
+        resp = self.app.post_json('/updates/', args)
+        newuser = User(name=u'bob')
+        session.add(newuser)
+        up = session.query(Update).filter_by(title=title).one()
+        up.status = UpdateStatus.testing
+        up.request = None
+        up.submitter = newuser
+        session.flush()
+
+        newtitle = u'bodhi-2.0-3.fc17'
+        args = self.get_update(newtitle)
+        resp = self.app.post_json('/updates/', args)
+
+        # The TestResponse doesn't track the session, so we can't peek at the
+        # flash messages. So, let's just make sure the session cookie was set.
+        assert resp.headers['Set-Cookie'].startswith('session='), resp.headers
+
+        # Ensure the second update was created successfully
+        session.query(Update).filter_by(title=newtitle).one()
Repository: fedora-infra/bodhi

Issue:
Fix bodhi1 for EPEL-7
There are a bunch of places in the master branch that look to see if the `Release.name.startswith('EL')`, and also assumes the tag will be `el%d`.



Discussion:

Resolving patch:
diff --git a/bodhi/masher.py b/bodhi/masher.py
--- a/bodhi/masher.py
+++ b/bodhi/masher.py
@@ -571,7 +571,10 @@ def update_symlinks(self):
             log.debug("Running sanity checks on %s" % newrepo)
 
             # make sure the new repository has our arches
-            for arch in config.get('arches').split():
+            expected_arches = config.get('%s_arches' % repo,
+                                         config.get('arches'))
+
+            for arch in expected_arches:
                 if '/' in arch:  # 'ppc/ppc64'
                     one, other = arch.split('/')
                     if one not in arches and other not in arches:
@@ -952,14 +955,10 @@ def generate_updateinfo(self):
         for repo, mashdir in self.mashed_repos.items():
             # File name is prefixed with a hash, use a glob to find it
             olduinfos = glob.glob(os.path.join(config.get('mashed_dir'),
-                                               '%s.repodata' % repo, 'i386',
+                                               '%s.repodata' % repo, '*',
                                                "*updateinfo.xml.gz"))
 
-            if len(olduinfos) > 1:
-                # TODO: Shouldn't that be an error?
-                olduinfo = olduinfos[0]
-
-            if len(olduinfos) == 1:
+            if len(olduinfos) >= 1:
                 olduinfo = olduinfos[0]
 
             else:


Test patch:
Repository: fedora-infra/bodhi

Issue:
Fix mirror polling bug with recent EPEL push
The EPEL masher is currently spinning, unable to find the repodata with the proper hash.



Discussion:

Resolving patch:
diff --git a/bodhi/masher.py b/bodhi/masher.py
--- a/bodhi/masher.py
+++ b/bodhi/masher.py
@@ -932,7 +932,7 @@ def wait_for_sync(self):
         while True:
             sleep(600)
             try:
-                masterrepomd = urllib2.urlopen(master_repomd % release.get_version())
+                masterrepomd = urllib2.urlopen(master_repomd % (release.get_version(), arch))
             except urllib2.URLError, e:
                 log.error("Error fetching repomd.xml: %s" % str(e))
                 continue


Test patch:
Repository: fedora-infra/bodhi

Issue:
Traceback when loading pickled db
I hit this error when trying to import the currently posted pickledb.  This could pose a problem when we try to migrate staging and ultimately production, so marking as 'critical'.

```
$ PYTHONPATH=$(pwd) python tools/pickledb.py migrate bodhi-pickledb*

No handlers could be found for logger "bodhi.buildsys"

Loading pickled database bodhi-pickledb-130801.1918-F17-EOL
WARNING:fedmsg.crypto.x509:Crypto disabled ImportError('No module named M2Crypto',)
Traceback (most recent call last):
  File "tools/pickledb.py", line 446, in <module>
    main()
  File "tools/pickledb.py", line 441, in main
    load_sqlalchemy_db()
  File "tools/pickledb.py", line 214, in load_sqlalchemy_db
    r = Release(**release)
  File "<string>", line 4, in __init__
  File "/home/threebean/.virtualenvs/bodhi-python2.7/lib/python2.7/site-packages/SQLAlchemy-0.9.8-py2.7-linux-x86_64.egg/sqlalchemy/orm/state.py", line 260, in _initialize_instance
    return manager.original_init(*mixed[1:], **kwargs)
  File "/home/threebean/.virtualenvs/bodhi-python2.7/lib/python2.7/site-packages/SQLAlchemy-0.9.8-py2.7-linux-x86_64.egg/sqlalchemy/ext/declarative/base.py", line 525, in _declarative_constructor
    (k, cls_.__name__))
TypeError: 'locked' is an invalid keyword argument for Release
```



Discussion:

Resolving patch:
diff --git a/tools/pickledb.py b/tools/pickledb.py
--- a/tools/pickledb.py
+++ b/tools/pickledb.py
@@ -211,7 +211,14 @@ def load_sqlalchemy_db():
                 db.query(Release).filter_by(name=release['name']).one()
             except NoResultFound:
                 del(release['metrics'])
+                del(release['locked'])
                 r = Release(**release)
+                r.stable_tag = "%s-updates" % r.dist_tag
+                r.testing_tag = "%s-testing" % r.stable_tag
+                r.candidate_tag = "%s-candidate" % r.stable_tag
+                r.pending_testing_tag = "%s-pending" % r.testing_tag
+                r.pending_stable_tag = "%s-pending" % r.stable_tag
+                r.override_tag = "%s-override" % r.dist_tag
                 db.add(r)
         data = data['updates']
 


Test patch:
Repository: fedora-infra/bodhi

Issue:
Port style & templates
Bodhi's current theme is written using Kid, and uses a very old fedora style that no other apps use anymore.

I'm leaning towards a fresh start with https://github.com/ralphbean/bootstrap-fedora



Discussion:
@ralphbean commited a bootstrap-fedora based theme in 4e65a9583faef68cd9fd1212648494a2269f905e :dragon_face: 


Resolving patch:
diff --git a/bodhi/validators.py b/bodhi/validators.py
--- a/bodhi/validators.py
+++ b/bodhi/validators.py
@@ -12,7 +12,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-from datetime import datetime
+from datetime import datetime, timedelta
 
 from sqlalchemy.sql import or_
 from pyramid.exceptions import HTTPNotFound, HTTPBadRequest
@@ -643,7 +643,16 @@ def validate_expiration_date(request):
     now = datetime.utcnow()
 
     if expiration_date <= now:
-        request.errors.add('body', 'nvr', 'Expiration date in the past')
+        request.errors.add('body', 'expiration_date',
+                           'Expiration date in the past')
+        return
+
+    settings = request.registry.settings
+    days = int(settings.get('buildroot_limit', 31))
+    limit = now + timedelta(days=days)
+    if expiration_date > limit:
+        request.errors.add('body', 'expiration_date',
+                           'Expiration date may not be longer than %i' % days)
         return
 
     request.validated['expiration_date'] = expiration_date


Test patch:
diff --git a/bodhi/tests/functional/test_overrides.py b/bodhi/tests/functional/test_overrides.py
--- a/bodhi/tests/functional/test_overrides.py
+++ b/bodhi/tests/functional/test_overrides.py
@@ -207,6 +207,26 @@ def test_create_override(self, publish):
                           expiration_date.strftime("%Y-%m-%d %H:%M:%S"))
         self.assertEquals(o['expired_date'], None)
 
+    @mock.patch('bodhi.notifications.publish')
+    def test_create_override_too_long(self, publish):
+        session = DBSession()
+
+        release = Release.get(u'F17', session)
+
+        package = Package(name=u'not-bodhi')
+        session.add(package)
+        build = Build(nvr=u'not-bodhi-2.0-2.fc17', package=package,
+                      release=release)
+        session.add(build)
+        session.flush()
+
+        expiration_date = datetime.utcnow() + timedelta(days=60)
+
+        data = {'nvr': build.nvr, 'notes': u'blah blah blah',
+                'expiration_date': expiration_date,
+                'csrf_token': self.get_csrf_token()}
+        self.app.post('/overrides/', data, status=400)
+
     @mock.patch('bodhi.notifications.publish')
     def test_create_override_for_newer_build(self, publish):
         session = DBSession()
Repository: fedora-infra/bodhi

Issue:
Test suite errors when building on koji
https://kojipkgs.fedoraproject.org//work/tasks/8507/9488507/build.log

```
fedmsg: ERROR: Exception in MasherThread(f17-updates-testing)
Traceback (most recent call last):
  File "/builddir/build/BUILD/bodhi-2.0/bodhi/masher.py", line 265, in work
    self.send_notifications()
  File "/builddir/build/BUILD/bodhi-2.0/bodhi/masher.py", line 635, in send_notifications
    agent=os.getlogin(),  # Should almost always be "masher"
OSError: [Errno 25] Inappropriate ioctl for device
```



Discussion:

Resolving patch:
diff --git a/bodhi/masher.py b/bodhi/masher.py
--- a/bodhi/masher.py
+++ b/bodhi/masher.py
@@ -628,11 +628,14 @@ def wait_for_sync(self):
 
     def send_notifications(self):
         self.log.info('Sending notifications')
+        try:
+            agent = os.getlogin()
+        except OSError:  # this can happen when building on koji
+            agent = u'masher'
         for update in self.updates:
             topic = u'update.complete.%s' % update.status
             notifications.publish(topic=topic, msg=dict(
-                update=update,
-                agent=os.getlogin(),  # Should almost always be "masher"
+                update=update, agent=agent,
             ))
 
     def modify_bugs(self):


Test patch: