internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: SeldonIO/MLServer

Issue:
The huggingface translation task name requires an extra suffix
When I run the Huggingface translation task, got this raise ValueError('The task defaults can\'t be correctly selected. You probably meant "translation_XX_to_YY"')



Discussion:

Resolving patch:
diff --git a/runtimes/huggingface/mlserver_huggingface/common.py b/runtimes/huggingface/mlserver_huggingface/common.py
--- a/runtimes/huggingface/mlserver_huggingface/common.py
+++ b/runtimes/huggingface/mlserver_huggingface/common.py
@@ -38,12 +38,22 @@ class Config:
         env_prefix = ENV_PREFIX_HUGGINGFACE_SETTINGS
 
     task: str = ""
+    # Why need this filed?
+    # for translation task, required a suffix to specify source and target
+    # related issue: https://github.com/SeldonIO/MLServer/issues/947
+    task_suffix: str = ""
     pretrained_model: Optional[str] = None
     pretrained_tokenizer: Optional[str] = None
     optimum_model: bool = False
     device: int = -1
     batch_size: Optional[int] = None
 
+    @property
+    def task_name(self):
+        if self.task == "translation":
+            return f"{self.task}{self.task_suffix}"
+        return self.task
+
 
 def parse_parameters_from_env() -> Dict:
     """
@@ -114,7 +124,7 @@ def load_pipeline_from_settings(hf_settings: HuggingFaceSettings) -> Pipeline:
         device = -1
 
     pp = pipeline(
-        hf_settings.task,
+        hf_settings.task_name,
         model=model,
         tokenizer=tokenizer,
         device=device,
diff --git a/runtimes/huggingface/mlserver_huggingface/runtime.py b/runtimes/huggingface/mlserver_huggingface/runtime.py
--- a/runtimes/huggingface/mlserver_huggingface/runtime.py
+++ b/runtimes/huggingface/mlserver_huggingface/runtime.py
@@ -65,7 +65,7 @@ def __init__(self, settings: ModelSettings):
     async def load(self) -> bool:
         # Loading & caching pipeline in asyncio loop to avoid blocking
         print("=" * 80)
-        print(self.hf_settings.task)
+        print(self.hf_settings.task_name)
         print("loading model...")
         await asyncio.get_running_loop().run_in_executor(
             None, load_pipeline_from_settings, self.hf_settings


Test patch:
diff --git a/runtimes/huggingface/tests/test_common.py b/runtimes/huggingface/tests/test_common.py
new file mode 100644
--- /dev/null
+++ b/runtimes/huggingface/tests/test_common.py
@@ -0,0 +1,18 @@
+import pytest
+from typing import Dict
+from mlserver_huggingface.common import HuggingFaceSettings
+
+
+@pytest.mark.parametrize(
+    "envs, expected",
+    [
+        ({"task": "translation", "task_suffix": "_en_to_fr"}, "translation_en_to_fr"),
+        (
+            {"task": "question-answering", "task_suffix": "_any_thing_else"},
+            "question-answering",
+        ),
+    ],
+)
+def test_settings_task_name(envs: Dict[str, str], expected: str):
+    setting = HuggingFaceSettings(**envs)
+    assert setting.task_name == expected
Repository: SeldonIO/MLServer

Issue:
Add OS constraint in PyPI
Mention MLServer's OS constraints as metadata in `setup.py`, so that it becomes visible in pypi.org. 

```
setup(...,
      classifiers=[
          'Operating System :: POSIX',
          ],
      )
```

_Originally posted by @HugoMVale in https://github.com/SeldonIO/MLServer/issues/1022#issuecomment-1456788132_
            


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -37,6 +37,7 @@ def _load_description() -> str:
     url="https://github.com/SeldonIO/MLServer.git",
     author="Seldon Technologies Ltd.",
     author_email="hello@seldon.io",
+    classifiers=["Operating System :: POSIX", "Operating System :: MacOS"],
     description="ML server",
     include_package_data=True,
     packages=find_packages(exclude=["tests", "tests.*"]),


Test patch:
Repository: SeldonIO/MLServer

Issue:
Star imports from `mlserver.codecs` not working
For example:

```python
from mlserver.codecs import *
```
Throws an error:
```python
Traceback (most recent call last):
  File "/home/janis/.conda/envs/py310/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3460, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-b8cc62508f29>", line 1, in <module>
    from mlserver.codecs import *
AttributeError: module 'mlserver.codecs' has no attribute 'StringRequestCodec'
```

This is likely because `__all__` is out-of-date with the actual imports. I haven't tested other sub-packages, but it might be worth looking at these.

P.S. I'm not a big fan of  `__all__` and star imports in particular, the main issue is that the existence of `__all__` gives rise to two public APIs which may diverge (as it has in this case).


Discussion:

Resolving patch:
diff --git a/mlserver/codecs/__init__.py b/mlserver/codecs/__init__.py
--- a/mlserver/codecs/__init__.py
+++ b/mlserver/codecs/__init__.py
@@ -1,6 +1,6 @@
 from .numpy import NumpyCodec, NumpyRequestCodec
 from .pandas import PandasCodec
-from .string import StringCodec
+from .string import StringCodec, StringRequestCodec
 from .base64 import Base64Codec
 from .datetime import DatetimeCodec
 from .errors import CodecError


Test patch:
Repository: beetbox/beets

Issue:
"modify" for non-string values
This issue was automatically migrated from Google Code.
_Original author: adrian.sampson (January 30, 2012 01:39:59)_
_Original issue: http://code.google.com/p/beets/issues/detail?id=323_



Discussion:
Are there any thoughts on this already?

It could be simple as having in the fields list another element in the tuple, e.g.:

``` python
('title',                'text', unicode, True, True),
('year',                 'int', int, True, True),
('rg_track_gain',        'real', float, True, True),
```

And then we could simply instantiate it later.

What do you think?

Right, something very much like this would be perfect. We could even get rid of the SQLite type element (`'text'`, `'int'`, etc.) and maintain a map from Python types to those strings.


Resolving patch:
diff --git a/beets/library.py b/beets/library.py
--- a/beets/library.py
+++ b/beets/library.py
@@ -159,6 +159,28 @@
 # Special path format key.
 PF_KEY_DEFAULT = 'default'
 
+# Convert 'true' and 'false' to correspondent boolean
+def _str_to_bool(value):
+    if value.lower() == 'true':
+        return True
+    if value.lower() == 'false':
+        return False
+    raise ValueError('could not convert string to bool: {0}'.format(value))
+
+# Mapping the correspondent Python constructor to SQLite field types
+CONSTRUCTOR_MAPPING = {
+    'int': int,
+    'bool': _str_to_bool,
+    'real': float,
+}
+
+# Convert a string (from user input) to the correct Python type
+def _convert_type(fields, key, value):
+    sqlite_type = [f[1] for f in fields if f[0] == key][0]
+    if value and sqlite_type in CONSTRUCTOR_MAPPING:
+        constructor = CONSTRUCTOR_MAPPING[sqlite_type]
+        return constructor(value)
+    return value
 
 # Logger.
 log = logging.getLogger('beets')
@@ -642,7 +664,7 @@ def match(self, item):
             if subq.match(item):
                 return True
         return False
-    
+
 class MutableCollectionQuery(CollectionQuery):
     """A collection query whose subqueries may be modified after the
     query is initialized.
diff --git a/beets/ui/commands.py b/beets/ui/commands.py
--- a/beets/ui/commands.py
+++ b/beets/ui/commands.py
@@ -989,13 +989,14 @@ def show_version(lib, opts, args):
 def modify_items(lib, mods, query, write, move, album, confirm):
     """Modifies matching items according to key=value assignments."""
     # Parse key=value specifications into a dictionary.
+    fields = library.ALBUM_FIELDS if album else library.ITEM_FIELDS
     allowed_keys = library.ALBUM_KEYS if album else library.ITEM_KEYS_WRITABLE
     fsets = {}
     for mod in mods:
         key, value = mod.split('=', 1)
         if key not in allowed_keys:
             raise ui.UserError('"%s" is not a valid field' % key)
-        fsets[key] = value
+        fsets[key] = library._convert_type(fields, key, value)
 
     # Get the items to modify.
     items, albums = _do_query(lib, query, album, False)


Test patch:
Repository: beetbox/beets

Issue:
Error while querying lyrics
I'm getting the following error when attempting to load lyrics:

```
Traceback (most recent call last):                                               
  File "/Volumes/megafil/music/tools/env/bin/beet", line 9, in <module>          
    load_entry_point('beets==1.3.2', 'console_scripts', 'beet')()                
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/beets/ui/__init__.py", line 810, in main
    _raw_main(args)                                                              
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/beets/ui/__init__.py", line 802, in _raw_main
    subcommand.func(lib, suboptions, subargs)                                    
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/beetsplug/lyrics.py", line 408, in func
    opts.force_refetch)                                                          
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/beetsplug/lyrics.py", line 435, in fetch_item_lyrics
    lyrics = self.get_lyrics(item.artist, item.title)                            
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/beetsplug/lyrics.py", line 464, in get_lyrics
    lyrics = backend(artist, title)                                              
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/beetsplug/lyrics.py", line 365, in fetch_google
    lyrics = scrape_lyrics_from_url(urlLink)                                     
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/beetsplug/lyrics.py", line 299, in scrape_lyrics_from_url
    soup = BeautifulSoup(html)                                                   
  File "/Volumes/megafil/music/tools/env/lib/python2.7/site-packages/bs4/__init__.py", line 162, in __init__
    elif len(markup) <= 256:                                                     
TypeError: object of type 'NoneType' has no len()                                                                                                                                                                                                                                                                                                                           
```

Known issue? Looking at the code, we have:

``` py
    html = fetch_url(url)
    soup = BeautifulSoup(html)
```

`html` can be `None`, which causes `BeautifulSoup` to throw.



Discussion:

Resolving patch:
diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py
--- a/beetsplug/lyrics.py
+++ b/beetsplug/lyrics.py
@@ -296,6 +296,9 @@ def scrape_lyrics_from_url(url):
     """
     from bs4 import BeautifulSoup, Tag, Comment
     html = fetch_url(url)
+    if not html:
+        return None
+
     soup = BeautifulSoup(html)
 
     for tag in soup.findAll('br'):


Test patch:
Repository: beetbox/beets

Issue:
mpdstats: last_played is documented but not implemented
As pointed out [on the mailing list](https://groups.google.com/d/msg/beets-users/VW0pxtCVZG4/sq9gGsNS9zEJ), the mpdstats plugin (paging @pscn and @kljohann) does not seem to set the `last_played` field, even though the field is described in [the plugin's docs](http://beets.readthedocs.org/en/v1.3.2/plugins/mpdstats.html). Grepping in mpdstats.py for "last_played" shows that doesn't seem to be implemented. We should probably either add it to the plugin or remove it from the docs.



Discussion:
`last_played` was written in the "original" version of mpdstats.  Didn't check the re-worked version though as I sadly don't have much time for beets at the moment.

Oh, sorry. I will send a pull request to re-add this on monday if nobody beats me to it. :)

Aha, that explains it! Thanks for taking a look, @kljohann. That is, if no one _beets_ you to it... :smiley: :flushed:


Resolving patch:
diff --git a/beetsplug/mpdstats.py b/beetsplug/mpdstats.py
--- a/beetsplug/mpdstats.py
+++ b/beetsplug/mpdstats.py
@@ -281,6 +281,9 @@ def on_play(self, status):
             'beets_item': self.get_item(path),
         }
 
+        self.update_item(self.now_playing['beets_item'],
+                         'last_played', value=int(time.time()))
+
     def run(self):
         self.mpd.connect()
         events = ['player']


Test patch:
Repository: beetbox/beets

Issue:
Option to display source of data for current suggestion
I'm currently importing a bunch of music, and whenever I find an issue with the suggested data, I go to musicbrainz to try and sort it out.

It would be great if there was an option to display the URL for the musicbrainz release that the current suggestion is based on. (maybe this should be generalised to other sources) 



Discussion:
Good idea. This will be easy to implement since we already do it for discogs—just grep for [data_url](https://github.com/sampsyo/beets/search?q=data_url)—if you're interested in taking care of this.

Sure, looks pretty straightforward, I'll see if I can add it.


Resolving patch:
diff --git a/beets/autotag/mb.py b/beets/autotag/mb.py
--- a/beets/autotag/mb.py
+++ b/beets/autotag/mb.py
@@ -18,6 +18,7 @@
 import musicbrainzngs
 import re
 import traceback
+from urlparse import urljoin
 
 import beets.autotag.hooks
 import beets
@@ -26,6 +27,7 @@
 
 SEARCH_LIMIT = 5
 VARIOUS_ARTISTS_ID = '89ad4ac3-39f7-470e-963a-56509c546377'
+BASE_URL = 'http://musicbrainz.org/'
 
 musicbrainzngs.set_useragent('beets', beets.__version__,
                              'http://beets.radbox.org/')
@@ -49,6 +51,12 @@ def get_message(self):
                     'labels', 'artist-credits', 'aliases']
 TRACK_INCLUDES = ['artists', 'aliases']
 
+def track_url(trackid):
+    return urljoin(BASE_URL, 'recording/' + trackid)
+
+def album_url(albumid):
+    return urljoin(BASE_URL, 'release/' + albumid)
+
 def configure():
     """Set up the python-musicbrainz-ngs module according to settings
     from the beets configuration. This should be called at startup.
@@ -148,6 +156,7 @@ def track_info(recording, index=None, medium=None, medium_index=None,
         medium=medium,
         medium_index=medium_index,
         medium_total=medium_total,
+        data_url=track_url(recording['id']),
     )
 
     if recording.get('artist-credit'):
@@ -232,6 +241,7 @@ def album_info(release):
         artist_sort=artist_sort_name,
         artist_credit=artist_credit_name,
         data_source='MusicBrainz',
+        data_url=album_url(release['id']),
     )
     info.va = info.artist_id == VARIOUS_ARTISTS_ID
     info.asin = release.get('asin')


Test patch:
Repository: beetbox/beets

Issue:
User-defined delimiter for multiple genres in LastGenre plugin
It would be very nice to setup a user-defined separator  for the multiple genre setting in the lastgenre plugin.



Discussion:
Thanks for filing! Should be straightforward enough, in case anyone is interested in picking this up.


Resolving patch:
diff --git a/beetsplug/lastgenre/__init__.py b/beetsplug/lastgenre/__init__.py
--- a/beetsplug/lastgenre/__init__.py
+++ b/beetsplug/lastgenre/__init__.py
@@ -114,7 +114,9 @@ def _strings_to_genre(tags):
         tags = out
 
     tags = [t.title() for t in tags]
-    return u', '.join(tags[:config['lastgenre']['count'].get(int)])
+    return config['lastgenre']['separator'].get(unicode).join(
+        tags[:config['lastgenre']['count'].get(int)]
+    )
 
 def fetch_genre(lastfm_obj):
     """Return the genre for a pylast entity or None if no suitable genre
@@ -217,6 +219,7 @@ def __init__(self):
             'source': 'album',
             'force': True,
             'auto': True,
+            'separator': u', ',
         })
 
         if self.config['auto']:


Test patch:
Repository: beetbox/beets

Issue:
Make "singleton" a computed album field
Currently, we have a special `SingletonQuery` type for implementing queries like `singleton:true`. This requires a bunch of extra logic in query parsing. Now that we can issue queries over computed fields, we should just make `singleton` into a computed field on albums and let `BooleanQuery` suffice to query it.



Discussion:

Resolving patch:
diff --git a/beets/library.py b/beets/library.py
--- a/beets/library.py
+++ b/beets/library.py
@@ -58,22 +58,6 @@ def clause(self):
                (file_blob, dir_pat)
 
 
-class SingletonQuery(dbcore.Query):
-    """Matches either singleton or non-singleton items."""
-    def __init__(self, sense):
-        self.sense = sense
-
-    def clause(self):
-        if self.sense:
-            return "album_id ISNULL", ()
-        else:
-            return "NOT album_id ISNULL", ()
-
-    def match(self, item):
-        return (not item.album_id) == self.sense
-
-
-
 # Library-specific field types.
 
 
@@ -278,7 +262,9 @@ class Item(LibModel):
 
     @classmethod
     def _getters(cls):
-        return plugins.item_field_getters()
+        getters = plugins.item_field_getters()
+        getters['singleton'] = Item.singleton
+        return getters
 
     @classmethod
     def from_path(cls, path):
@@ -305,8 +291,13 @@ def __setitem__(self, key, value):
 
         super(Item, self).__setitem__(key, value)
 
+    def singleton(self):
+        """Returns a boolean indicating whether this item is a singleton
+        (doesn't belong to an album)"""
+        return self.album_id is None
+
     def update(self, values):
-        """Sett all key/value pairs in the mapping. If mtime is
+        """Set all key/value pairs in the mapping. If mtime is
         specified, it is not reset (as it might otherwise be).
         """
         super(Item, self).update(values)
@@ -932,14 +923,7 @@ def construct_query_part(query_part, model_cls):
             return query_class(pattern)
 
     key = key.lower()
-
-    # Singleton query (not a real field).
-    if key == 'singleton':
-        return SingletonQuery(util.str2bool(pattern))
-
-    # Other field.
-    else:
-        return query_class(key.lower(), pattern, key in model_cls._fields)
+    return query_class(key.lower(), pattern, key in model_cls._fields)
 
 
 def query_from_strings(query_cls, model_cls, query_parts):
diff --git a/beetsplug/mbsync.py b/beetsplug/mbsync.py
--- a/beetsplug/mbsync.py
+++ b/beetsplug/mbsync.py
@@ -49,7 +49,7 @@ def mbsync_singletons(lib, query, move, pretend, write):
     """Synchronize matching singleton items.
     """
     singletons_query = library.get_query(query, library.Item)
-    singletons_query.subqueries.append(library.SingletonQuery(True))
+    singletons_query.subqueries.append(library.BooleanQuery('singleton', True))
     for s in lib.items(singletons_query):
         if not s.mb_trackid:
             log.info(u'Skipping singleton {0}: has no mb_trackid'


Test patch:
Repository: beetbox/beets

Issue:
%if{} template function should work with Python booleans
Currently, if the first argument to an %if{} is the string "False", it treats the condition as true. It should special-case this string to facilitate use with inline functions that return booleans.



Discussion:

Resolving patch:
diff --git a/beets/library.py b/beets/library.py
--- a/beets/library.py
+++ b/beets/library.py
@@ -1121,9 +1121,13 @@ def tmpl_if(condition, trueval, falseval=u''):
         otherwise, emit ``falseval`` (if provided).
         """
         try:
-            condition = _int_arg(condition)
+            int_condition = _int_arg(condition)
         except ValueError:
-            condition = condition.strip()
+            if condition.lower() == "false":
+                return falseval
+        else:
+            condition = int_condition
+
         if condition:
             return trueval
         else:


Test patch:
diff --git a/test/test_library.py b/test/test_library.py
--- a/test/test_library.py
+++ b/test/test_library.py
@@ -496,6 +496,10 @@ def test_if_false(self):
         self._setf(u'x%if{,foo}')
         self._assert_dest('/base/x')
 
+    def test_if_false_value(self):
+        self._setf(u'x%if{false,foo}')
+        self._assert_dest('/base/x')
+
     def test_if_true(self):
         self._setf(u'%if{bar,foo}')
         self._assert_dest('/base/foo')
@@ -504,6 +508,10 @@ def test_if_else_false(self):
         self._setf(u'%if{,foo,baz}')
         self._assert_dest('/base/baz')
 
+    def test_if_else_false_value(self):
+        self._setf(u'%if{false,foo,baz}')
+        self._assert_dest('/base/baz')
+
     def test_if_int_value(self):
         self._setf(u'%if{0,foo,baz}')
         self._assert_dest('/base/baz')
Repository: beetbox/beets

Issue:
mpdstats: single or last song isn't rated and counted
The `mpdstats` plugin won't update `play_count`+`rating` for the last (or only) song in the playlist. (paging @pscn and @kljohann)

mpdstats: single or last song isn't rated and counted
The `mpdstats` plugin won't update `play_count`+`rating` for the last (or only) song in the playlist. (paging @pscn and @kljohann)



Discussion:
That's odd—any guesses as to why? Garden-variety off-by-one error?

It looks like `on_play` will only call `handle_song_change` for the previous song, according to [these lines](https://github.com/sampsyo/beets/blob/master/beetsplug/mpdstats.py#L270-L271). So the last (or single) song in the playlist will never get processed by `handle_song_change`.

Aha, got it—so we need to check also when `self.now_playing` is false and detect when the playlist has finished. Thanks for investigating!

A patch from a daily MPD user would be appreciated here.

Well I'm not sure, if the last song finishes, then `on_play` won't be triggered again. So maybe `on_stop` should check if the last song was handled?

Yes, that sounds more reasonable.

That's odd—any guesses as to why? Garden-variety off-by-one error?

It looks like `on_play` will only call `handle_song_change` for the previous song, according to [these lines](https://github.com/sampsyo/beets/blob/master/beetsplug/mpdstats.py#L270-L271). So the last (or single) song in the playlist will never get processed by `handle_song_change`.

Aha, got it—so we need to check also when `self.now_playing` is false and detect when the playlist has finished. Thanks for investigating!

A patch from a daily MPD user would be appreciated here.

Well I'm not sure, if the last song finishes, then `on_play` won't be triggered again. So maybe `on_stop` should check if the last song was handled?

Yes, that sounds more reasonable.


Resolving patch:
diff --git a/beetsplug/mpdstats.py b/beetsplug/mpdstats.py
--- a/beetsplug/mpdstats.py
+++ b/beetsplug/mpdstats.py
@@ -245,6 +245,10 @@ def handle_skipped(self, song):
 
     def on_stop(self, status):
         log.info(u'mpdstats: stop')
+
+        if self.now_playing:
+            self.handle_song_change(self.now_playing)
+
         self.now_playing = None
 
     def on_pause(self, status):


Test patch:
Repository: beetbox/beets

Issue:
Allow on-demand only acoustid fingerprinting
It would be great to be able to have the chroma plugin activated, but only for the explicit `submit` use case, so that you don't have to keep enabling and disabling it to avoid the dramatic slowdown when doing imports.

Some kind of an option like:

``` yaml
acoustid:
  auto: no
```



Discussion:
Indeed it would! And `auto` is exactly the right name. :smiley_cat: 

Any update on this?

@voltagex If you're interested in the feature, the best thing to do is start contributing—a pull request would be welcome here.


Resolving patch:
diff --git a/beetsplug/chroma.py b/beetsplug/chroma.py
--- a/beetsplug/chroma.py
+++ b/beetsplug/chroma.py
@@ -181,9 +181,11 @@ def fingerprint_task(task, session):
     """Fingerprint each item in the task for later use during the
     autotagging candidate search.
     """
-    items = task.items if task.is_album else [task.item]
-    for item in items:
-        acoustid_match(item.path)
+    auto = config['acoustid']['auto']
+    if auto:
+        items = task.items if task.is_album else [task.item]
+        for item in items:
+            acoustid_match(item.path)
 
 
 @AcoustidPlugin.listen('import_task_apply')


Test patch: