internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: scikit-hep/uproot5

Issue:
XRootD: The number of 'read ahead' elements requested in a readv call can exceed the server's limit
Uproot 4.0.2rc1

I'm sorry that I can't provide a root file / xrd server to reproduce this.

In
https://github.com/scikit-hep/uproot4/blob/3e53f480475883397a3a4e2dea199cdc00fd6477/uproot/source/xrootd.py#L326-L341

if the `request_ranges` list length exceeds `readv_iov_max`, the server will report the error "Read vector is too long" i.e.
```cpp
   if (rdVecNum > XrdProto::maxRvecsz)
      return Response.Send(kXR_ArgTooLong, "Read vector is too long");
``` 
where `rdVecNum = rdVecLen / sizeof(readahead_list);`,  which corresponds to the number of elements in the `request_ranges` list sent to the server.

I think that the code at https://github.com/scikit-hep/uproot4/blob/3e53f480475883397a3a4e2dea199cdc00fd6477/uproot/source/xrootd.py#L294-L298

may be the cause, since it does the max element size check. Changing
```
     if len(all_request_ranges[-1]) > self._max_num_elements: 
```
to
```
     if len(all_request_ranges[-1]) >= self._max_num_elements: 
```
seems to fix the issue in my test. Will open a PR.





Discussion:

Resolving patch:
diff --git a/uproot/source/xrootd.py b/uproot/source/xrootd.py
--- a/uproot/source/xrootd.py
+++ b/uproot/source/xrootd.py
@@ -292,7 +292,7 @@ def chunks(self, ranges, notifications):
         sub_ranges = {}
 
         def add_request_range(start, length, sub_ranges_list):
-            if len(all_request_ranges[-1]) > self._max_num_elements:
+            if len(all_request_ranges[-1]) >= self._max_num_elements:
                 all_request_ranges.append([])
             all_request_ranges[-1].append((start, length))
             sub_ranges_list.append((start, start + length))


Test patch:
Repository: scikit-hep/uproot5

Issue:
Histogram protocol issue?
I am confused about `PlottableAxisContinuous.__getitem__`: for uproot4 it seems to give the one-indexed values where I was expecting zero-indexed, since `__len__` gives the number of bins without flow. For example:
```
>>> h = uproot.open('https://raw.githubusercontent.com/CoffeaTeam/coffea/master/tests/samples/testSF2d.histo.root:scalefactors_Tight_Electron')
>>> axis = h.axes[0]
>>> len(axis)
10
>>> axis.edges()
array([-2.5  , -2.   , -1.566, -1.444, -0.8  ,  0.   ,  0.8  ,  1.444,
        1.566,  2.   ,  2.5  ])
>>> axis.edges().shape
(11,)
>>> axis[0]
(-2.0, -1.566)
```


Discussion:
After much back-and-forth, the histogram protocol settled on not including under/overflow bins, and _going beyond_ the protocol, we are allowed to include a `flow=True/False` option to turn it on and off. See, for instance, [TH1.values](https://uproot.readthedocs.io/en/latest/uproot.behaviors.TH1.TH1.html#values) and [TH1.edges](https://uproot.readthedocs.io/en/latest/uproot.behaviors.TAxis.TAxis.html#edges).

But I think what you're running up against is not under/overflow bin handling, but the [fencepost principle](https://en.wikipedia.org/wiki/Off-by-one_error#Fencepost_error). If you do `__getitem__`, you get a section of the fence defined by the two posts that border it. If you do `edges()`, you see all the posts. It's like the difference between `offsets` and `starts/stops`.

If anything, this should be categorized as "policy," rather than a "bug," but I really don't want to revisit the histogram protocol definitions again. I'd like to let those dogs lie.
Uh.. I am fine with fenceposts or whatever but why don't I get the first (not overflow) bin `(-2.5, -2)` when I ask for bin index 0? Surely such behaviors are supposed to be specified by the protocol. @henryiii ?
Oh, that is strange, now that I look at the actual numbers. This `edges` doesn't look consistent with the `__getitem__`. If you had asked for `flow=True`, it would add infinity fenceposts to the ends:

https://github.com/scikit-hep/uproot4/blob/ea0456cd4d101eed8c8e20207560e6057bf063c3/uproot/behaviors/TAxis.py#L215-L223

So that means that the `__getitem__` should return `fXbins[where], fXbins[where + 1]` instead of

https://github.com/scikit-hep/uproot4/blob/ea0456cd4d101eed8c8e20207560e6057bf063c3/uproot/behaviors/TAxis.py#L61-L75

which, I guess, only affects irregularly spacaed bins. This is looking more like a bug to me, too (and not a histogram protocol thing).


Resolving patch:
diff --git a/uproot/behaviors/TAxis.py b/uproot/behaviors/TAxis.py
--- a/uproot/behaviors/TAxis.py
+++ b/uproot/behaviors/TAxis.py
@@ -72,7 +72,7 @@ def __getitem__(self, where):
             return low, high
 
         else:
-            return fXbins[where + 1], fXbins[where + 2]
+            return fXbins[where], fXbins[where + 1]
 
     def __iter__(self):
         """


Test patch:
Repository: scikit-hep/uproot5

Issue:
Xrootd vector read has no timeout
In https://github.com/scikit-hep/uproot4/blob/7e3353cfdec91c340c7a0e26a31a695d2db3bcf1/uproot/source/xrootd.py#L341-L343 there is no timeout argument passed to `vector_read`. The signature supports it: https://xrootd.slac.stanford.edu/doc/python/xrootd-python/modules/client/file.html#XRootD.client.File.vector_read and the regular read does use it:
https://github.com/scikit-hep/uproot4/blob/7e3353cfdec91c340c7a0e26a31a695d2db3bcf1/uproot/source/xrootd.py#L152-L154


Discussion:
Since `self` in the first code block is a XRootDSource, which has a `self._timeout`, is there any downside to calling the equivalent of `_xrd_timeout` and passing it to `vector_read`? 

`_xrd_timeout` is unfortunately not defined for XRootDSource, but XRootDResource, though it could become a free function:

https://github.com/scikit-hep/uproot4/blob/7e3353cfdec91c340c7a0e26a31a695d2db3bcf1/uproot/source/xrootd.py#L90-L94
I think it should be as simple as adding `timeout=self._resource._xrd_timeout()` to the call. I'll make a PR soon
If the resource has the same `_timeout` (i.e. the data is simply copied). I would think that it is.

Resolving patch:
diff --git a/uproot/source/xrootd.py b/uproot/source/xrootd.py
--- a/uproot/source/xrootd.py
+++ b/uproot/source/xrootd.py
@@ -339,7 +339,9 @@ def add_request_range(start, length, sub_ranges_list):
             callback = self._resource.callbacker(futures, results)
 
             status = self._resource.file.vector_read(
-                chunks=request_ranges, callback=callback
+                chunks=request_ranges,
+                timeout=self._resource._xrd_timeout(),
+                callback=callback,
             )
             if status.error:
                 self._resource._xrd_error(status)


Test patch:
Repository: scikit-hep/uproot5

Issue:
XRootD vector_read leaks memory
XRootD vector_read leaks memory and should not be the default until the issue is fixed upstream.
Here is a reproducible example that demonstrates the problem:

```python
import uproot
import threading
from queue import Queue
import psutil
import time
import tqdm
import gc


notifications = Queue()

def worker():
    # just eat the chunks as they come in
    while True:
        notifications.get().wait()
        notifications.task_done()


usage = []
def collect_usage():
    chunktype = uproot.source.chunk.Chunk
    usage.append({
        "dt": time.time() - tstart,
        "rss": process.memory_info().rss,
        "nchunks": sum(isinstance(o, chunktype) for o in gc.get_objects()),
    })

threading.Thread(target=worker, daemon=True).start()
process = psutil.Process()
step = 1024 * 32  # a typical basket size
step2 = 10  # like number of baskets per chunk

fn = "root://eospublic.cern.ch//eos/root-eos/cms_opendata_2012_nanoaod/Run2012B_DoubleMuParked.root"
with uproot.source.xrootd.XRootDSource(fn, **uproot.open.defaults) as source:
    maxbytes = source.num_bytes  # how much memory would you like to use? :)
    ranges = [(start, start + step) for start in range(0, maxbytes, step)]

    usage = []
    tstart = time.time()
    for i in tqdm.trange(0, len(ranges), step2):
        subranges = ranges[i:i + step2]
        chunks = source.chunks(subranges, notifications)
        notifications.join()
        del chunks  # this *should* be the only reference to the data
        gc.collect()  # the chunks seem to have cycles
        collect_usage()

collect_usage()
import pandas
usage = pandas.DataFrame(usage).set_index("dt")
```

If I then plot the data:
```python
from matplotlib.ticker import EngFormatter

ax = usage.plot(secondary_y="nchunks")
ax.yaxis.set_major_formatter(EngFormatter(unit='b'))
ax.set_title(f"Reading {maxbytes/1e9:.1f}Gb from a file")
```
I get:
![image](https://user-images.githubusercontent.com/6587412/110027028-14a42480-7cf7-11eb-8a0f-dd6c8bf7325d.png)

PS I reported this behavior a long time ago https://github.com/scikit-hep/uproot4/issues/2#issuecomment-629300538


Discussion:
Please do make it non-default. I'll release a new version of Uproot when that's merged into main.

Thanks!
More python objects that are not being held:

```python
import numpy
sum(isinstance(o, numpy.ndarray) for o in gc.get_objects())
```
is 2

```python
import XRootD
sum(isinstance(o, XRootD.client.responses.ChunkInfo) for o in gc.get_objects())
```
is 0

Resolving patch:
diff --git a/uproot/reading.py b/uproot/reading.py
--- a/uproot/reading.py
+++ b/uproot/reading.py
@@ -154,7 +154,7 @@ def open(
 
 open.defaults = {
     "file_handler": uproot.source.file.MemmapSource,
-    "xrootd_handler": uproot.source.xrootd.XRootDSource,
+    "xrootd_handler": uproot.source.xrootd.MultithreadedXRootDSource,
     "http_handler": uproot.source.http.HTTPSource,
     "object_handler": uproot.source.object.ObjectSource,
     "timeout": 30,


Test patch:
Repository: scikit-hep/uproot5

Issue:
Uproot fails with self-built XRootD
With Uproot 4.0.11 and a self-built XRootD with Python bindings, `import uproot` fails with `TypeError: '<' not supported between instances of 'str' and 'int'`. This is due to the following line: https://github.com/scikit-hep/uproot4/blob/d6f9bea0f1a9ca6806445b95da93efa37c5117ba/src/uproot/extras.py#L116

When one builds XRootD, the version number differs from the standard `x.y.z` - it is, e.g., `v20210712-58b374f12`, which causes `LooseVersion` to raise `TypeError`. 


Discussion:

Resolving patch:
diff --git a/src/uproot/extras.py b/src/uproot/extras.py
--- a/src/uproot/extras.py
+++ b/src/uproot/extras.py
@@ -106,14 +106,20 @@ def cleanup_open_files():
 def older_xrootd(min_version):
     """
     Check if the installed XRootD bindings are newer than a given version
-    without importing. Defaults to False if XRootD is not installed.
+    without importing. Defaults to False if XRootD is not installed. Unrecognized
+    versions (i.e. self-built XRootD, whose version numbers are strings)
+    return False: that is, they're assumed to be new, so that no warnings
+    are raised.
     """
     try:
         dist = pkg_resources.get_distribution("XRootD")
     except pkg_resources.DistributionNotFound:
         return False
     else:
-        return LooseVersion(dist.version) < LooseVersion(min_version)
+        try:
+            return LooseVersion(dist.version) < LooseVersion(min_version)
+        except TypeError:
+            return False
 
 
 def lzma():


Test patch:
Repository: scikit-hep/uproot5

Issue:
It's possible for a ReadOnlyDirectory to be created without all fields.
ReadOnlyDirectory has a few attributes that usually get filled with meaningful values when `fSeekKeys != 0`. But in that special case:

https://github.com/scikit-hep/uproot5/blob/914dd25ec03225c5a37da3c30d8d83d68d34fea4/src/uproot/reading.py#L1405-L1407

the `self._keys_lookup` and `self._len` attributes don't get set (any others? scroll down to check). They should be set in any case, possibly before that `if`-branch so that conditional initialization doesn't bite us again.


Discussion:
By the way, this should be back-ported to `main-v4` and make a new v4 release, not just `main`/v5. It's important enough to warrant a new v4 release.

Resolving patch:
diff --git a/src/uproot/reading.py b/src/uproot/reading.py
--- a/src/uproot/reading.py
+++ b/src/uproot/reading.py
@@ -1405,7 +1405,8 @@ def __init__(self, path, cursor, context, file, parent):
         if self._fSeekKeys == 0:
             self._header_key = None
             self._keys = []
-
+            self._keys_lookup = {}
+            self._len = None
         else:
             keys_start = self._fSeekKeys
             keys_stop = min(keys_start + self._fNbytesKeys + 8, file.fEND)


Test patch:
Repository: scikit-hep/uproot5

Issue:
Threads staying open after `uproot.num_entries`
When using `uproot.num_entries` to read the number of entries for a lot of remote files, I eventually run into `RuntimeError: can't start new thread`. I cannot reproduce this with local files. This is tested with `uproot` version 4.3.5.
```python
import uproot
import threading

for _ in range(10):
    next(uproot.num_entries("https://github.com/scikit-hep/scikit-hep-testdata/"\
            "blob/main/src/skhep_testdata/data/uproot-HZZ.root?raw=true:events"))
    print(threading.active_count())
```
output:
```
2
3
4
5
6
7
8
9
10
11
```


Discussion:
It looks like we never close the executors, so their resources (threads) accumulate until exhaustion of the limit.

Resolving patch:
diff --git a/src/uproot/models/TTree.py b/src/uproot/models/TTree.py
--- a/src/uproot/models/TTree.py
+++ b/src/uproot/models/TTree.py
@@ -968,6 +968,7 @@ def num_entries(paths):
         paths = [uproot._util.file_object_path_split(paths)]
 
     for i, (file_path, object_path) in enumerate(paths2):
-        yield paths[i][0], paths[i][1], uproot.open(
+        with uproot.open(
             {file_path: object_path}, custom_classes={"TTree": Model_TTree_NumEntries}
-        ).all_members["fEntries"][0]
+        ) as f:
+            yield paths[i][0], paths[i][1], f.all_members["fEntries"][0]


Test patch:
Repository: scikit-hep/uproot5

Issue:
uproot.dask form remapping does not work when dask-awkward column optimization turned off
Logging it here since we discussed it over zoom / on friday.

Replicating the text of where the problem is:
"""
so the issue is that the nanoevents keys do not get subbed in until project_columns is called https://github.com/scikit-hep/uproot5/blob/main/src/uproot/_dask.py#L789 and it's only called when we optimize columns https://github.com/dask-contrib/dask-awkward/blob/main/src/dask_awkward/lib/optimize.py#L124 (iiuc)
"""

So I think we can make it so that when uproot.dask creates the layer we make sure to pass the correct dask-awkward form keys.


Discussion:

Resolving patch:
diff --git a/src/uproot/_dask.py b/src/uproot/_dask.py
--- a/src/uproot/_dask.py
+++ b/src/uproot/_dask.py
@@ -765,7 +765,10 @@ def __call__(self, i_start_stop):
         if self.form_mapping is not None:
             awkward = uproot.extras.awkward()
 
-            actual_form = self.rendered_form.select_columns(self.common_keys)
+            if set(self.common_keys) != set(self.rendered_form.columns()):
+                actual_form = self.rendered_form.select_columns(self.common_keys)
+            else:
+                actual_form = self.rendered_form
 
             mapping, buffer_key = self.form_mapping.create_column_mapping_and_key(
                 self.ttrees[i], start, stop, self.interp_options
@@ -880,7 +883,10 @@ def __call__(self, file_path_object_path_istep_nsteps_ischunk):
         if self.form_mapping is not None:
             awkward = uproot.extras.awkward()
 
-            actual_form = self.rendered_form.select_columns(self.common_keys)
+            if set(self.common_keys) != set(self.rendered_form.columns()):
+                actual_form = self.rendered_form.select_columns(self.common_keys)
+            else:
+                actual_form = self.rendered_form
 
             mapping, buffer_key = self.form_mapping.create_column_mapping_and_key(
                 ttree, start, stop, self.interp_options
@@ -1139,7 +1145,7 @@ def real_filter_branch(branch):
     return dask_awkward.from_map(
         _UprootRead(
             ttrees,
-            common_keys,
+            common_keys if form_mapping is None else form.columns(),
             common_keys,
             interp_options,
             form_mapping=form_mapping,
@@ -1230,7 +1236,7 @@ def _get_dak_array_delay_open(
             custom_classes,
             allow_missing,
             real_options,
-            common_keys,
+            common_keys if form_mapping is None else form.columns(),
             common_keys,
             interp_options,
             form_mapping=form_mapping,


Test patch:
Repository: apache/libcloud

Issue:
Error in resize function in OpenStack driver
When calling the "ex_resize" function of the OpenStack driver I get this error:
```
BaseHTTPError: 400 Bad Request Invalid input for field/attribute resize. Value: {u'flavorRef': u'8', 
 u'personality': [], u'name': u'userimage-156283439906', u'imageRef': u'0de96743-4a12-4470-b8b2-
 6dc260977a40', u'metadata': {}}. Additional properties are not allowed (u'metadata', u'name', 
 u'imageRef', u'personality' were unexpected)
```



Discussion:

Resolving patch:
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -1588,7 +1588,7 @@ def ex_resize(self, node, size):
 
         :rtype: ``bool``
         """
-        server_params = self._create_args_to_params(node, size=size)
+        server_params = {'flavorRef': size.id}
         resp = self._node_action(node, 'resize', **server_params)
         return resp.status == httplib.ACCEPTED
 


Test patch:
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -601,7 +601,10 @@ def _v1_0_slug_servers_444222_action(self, method, url, body, headers):
         body = u(body)
         if body.find('resize') != -1:
             # test_ex_resize_server
-            return (httplib.ACCEPTED, "", headers, httplib.responses[httplib.NO_CONTENT])
+            if body.find('personality') != -1:
+                return httplib.BAD_REQUEST
+            else:
+                return (httplib.ACCEPTED, "", headers, httplib.responses[httplib.NO_CONTENT])
         elif body.find('confirmResize') != -1:
             # test_ex_confirm_resize
             return (httplib.NO_CONTENT, "", headers, httplib.responses[httplib.NO_CONTENT])
Repository: apache/libcloud

Issue:
Error updating port in OpenStack driver
## Summary

There is an error in the ex_update_port function.
It returns 500 error.

## Detailed Information

There is an error in the request as the data parameter is not set.



Discussion:

Resolving patch:
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -3294,7 +3294,7 @@ def ex_update_port(self, port, description=None,
         if security_groups is not None:
             data['port']['security_groups'] = security_groups
         response = self.network_connection.request(
-            '/v2.0/ports/{}'.format(port.id), method='PUT'
+            '/v2.0/ports/{}'.format(port.id), method='PUT', data=data
         )
         return self._to_port(response.object['port'])
 


Test patch:
diff --git a/libcloud/test/compute/test_openstack.py b/libcloud/test/compute/test_openstack.py
--- a/libcloud/test/compute/test_openstack.py
+++ b/libcloud/test/compute/test_openstack.py
@@ -1907,7 +1907,7 @@ def test_ex_delete_port(self):
     def test_ex_update_port(self):
         port = self.driver.ex_get_port('126da55e-cfcb-41c8-ae39-a26cb8a7e723')
         ret = self.driver.ex_update_port(port, port_security_enabled=False)
-        self.assertEqual(port.extra['name'], 'Some port name')
+        self.assertEqual(ret.extra['name'], 'Some port name')
 
     def test_detach_port_interface(self):
         node = Node(id='1c01300f-ef97-4937-8f03-ac676d6234be', name=None,
@@ -2277,8 +2277,11 @@ def _v2_1337_v2_0_ports_126da55e_cfcb_41c8_ae39_a26cb8a7e723(self, method, url,
             body = self.fixtures.load('_port_v2.json')
             return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
         elif method == "PUT":
-            body = self.fixtures.load('_port_v2.json')
-            return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
+            if body:
+                body = self.fixtures.load('_port_v2.json')
+                return (httplib.OK, body, self.json_content_headers, httplib.responses[httplib.OK])
+            else:
+                return (httplib.INTERNAL_SERVER_ERROR, "", {}, httplib.responses[httplib.INTERNAL_SERVER_ERROR])
         else:
             raise NotImplementedError()
Repository: huggingface/diffusers

Issue:
Typo in StableDiffusionInpaintPipeline.disable_attention_slicing() method 
### Describe the bug

To enable/disable attention slicing, one need to use enable/disable_attention_slicing() method.

but in StableDiffusionInpaintPipeline class, there is misspelling in disable_attention_slicing() method.

`self.enable_attention_slice(None)` should be replaced as `self.enable_attention_slicing(None)`.

### Reproduction

_No response_

### Logs

```shell
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-cdc2e7fc6066> in <module>
     34 else:
     35     pipe.disable_attention_slicing()
---> 36     pipe_inpaint.disable_attention_slicing()
     37 
     38 for i in range(10):

/usr/local/lib/python3.7/dist-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py in disable_attention_slicing(self)
    119         """
    120         # set slice_size = `None` to disable `set_attention_slice`
--> 121         self.enable_attention_slice(None)
    122 
    123     @torch.no_grad()

AttributeError: 'StableDiffusionInpaintPipeline' object has no attribute 'enable_attention_slice'
```


### System Info

Google Colab Pro+ ( with V100 gpu )


Discussion:
Thanks @juno-hwang! The same thing happens in the `img2img` pipeline, will fix it.

Resolving patch:
diff --git a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py
--- a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py
+++ b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py
@@ -99,7 +99,7 @@ def disable_attention_slicing(self):
         back to computing attention in one step.
         """
         # set slice_size = `None` to disable `set_attention_slice`
-        self.enable_attention_slice(None)
+        self.enable_attention_slicing(None)
 
     @torch.no_grad()
     def __call__(
diff --git a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py
--- a/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py
+++ b/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py
@@ -118,7 +118,7 @@ def disable_attention_slicing(self):
         back to computing attention in one step.
         """
         # set slice_size = `None` to disable `set_attention_slice`
-        self.enable_attention_slice(None)
+        self.enable_attention_slicing(None)
 
     @torch.no_grad()
     def __call__(


Test patch: