internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: scalableminds/webknossos-libs

Issue:
Webknossos CLI download annotation
## Context
- Affected library: webknossos
When using the webknossos CLI to download an annotation, the download command is overloaded to take care of dataset downloads and annotation downloads. An annotation should be downloaded when no dataset is found. This is triggered by an AssertionError. Currently no assertion is thrown. Instead, an UnexpectedStatusError is raised.

## Expected Behavior
When a URL to an Annotation is given, the Annotation should be downloaded.




Discussion:

Resolving patch:
diff --git a/webknossos/webknossos/cli/download.py b/webknossos/webknossos/cli/download.py
--- a/webknossos/webknossos/cli/download.py
+++ b/webknossos/webknossos/cli/download.py
@@ -1,13 +1,15 @@
 """This module takes care of downloading WEBKNOSSOS datasets."""
 
+import re
 from typing import Any, List, Optional
 
 import typer
 from typing_extensions import Annotated
 
-from ..annotation import Annotation
+from ..annotation.annotation import _ANNOTATION_URL_REGEX, Annotation
 from ..client import webknossos_context
-from ..dataset import Dataset
+from ..client._resolve_short_link import resolve_short_link
+from ..dataset.dataset import _DATASET_URL_REGEX, Dataset
 from ..geometry import BoundingBox, Mag
 from ._utils import parse_bbox, parse_mag, parse_path
 
@@ -72,9 +74,10 @@ def main(
 
     layers = layer if layer else None
     mags = mag if mag else None
+    url = resolve_short_link(url)
 
     with webknossos_context(token=token):
-        try:
+        if re.match(_DATASET_URL_REGEX, url):
             Dataset.download(
                 dataset_name_or_url=url,
                 path=target,
@@ -82,5 +85,13 @@ def main(
                 layers=layers,
                 mags=mags,
             )
-        except AssertionError:
+        elif re.match(_ANNOTATION_URL_REGEX, url):
             Annotation.download(annotation_id_or_url=url).save(target)
+        else:
+            raise RuntimeError(
+                "The provided URL does not lead to a dataset or annotation."
+            )
+
+
+if __name__ == "__main__":
+    typer.run(main)


Test patch:
Repository: scalableminds/webknossos-libs

Issue:
Support IMS images in Dataset.from_images
Should probably be supported by bioformats (?)

compare https://scm.slack.com/archives/C5AKLAV0B/p1689600583314559?thread_ts=1689579012.878959&cid=C5AKLAV0B


Discussion:

Resolving patch:
diff --git a/webknossos/webknossos/dataset/_utils/pims_images.py b/webknossos/webknossos/dataset/_utils/pims_images.py
--- a/webknossos/webknossos/dataset/_utils/pims_images.py
+++ b/webknossos/webknossos/dataset/_utils/pims_images.py
@@ -699,26 +699,27 @@ def get_valid_pims_suffixes() -> Set[str]:
 def get_valid_bioformats_suffixes() -> Set[str]:
     # Added the most present suffixes that are implemented in bioformats
     return {
+        "btf",
         "dcm",
         "dicom",
+        "gif",
         "ics",
         "ids",
+        "ims",
         "lei",
-        "tif",
         "lif",
-        "stk",
         "nd",
         "nd2",
+        "nii",
         "png",
-        "tiff",
+        "pic",
+        "stk",
         "tf2",
         "tf8",
-        "btf",
-        "pic",
+        "tif",
+        "tiff",
         "raw",
         "xml",
-        "gif",
-        "nii",
     }
 
 


Test patch:
Repository: scalableminds/webknossos-libs

Issue:
Suffixes with capital letters should be valid too
## Context
- Some image files have suffixes written in capital letters. As they are case-sensitive compared against a list of allowed suffixes, conversion sometimes fails.

## Expected Behavior
- e.g. `.DCM` should be as valid as `.dcm`



Discussion:

Resolving patch:
diff --git a/webknossos/webknossos/dataset/dataset.py b/webknossos/webknossos/dataset/dataset.py
--- a/webknossos/webknossos/dataset/dataset.py
+++ b/webknossos/webknossos/dataset/dataset.py
@@ -624,7 +624,7 @@ def from_images(
         input_files = [
             i.relative_to(input_upath)
             for i in input_upath.glob("**/*")
-            if i.is_file() and i.suffix.lstrip(".") in valid_suffixes
+            if i.is_file() and i.suffix.lstrip(".").lower() in valid_suffixes
         ]
         if len(input_files) == 0:
             raise ValueError(


Test patch:
Repository: Flexget/Flexget

Issue:
Can't log in into myepisodes
When usin the myepisodes plugin you get the warning "Login to myepisodes.com failed, please check your account data or see if the site is down."
It seems that they have changed so you have to access their site with www.myepisodes.com. 

I made a copy of the plugin and changed all the urls to www.myepisodes.com and it worked



Discussion:

Resolving patch:
diff --git a/flexget/plugins/services/myepisodes.py b/flexget/plugins/services/myepisodes.py
--- a/flexget/plugins/services/myepisodes.py
+++ b/flexget/plugins/services/myepisodes.py
@@ -97,7 +97,7 @@ def on_task_exit(self, task, config):
 
         cookiejar = cookielib.CookieJar()
         opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
-        baseurl = urllib2.Request('http://myepisodes.com/login.php?')
+        baseurl = urllib2.Request('http://www.myepisodes.com/login.php?')
         loginparams = urllib.urlencode({'username': username,
                                         'password': password,
                                         'action': 'Login'})
@@ -156,7 +156,7 @@ def lookup_myepisodes_id(self, entry, opener, session):
                 log.warning('Unable to lookup series `%s` from tvdb, using raw name.' % series_name)
                 query_name = series_name
 
-        baseurl = urllib2.Request('http://myepisodes.com/search.php?')
+        baseurl = urllib2.Request('http://www.myepisodes.com/search.php?')
         params = urllib.urlencode({'tvshow': query_name, 'action': 'Search myepisodes.com'})
         try:
             con = opener.open(baseurl, params)
@@ -205,7 +205,7 @@ def mark_episode(self, task, entry, opener):
             log.info('Would mark %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))
         else:
             baseurl2 = urllib2.Request(
-                'http://myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %
+                'http://www.myepisodes.com/myshows.php?action=Update&showid=%s&season=%s&episode=%s&seen=0' %
                 (myepisodes_id, season, episode))
             opener.open(baseurl2)
             log.info('Marked %s of `%s` as acquired.' % (entry['series_id'], entry['series_name']))


Test patch:
Repository: Flexget/Flexget

Issue:
Switch to GitHub Actions for CI
### Motivation for changes:
Try out github actions as a replacement for circleci
Hopefully we don't need to maintain custom docker images this way

#### To Do:

- [ ] Get it working
- [ ] Verify we like it better than circleci
- [ ] Add a release workflow



Discussion:

Resolving patch:
diff --git a/flexget/plugins/output/pyload.py b/flexget/plugins/output/pyload.py
--- a/flexget/plugins/output/pyload.py
+++ b/flexget/plugins/output/pyload.py
@@ -97,7 +97,6 @@ def add_entries(self, task, config):
 
         api = config.get('api', self.DEFAULT_API)
         hoster = config.get('hoster', self.DEFAULT_HOSTER)
-        folder = config.get('folder', self.DEFAULT_FOLDER)
 
         for entry in task.accepted:
             # bunch of urls now going to check
@@ -145,7 +144,7 @@ def add_entries(self, task, config):
             try:
                 dest = 1 if config.get('queue', self.DEFAULT_QUEUE) else 0  # Destination.Queue = 1
 
-                # Use the title of the enty, if no naming schema for the package is defined.
+                # Use the title of the entry, if no naming schema for the package is defined.
                 name = config.get('package', entry['title'])
 
                 # If name has jinja template, render it
@@ -163,9 +162,18 @@ def add_entries(self, task, config):
                 pid = query_api(api, "addPackage", post).text
                 log.debug('added package pid: %s' % pid)
 
+                # Set Folder
+                folder = config.get('folder', self.DEFAULT_FOLDER)
+                folder = entry.get('path', folder)
                 if folder:
+                    # If folder has jinja template, render it
+                    try:
+                        folder = entry.render(folder)
+                    except RenderError as e:
+                        folder = self.DEFAULT_FOLDER
+                        log.error('Error rendering jinja event: %s' % e)
                     # set folder with api
-                    data = {'folder': folder}
+                    data = json.dumps({'folder': folder})
                     query_api(api, "setPackageData", {'pid': pid, 'data': data, 'session': session})
 
             except Exception as e:


Test patch:
Repository: Flexget/Flexget

Issue:
[add] jinja split: Adds split into jinja filters
Sorry about this, I found the solution


Discussion:

Resolving patch:
diff --git a/flexget/plugins/input/trakt_emit.py b/flexget/plugins/input/trakt_emit.py
--- a/flexget/plugins/input/trakt_emit.py
+++ b/flexget/plugins/input/trakt_emit.py
@@ -1,5 +1,4 @@
 from __future__ import unicode_literals, division, absolute_import
-import hashlib
 import logging
 from urlparse import urljoin
 
@@ -8,7 +7,6 @@
 from flexget import plugin
 from flexget.entry import Entry
 from flexget.event import event
-from flexget.utils import json
 from flexget.utils.trakt import API_URL, get_session, make_list_slug, get_api_url
 
 log = logging.getLogger('trakt_emit')
@@ -103,6 +101,12 @@ def on_task_input(self, task, config):
                             else:
                                 epn += 1
                         break
+                else:
+                  if config['position'] == 'next':
+                    eps = epn = 1
+                  else:
+                    # There were no watched/collected episodes, nothing to emit in 'last' mode
+                    continue
             if eps and epn:
                 entry = self.make_entry(fields, eps, epn)
                 entries.append(entry)


Test patch:
Repository: Flexget/Flexget

Issue:
Put requirements one per line in pavement.py
It's impossible (tedious) to track why and when a certain requirement exception has been added to pavement. They should be listed one per line so a simple git blame would tell who added the line and when.



Discussion:

Resolving patch:
diff --git a/pavement.py b/pavement.py
--- a/pavement.py
+++ b/pavement.py
@@ -27,13 +27,35 @@
 # There is a bug in beautifulsoup 4.2.0 that breaks imdb parsing, see http://flexget.com/ticket/2091
 # There is a bug in requests 2.4.0 where it leaks urllib3 exceptions
 install_requires = [
-    'FeedParser>=5.2.1', 'SQLAlchemy >=0.7.5, !=0.9.0, <1.999', 'PyYAML',
-    'beautifulsoup4>=4.1, !=4.2.0, <4.4', 'html5lib>=0.11', 'PyRSS2Gen', 'pynzb', 'progressbar', 'rpyc',
-    'jinja2', 'requests>=1.0, !=2.4.0, <2.99', 'python-dateutil!=2.0, !=2.2', 'jsonschema>=2.0',
-    'tmdb3', 'path.py', 'guessit>=0.9.3, <0.10.4', 'apscheduler',
-    'flask>=0.7', 'flask-restful>=0.3.3', 'ordereddict>=1.1', 'flask-restplus==0.7.2', 'cherrypy>=3.7.0',
-    'flask-assets>=0.11', 'cssmin>=0.2.0', 'flask-compress>=1.2.1', 'flask-login>=0.3.2', 'pyparsing>=2.0.3',
-    'pyScss>=1.3.4', 'pytvmaze>=1.4.0'
+    'FeedParser>=5.2.1',
+    'SQLAlchemy >=0.7.5, !=0.9.0, <1.999',
+    'PyYAML',
+    'beautifulsoup4>=4.1, !=4.2.0, <4.4',
+    'html5lib>=0.11',
+    'PyRSS2Gen',
+    'pynzb',
+    'progressbar',
+    'rpyc',
+    'jinja2',
+    'requests>=1.0, !=2.4.0, <2.99',
+    'python-dateutil!=2.0, !=2.2',
+    'jsonschema>=2.0',
+    'tmdb3',
+    'path.py',
+    'guessit>=0.9.3, <0.10.4',
+    'apscheduler',
+    'flask>=0.7',
+    'flask-restful>=0.3.3',
+    'ordereddict>=1.1',
+    'flask-restplus==0.7.2',
+    'cherrypy>=3.7.0',
+    'flask-assets>=0.11',
+    'cssmin>=0.2.0',
+    'flask-compress>=1.2.1',
+    'flask-login>=0.3.2',
+    'pyparsing>=2.0.3',
+    'pyScss>=1.3.4',
+    'pytvmaze>=1.4.0'
 ]
 
 if sys.version_info < (2, 7):


Test patch:
Repository: Flexget/Flexget

Issue:
Problem with sabnzbd after upgrade to version 2.0.5
Hi,

Last night I upgraded to version 2.0.5 from 1.2.521. I haven't made any config changes. Everything seems to work except adding downloads to sabnzbd. Reverting back to version 1.2.521 made everything work again.

```
2016-04-27 07:30 CRITICAL sabnzbd       usenet          Failed to use sabnzbd. Requested http://sabnzbd:8080/sabnzbd/api?nzbname=REL_NAME&apikey=11111&mode=addurl&name=URL_THAT_WORKS
2016-04-27 07:30 CRITICAL sabnzbd       usenet          Result was: 'Task' object has no attribute 'get'
2016-04-27 07:30 ERROR    entry         usenet          Failed REL_NAME (sabnzbd unreachable) 
```

Manually clicking the url does add the nzb to sabznbd. 

This runs in a FreeBSD 10.3 jail using Python 2.7.11 installed and upgraded using pip.



Discussion:
@yodax Full traceback is usually required if any is given. Probably one of a very long list of py3 conversion issues we're going to have for a while. We'd appreciate it if users wouldn't revert right away to older versions. So we can actually find all the bugs from the new conversion. I understand. It's broken. But we can't fix all the issues your having if you revert back before we fix them.

Also a config minus any personal information is useful.

Just did a quick peek, but this appears to be the problem https://github.com/Flexget/Flexget/blob/develop/flexget/plugins/output/sabnzbd.py#L87

That should be `task.requests.get`

@gazpachoking yeah was about to fix that. Ohhh it was using something else before. makes sense now.

https://github.com/Flexget/Flexget/blob/develop/flexget/plugins/output/sabnzbd.py#L88

This catch is also way too broad, and the reason @yodax didn't get a traceback and the error message was wrong.


Resolving patch:
diff --git a/flexget/plugins/output/sabnzbd.py b/flexget/plugins/output/sabnzbd.py
--- a/flexget/plugins/output/sabnzbd.py
+++ b/flexget/plugins/output/sabnzbd.py
@@ -6,6 +6,7 @@
 
 from flexget import plugin
 from flexget.event import event
+from requests import RequestException
 
 log = logging.getLogger('sabnzbd')
 
@@ -84,10 +85,10 @@ def on_task_output(self, task, config):
             request_url = config['url'] + urlencode(params)
             log.debug('request_url: %s' % request_url)
             try:
-                response = task.get(request_url)
-            except Exception as e:
+                response = task.requests.get(request_url)
+            except RequestException as e:
                 log.critical('Failed to use sabnzbd. Requested %s' % request_url)
-                log.critical('Result was: %s' % e)
+                log.critical('Result was: %s' % e.args[0])
                 entry.fail('sabnzbd unreachable')
                 if task.options.debug:
                     log.exception(e)


Test patch:
Repository: Flexget/Flexget

Issue:
Transmission queue top feature
Transmission add to queue top feature request.
There is already option to add to top of queue in deluge.
But not in transmission.
It'll be good to add the feature.So that certain priority downloads will be added to top.



Discussion:

Resolving patch:
diff --git a/flexget/plugins/plugin_transmission.py b/flexget/plugins/plugin_transmission.py
--- a/flexget/plugins/plugin_transmission.py
+++ b/flexget/plugins/plugin_transmission.py
@@ -245,7 +245,8 @@ class PluginTransmission(TransmissionBase):
                     'honourlimits': {'type': 'boolean'},
                     'include_files': one_or_more({'type': 'string'}),
                     'skip_files': one_or_more({'type': 'string'}),
-                    'rename_like_files': {'type': 'boolean'}
+                    'rename_like_files': {'type': 'boolean'},
+                    'queue_position': {'type': 'integer'}
                 },
                 'additionalProperties': False
             }
@@ -303,7 +304,8 @@ def _make_torrent_options_dict(self, config, entry):
 
         for opt_key in ('path', 'addpaused', 'honourlimits', 'bandwidthpriority', 'maxconnections', 'maxupspeed', 
                         'maxdownspeed', 'ratio', 'main_file_only', 'main_file_ratio', 'magnetization_timeout',
-                        'include_subs', 'content_filename', 'include_files', 'skip_files', 'rename_like_files'):
+                        'include_subs', 'content_filename', 'include_files', 'skip_files', 'rename_like_files',
+                        'queue_position'):
             # Values do not merge config with task
             # Task takes priority then config is used
             if opt_key in entry:
@@ -348,6 +350,9 @@ def _make_torrent_options_dict(self, config, entry):
             else:
                 change['seedRatioMode'] = 1
 
+        if 'queue_position' in opt_dic:
+            change['queuePosition'] = opt_dic['queue_position']
+
         post = options['post']
         # set to modify paused status after 
         if 'addpaused' in opt_dic:


Test patch:
Repository: Flexget/Flexget

Issue:
TypeError with Form Login Plugin
### Expected behaviour:

Task runs without generating error.
### Actual behaviour:

Task runs and generates the following error

```
TypeError: must be unicode, not str
```
### Steps to reproduce:
- Step 1: Install latest version of Flexget using virtualenv
- Step 2: pip install mechanize
- Step 3: Create config.yml
- Step 4: flexget --test execute
#### Config:

```
tasks:
  test task:
    form:
      url: http://example.com/login.php
      username: email address
      password: password
    html:
      url: http://example.com/
```
#### Log:

Crash:

```
2016-08-16 11:40 DEBUG    manager       test task       Traceback:
Traceback (most recent call last):
  File "/home/username/flexget/local/lib/python2.7/site-packages/flexget/task.py", line 444, in __run_plugin
    return method(*args, **kwargs)
  File "/home/username/flexget/local/lib/python2.7/site-packages/flexget/event.py", line 23, in __call__
    return self.func(*args, **kwargs)
  File "/home/username/flexget/local/lib/python2.7/site-packages/flexget/plugins/plugin_formlogin.py", line 73, in on_task_start
    f.write(br.response().get_data())
TypeError: must be unicode, not str
2016-08-16 11:40 WARNING  task          test task       Aborting task (plugin: form)
2016-08-16 11:40 DEBUG    task_queue                    task test task aborted: TaskAbort(reason=BUG: Unhandled error in plugin form: must be unicode, not str, silent=False)
```

Full log.

```
http://pastebin.com/yBRqhYjR
```
### Additional information:
- Flexget Version: 2.2.20
- Python Version: 2.7.9
- Installation method: Virtualenv
- OS and version: Debian 8



Discussion:

Resolving patch:
diff --git a/flexget/plugins/plugin_formlogin.py b/flexget/plugins/plugin_formlogin.py
--- a/flexget/plugins/plugin_formlogin.py
+++ b/flexget/plugins/plugin_formlogin.py
@@ -2,6 +2,7 @@
 from builtins import *  # pylint: disable=unused-import, redefined-builtin
 
 import logging
+import io
 import os
 import socket
 
@@ -69,7 +70,7 @@ def on_task_start(self, task, config):
                 if not os.path.isdir(received):
                     os.mkdir(received)
                 filename = os.path.join(received, '%s.formlogin.html' % task.name)
-                with open(filename, 'w') as f:
+                with io.open(filename, 'wb') as f:
                     f.write(br.response().get_data())
                 log.critical('I have saved the login page content to %s for you to view' % filename)
                 raise plugin.PluginError('Unable to find login fields', log)


Test patch:
Repository: Flexget/Flexget

Issue:
archives plugin crashes when encountering a directory
### Expected behaviour:
Plugin should correctly reject directories

### Actual behaviour:
Crash!

### Steps to reproduce:
- Pass a directory entry to the archive plugin

#### Config:
```
paste relevant config
use paste service if config is too long
```
  
#### Log:
```
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/flexget/task.py", line 477, in __run_plugin
    return method(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/flexget/event.py", line 23, in __call__
    return self.func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/flexget/plugins/filter/archives.py", line 65, in on_task_filter
    if archive.is_archive(archive_path):
  File "/usr/local/lib/python2.7/site-packages/flexget/utils/archive.py", line 207, in is_archive
    archive = open_archive(path)
  File "/usr/local/lib/python2.7/site-packages/flexget/utils/archive.py", line 189, in open_archive
    elif rarfile and rarfile.is_rarfile(archive_path):
  File "/usr/local/lib/python2.7/site-packages/rarfile.py", line 362, in is_rarfile
    fd = XFile(xfile)
  File "/usr/local/lib/python2.7/site-packages/rarfile.py", line 1755, in __init__
    self._fd = open(xfile, 'rb', bufsize)
IOError: [Errno 21] Is a directory: u'/Volumes/Drobo/downloads/tv/
```

### Additional information:

- Flexget Version: 2.6.1
- Python Version: 2.7.12
- Installation method: pip
- OS and version: OS X Snow Leopard
- Link to crash log:

<!---
Please verify that the following data is present before submitting your issue:

- Paste or link to a paste service (http://pastebin.com/ for example) of relevant config (preferably full config including templates if present. Remember to redact any personal information! Please make sure the paste does not expire, if possible.
- Paste or link to a paste service of debug level logs of relevant task/s. Use `flexget -L debug execute --tasks <Task_name>`
- Flexget version (Use `flexget -V` to get it).
- Full Python version (`2.7.11` for example). Run `python -V` to get it.
- Installation method (pip, git install, etc.)
- OS and version
- Attach crash log if available
--->



Discussion:

Resolving patch:
diff --git a/flexget/utils/archive.py b/flexget/utils/archive.py
--- a/flexget/utils/archive.py
+++ b/flexget/utils/archive.py
@@ -208,8 +208,7 @@ def is_archive(path):
         if archive:
             archive.close()
             return True
-    except ArchiveError as error:
-        error_message = 'Failed to open file as archive: %s (%s)' % (path, error)
-        log.debug(error_message)
+    except (IOError, ArchiveError) as error:
+        log.debug('Failed to open file as archive: %s (%s)', path, error)
 
     return False


Test patch:
Repository: Flexget/Flexget

Issue:
Bakabt URL change
Bakabt url has change from http://www.bakabt.com to https://bakabt.me, the url rewriter plugin needs to be updated to match


Discussion:

Resolving patch:
diff --git a/flexget/plugins/sites/bakabt.py b/flexget/plugins/sites/bakabt.py
--- a/flexget/plugins/sites/bakabt.py
+++ b/flexget/plugins/sites/bakabt.py
@@ -17,9 +17,9 @@ class UrlRewriteBakaBT(object):
     # urlrewriter API
     def url_rewritable(self, task, entry):
         url = entry['url']
-        if url.startswith('http://www.bakabt.com/download/'):
+        if url.startswith('http://www.bakabt.me/download/'):
             return False
-        if url.startswith('http://www.bakabt.com/') or url.startswith('http://bakabt.com/'):
+        if url.startswith('http://www.bakabt.me/') or url.startswith('http://bakabt.me/'):
             return True
         return False
 
@@ -38,7 +38,7 @@ def parse_download_page(self, url, requests):
         tag_a = soup.find('a', attrs={'class': 'download_link'})
         if not tag_a:
             raise UrlRewritingError('Unable to locate download link from url %s' % url)
-        torrent_url = 'http://www.bakabt.com' + tag_a.get('href')
+        torrent_url = 'http://www.bakabt.me' + tag_a.get('href')
         return torrent_url
 
 


Test patch: