nebius/SWE-bench-extra huggingface dataset:
Repository: docker/docker-py

Issue:
Empty auth dictionary should be valid
docker/compose#3265

Comments:

Patch:
diff --git a/docker/auth/auth.py b/docker/auth/auth.py
index eedb7944..d23e6f3c 100644
--- a/docker/auth/auth.py
+++ b/docker/auth/auth.py
@@ -117,7 +117,7 @@ def parse_auth(entries, raise_on_error=False):
 
     conf = {}
     for registry, entry in six.iteritems(entries):
-        if not (isinstance(entry, dict) and 'auth' in entry):
+        if not isinstance(entry, dict):
             log.debug(
                 'Config entry for key {0} is not auth config'.format(registry)
             )
@@ -130,6 +130,16 @@ def parse_auth(entries, raise_on_error=False):
                     'Invalid configuration for registry {0}'.format(registry)
                 )
             return {}
+        if 'auth' not in entry:
+            # Starting with engine v1.11 (API 1.23), an empty dictionary is
+            # a valid value in the auths config.
+            # https://github.com/docker/compose/issues/3265
+            log.debug(
+                'Auth data for {0} is absent. Client might be using a '
+                'credentials store instead.'
+            )
+            return {}
+
         username, password = decode_auth(entry['auth'])
         log.debug(
             'Found entry (registry={0}, username={1})'
@@ -189,6 +199,9 @@ def load_config(config_path=None):
             if data.get('HttpHeaders'):
                 log.debug("Found 'HttpHeaders' section")
                 res.update({'HttpHeaders': data['HttpHeaders']})
+            if data.get('credsStore'):
+                log.debug("Found 'credsStore' section")
+                res.update({'credsStore': data['credsStore']})
             if res:
                 return res
             else:


Test patch:
diff --git a/tests/unit/auth_test.py b/tests/unit/auth_test.py
index 921aae00..4ea40477 100644
--- a/tests/unit/auth_test.py
+++ b/tests/unit/auth_test.py
@@ -459,6 +459,5 @@ class LoadConfigTest(base.Cleanup, base.BaseTestCase):
         with open(dockercfg_path, 'w') as f:
             json.dump(config, f)
 
-        self.assertRaises(
-            errors.InvalidConfigFile, auth.load_config, dockercfg_path
-        )
+        cfg = auth.load_config(dockercfg_path)
+        assert cfg == {}
Repository: docker/docker-py

Issue:
Feature Request: docker.from_env(version='auto')
Feature request to add auto api version support for ```docker.from_env()``` similar to ```docker.Client(version='auto')```?

I noticed that one of the suggestions from #402 for the ```version='auto'``` option was now available for ```docker.Client()``` but doesn't work for ```docker.from_env()```.

Comments:

Patch:
diff --git a/docker/client.py b/docker/client.py
index d1c6ee5f..ef718a72 100644
--- a/docker/client.py
+++ b/docker/client.py
@@ -114,7 +114,8 @@ class Client(
 
     @classmethod
     def from_env(cls, **kwargs):
-        return cls(**kwargs_from_env(**kwargs))
+        version = kwargs.pop('version', None)
+        return cls(version=version, **kwargs_from_env(**kwargs))
 
     def _retrieve_server_version(self):
         try:


Test patch:
diff --git a/tests/unit/client_test.py b/tests/unit/client_test.py
index b21f1d6a..6ceb8cbb 100644
--- a/tests/unit/client_test.py
+++ b/tests/unit/client_test.py
@@ -25,6 +25,14 @@ class ClientTest(base.BaseTestCase):
         client = Client.from_env()
         self.assertEqual(client.base_url, "https://192.168.59.103:2376")
 
+    def test_from_env_with_version(self):
+        os.environ.update(DOCKER_HOST='tcp://192.168.59.103:2376',
+                          DOCKER_CERT_PATH=TEST_CERT_DIR,
+                          DOCKER_TLS_VERIFY='1')
+        client = Client.from_env(version='2.32')
+        self.assertEqual(client.base_url, "https://192.168.59.103:2376")
+        self.assertEqual(client._version, '2.32')
+
 
 class DisableSocketTest(base.BaseTestCase):
     class DummySocket(object):
Repository: docker/docker-py

Issue:
Client should tolerate trailing slashes in base_url
docker/compose#3869

Comments:

Patch:
diff --git a/docker/api/image.py b/docker/api/image.py
index 7f25f9d9..262910cd 100644
--- a/docker/api/image.py
+++ b/docker/api/image.py
@@ -88,9 +88,6 @@ class ImageApiMixin(object):
                 u, data=data, params=params, headers=headers, timeout=None
             )
         )
-        return self.import_image(
-            src=data, repository=repository, tag=tag, changes=changes
-        )
 
     def import_image_from_file(self, filename, repository=None, tag=None,
                                changes=None):
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index b565732d..e1c7ad0c 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -453,8 +453,8 @@ def parse_host(addr, is_win32=False, tls=False):
             "Bind address needs a port: {0}".format(addr))
 
     if proto == "http+unix" or proto == 'npipe':
-        return "{0}://{1}".format(proto, host)
-    return "{0}://{1}:{2}{3}".format(proto, host, port, path)
+        return "{0}://{1}".format(proto, host).rstrip('/')
+    return "{0}://{1}:{2}{3}".format(proto, host, port, path).rstrip('/')
 
 
 def parse_devices(devices):


Test patch:
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py
index 2a2759d0..059c82d3 100644
--- a/tests/unit/utils_test.py
+++ b/tests/unit/utils_test.py
@@ -522,6 +522,11 @@ class ParseHostTest(base.BaseTestCase):
         expected_result = 'https://myhost.docker.net:3348'
         assert parse_host(host_value, tls=True) == expected_result
 
+    def test_parse_host_trailing_slash(self):
+        host_value = 'tcp://myhost.docker.net:2376/'
+        expected_result = 'http://myhost.docker.net:2376'
+        assert parse_host(host_value) == expected_result
+
 
 class ParseRepositoryTagTest(base.BaseTestCase):
     sha = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
Repository: docker/docker-py

Issue:
docker-py installation breaks docker-compose
im not quite sure if this is correct, but trying to install `docker-py` through pip after i've installed `docker-compose` breaks `docker-compose` with

```
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in <module>
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/site-packages/compose/cli/main.py", line 20, in <module>
    from ..bundle import get_image_digests
  File "/usr/local/lib/python2.7/site-packages/compose/bundle.py", line 13, in <module>
    from .network import get_network_defs_for_service
  File "/usr/local/lib/python2.7/site-packages/compose/network.py", line 7, in <module>
    from docker.types import IPAMConfig
ImportError: cannot import name IPAMConfig
```

To fix that error, i just need to do the installations in this order:
```
pip install docker-py
pip install docker-compose
```


gist:
https://gist.github.com/serialdoom/3a443c420aa29f9422f8c5fc73f46602

python/pip versions tried:
```
docker run -it python:2.7.13 bash -c 'pip --version'
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
docker run -it python:2.7.12 bash -c 'pip --version'
pip 8.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
```

Comments:

Patch:
diff --git a/docker/models/images.py b/docker/models/images.py
index 32068e69..6f8f4fe2 100644
--- a/docker/models/images.py
+++ b/docker/models/images.py
@@ -30,10 +30,10 @@ class Image(Model):
         """
         The image's tags.
         """
-        return [
-            tag for tag in self.attrs.get('RepoTags', [])
-            if tag != '<none>:<none>'
-        ]
+        tags = self.attrs.get('RepoTags')
+        if tags is None:
+            tags = []
+        return [tag for tag in tags if tag != '<none>:<none>']
 
     def history(self):
         """
diff --git a/setup.py b/setup.py
index b82a74f7..9fc4ad66 100644
--- a/setup.py
+++ b/setup.py
@@ -1,10 +1,20 @@
 #!/usr/bin/env python
+from __future__ import print_function
+
 import codecs
 import os
 import sys
 
+import pip
+
 from setuptools import setup, find_packages
 
+if 'docker-py' in [x.project_name for x in pip.get_installed_distributions()]:
+    print(
+        'ERROR: "docker-py" needs to be uninstalled before installing this'
+        ' package:\npip uninstall docker-py', file=sys.stderr
+    )
+    sys.exit(1)
 
 ROOT_DIR = os.path.dirname(__file__)
 SOURCE_DIR = os.path.join(ROOT_DIR)


Test patch:
diff --git a/tests/unit/models_images_test.py b/tests/unit/models_images_test.py
index 392c58d7..efb21166 100644
--- a/tests/unit/models_images_test.py
+++ b/tests/unit/models_images_test.py
@@ -83,6 +83,11 @@ class ImageTest(unittest.TestCase):
         })
         assert image.tags == []
 
+        image = Image(attrs={
+            'RepoTags': None
+        })
+        assert image.tags == []
+
     def test_history(self):
         client = make_fake_client()
         image = client.images.get(FAKE_IMAGE_ID)
Repository: dotmesh-io/dotscience-python

Issue:
ds.connect() only connects to single project and runs overwritten [fusemachines]
Fuse machines run ds.connect() from a local machine but it only connects to a single project.

Also runs are getting overwritten when running on the same machine.

This text is just a placeholder: it was decided on the Fuse machines call Oct 21st 4-5pm BST that they may need to do a call with the support engineer to fully explain. And/or send a video/screenshots.

Link to description from Fuse Machines: https://docs.google.com/document/d/1ZLhKlW6AG3khlPVyrINXD3LaS1fSTilyEorrj66w9ow

Comments:

Patch:
diff --git a/dotscience/__init__.py b/dotscience/__init__.py
index e12da54..c2c3ac3 100644
--- a/dotscience/__init__.py
+++ b/dotscience/__init__.py
@@ -253,6 +253,9 @@ class Dotscience:
     currentRun = None
 
     def __init__(self):
+        self._reset()
+
+    def _reset(self):
         self._mode = None
         self._workload_file = None
         self._root = os.getenv('DOTSCIENCE_PROJECT_DOT_ROOT', default=os.getcwd())
@@ -269,6 +272,7 @@ class Dotscience:
         # TODO: make publish etc fail if we're not connected in remote mode.
         if not project:
             raise Exception("Please specify a project name as the third argument to ds.connect()")
+        self._reset()
         self._dotmesh_client = DotmeshClient(
             cluster_url=hostname + "/v2/dotmesh/rpc",
             username=username,


Test patch:
diff --git a/dotscience/test_dotscience.py b/dotscience/test_dotscience.py
index 92790c7..89ab7e9 100644
--- a/dotscience/test_dotscience.py
+++ b/dotscience/test_dotscience.py
@@ -857,3 +857,39 @@ def test_multi_publish_2():
     assert m1["__ID"] != m2["__ID"]
     assert m1["start"] != m2["start"]
     assert m1["end"] != m2["end"]
+
+
+def test_reconnect_resets_internal_state(monkeypatch):
+    class FakeDotmeshClient:
+        def __init__(self, cluster_url, username, api_key):
+            self.cluster_url = cluster_url
+            self.username = username
+            self.api_key = api_key
+
+        def ping(self):
+            pass
+
+    monkeypatch.setattr(dotscience, "DotmeshClient", FakeDotmeshClient)
+
+    ds = dotscience.Dotscience()
+    ds.connect("me", "pass", "myproj", "https://example.com")
+    assert ds._dotmesh_client.__dict__ == {
+        "cluster_url": "https://example.com/v2/dotmesh/rpc",
+        "username": "me",
+        "api_key": "pass",
+    }
+    assert ds._project_name == "myproj"
+
+    # Pretend we have a cached project:
+    ds._cached_project = "not empty"
+    assert ds._get_project_or_create("myproj") == "not empty"
+
+    # Now, reconnect:
+    ds.connect("me2", "pass2", "myproj2", "https://2.example.com")
+    assert ds._dotmesh_client.__dict__ == {
+        "cluster_url": "https://2.example.com/v2/dotmesh/rpc",
+        "username": "me2",
+        "api_key": "pass2",
+    }
+    assert ds._project_name == "myproj2"
+    assert ds._cached_project == None