internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ansible/ansible-modules-extras

Issue:
ec2_elb_facts should support check mode
##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ec2_elb_facts

##### ANSIBLE VERSION

```
ansible 2.2.0.0
  config file = 
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
*N/A*

##### OS / ENVIRONMENT
*N/A*

##### SUMMARY
Since the `ec2_elb_facts` is strictly a read-only operation, it should support running with `--check`

##### STEPS TO REPRODUCE

```sh
ansible-playbook \
    -i hosts \
    -l my-elb-host \
    ec2_elb_facts_check.yml \
    -vv \
    --check
```

```yaml
- hosts: all
  connection: local
  gather_facts: no

  tasks:
    - name: Collect ELB facts
      ec2_elb_facts:
        names: "my-elb"
        region: "us-east-1"
      register: elbfacts
      tags: always
```

##### EXPECTED RESULTS
It would be expected that `ec2_elb_facts` would still fetch the instance information. This being omitted, prevents the ability to enumerate ELB instance hosts, dynamically add them to the inventory, and then conduct `--check` mode against what would *actually* be getting done.

##### ACTUAL RESULTS

```
TASK [Collect ELB facts] ***********************************************
task path: /Projects/ec2_elb_facts_check.yml:6
skipping: [my-elb-host] => {
    "changed": false, 
    "skipped": true
}

MSG:

remote module (ec2_elb_facts) does not support check mode
```


Discussion:
<!-- @tomislacker: Thanks for filing this bug report! -->
@mjschultz ping, this issue is waiting for your response.
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: issue_bug_new --->

Resolving patch:
diff --git a/cloud/amazon/ec2_elb_facts.py b/cloud/amazon/ec2_elb_facts.py
--- a/cloud/amazon/ec2_elb_facts.py
+++ b/cloud/amazon/ec2_elb_facts.py
@@ -220,7 +220,8 @@ def main():
             names={'default': [], 'type': 'list'}
         )
     )
-    module = AnsibleModule(argument_spec=argument_spec)
+    module = AnsibleModule(argument_spec=argument_spec,
+                           supports_check_mode=True)
 
     if not HAS_BOTO:
         module.fail_json(msg='boto required for this module')


Test patch:
Repository: wandb/wandb

Issue:
wandb.restore doesn't respect root argument
The `root` argument for `wandb.restore` is described as follows:
> The directory to download the file to.  Defaults to the current directory or the run directory if wandb.init was called.

However when `wandb.init` has been called, it *always* uses the run directory, so the `root` argument has no effect.


Discussion:
Issue-Label Bot is automatically applying the label `bug` to this issue, with a confidence of 0.94. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback! 

 Links: [app homepage](https://github.com/marketplace/issue-label-bot), [dashboard](https://mlbot.net/data/wandb/client) and [code](https://github.com/hamelsmu/MLapp) for this bot.

Resolving patch:
diff --git a/wandb/__init__.py b/wandb/__init__.py
--- a/wandb/__init__.py
+++ b/wandb/__init__.py
@@ -540,7 +540,7 @@ def save(glob_str, base_path=None, policy="live"):
     return files
 
 
-def restore(name, run_path=None, replace=False, root="."):
+def restore(name, run_path=None, replace=False, root=None):
     """ Downloads the specified file from cloud storage into the current run directory
     if it doesn exist.
 
@@ -558,7 +558,7 @@ def restore(name, run_path=None, replace=False, root="."):
             "You must call `wandb.init` before calling restore or specify a run_path")
     api = Api()
     api_run = api.run(run_path or run.path)
-    root = run.dir if run else root
+    root = root or run.dir if run else "."
     path = os.path.join(root, name)
     if os.path.exists(path) and replace == False:
         return open(path, "r")


Test patch:
Repository: wandb/wandb

Issue:
Initialising error
`wandb --version && python --version && uname`

* Weights and Biases version: Latest
* Python version: 3
* Operating System:Linux

### Description

Not initialising 

### What I Did

```
`wandb.init(project="matting-disEntangleRes34DIM") `gives me error :
```

Traceback (most recent call last):
  File "disentangleNetDIMBlock.py", line 51, in <module>
    wandb.init(project="matting-disEntangleRes34DIM")
  File "/opt/anaconda3/lib/python3.7/site-packages/wandb/__init__.py", line 1067, in init
    _init_headless(run)
  File "/opt/anaconda3/lib/python3.7/site-packages/wandb/__init__.py", line 306, in _init_headless
    stdout_redirector = io_wrap.FileRedirector(sys.stdout, stdout_slave)
  File "/opt/anaconda3/lib/python3.7/site-packages/wandb/io_wrap.py", line 331, in __init__
    self._from_fd = redir_file.fileno()
AttributeError: 'IOBuffer' object has no attribute 'fileno'
```
```
It is working on my other machine but not this one, I am thinking maybe some requirment is off?


Discussion:
Issue-Label Bot is automatically applying the label `bug` to this issue, with a confidence of 0.91. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback! 

 Links: [app homepage](https://github.com/marketplace/issue-label-bot), [dashboard](https://mlbot.net/data/wandb/client) and [code](https://github.com/hamelsmu/MLapp) for this bot.

Resolving patch:
diff --git a/wandb/__init__.py b/wandb/__init__.py
--- a/wandb/__init__.py
+++ b/wandb/__init__.py
@@ -305,7 +305,7 @@ def _init_headless(run, cloud=True):
         try:
             stdout_redirector = io_wrap.FileRedirector(sys.stdout, stdout_slave)
             stderr_redirector = io_wrap.FileRedirector(sys.stderr, stderr_slave)
-        except ValueError:
+        except (ValueError, AttributeError):
             # stdout / err aren't files
             output = open(os.path.join(run.dir, "output.log"), "wb")
             stdout_redirector = io_wrap.WindowsRedirector(sys.stdout, output)


Test patch:
Repository: wandb/wandb

Issue:
wandb.restore doesn't respect root argument without wandb.init call
* Weights and Biases version: `0.8.22`
* Python version: `3.7.5`
* Operating System: Linux

### Description

The documentation describes the `root` argument of `wandb.restore()` as

> string specifying the directory in which to store the local copy of the file. This defaults to the current working directory, or the `wandb.run.dir` if wandb.init was called earlier (default: ".")

However the `root` argument has no affect if there was no previous `wandb.init` call:

### Test Code

```python
import wandb, os

f = wandb.restore('config.yaml', root='/tmp/foo', run_path="borisd13/colorizer/runs/dckzfkk5", replace=True) 
expected = os.path.join('/tmp/foo', 'config.yaml')               
actual = f.name               
print(f"actual='{actual}', expected='{expected}'")
```
prints
```
actual='./config.yaml', expected='/tmp/foo/config.yaml'
```
It works as expected with an additional `wandb.init()` call.



Discussion:

Resolving patch:
diff --git a/wandb/__init__.py b/wandb/__init__.py
--- a/wandb/__init__.py
+++ b/wandb/__init__.py
@@ -611,7 +611,8 @@ def restore(name, run_path=None, replace=False, root=None):
             "You must call `wandb.init` before calling restore or specify a run_path")
     api = Api()
     api_run = api.run(run_path or run.path)
-    root = root or run.dir if run else "."
+    if root is None:
+        root = run.dir if run else '.'
     path = os.path.join(root, name)
     if os.path.exists(path) and replace == False:
         return open(path, "r")


Test patch:
Repository: wandb/wandb

Issue:
Pre-binned histograms corrupted
`wandb --version && python --version && uname`

* Weights and Biases version: 0.8.32
* Python version: Python 3.6.9 :: Anaconda, Inc.
* Operating System: Linux (Ubuntu 18.04) and macOS (10.15.4)

### Description

Converted data to a histogram using `np.histogram` and logged a a `wandb.Histogram` object from the pre-binned data with `np_histogram`.

The histogram did not show up correctly in the workspace, and when I open the info for the run in the browser, I only get an error.

### What I Did

```python
histogram = np.histogram(rmsse.values, bins=64, range=(0, 5),
                                     density=False)
wandb.log({
                'WRMSSE': wrmsse,
                # 'level_WRMSSE': level_wrmsses,
                'series_RMSSE': wandb.Histogram(np_histogram=histogram)
            })
```

(I'll attach a pull request for a simple fix.)



Discussion:

Resolving patch:
diff --git a/wandb/data_types.py b/wandb/data_types.py
--- a/wandb/data_types.py
+++ b/wandb/data_types.py
@@ -93,8 +93,8 @@ def __init__(self, sequence=None, np_histogram=None, num_bins=64):
 
         if np_histogram:
             if len(np_histogram) == 2:
-                self.histogram = np_histogram[0]
-                self.bins = np_histogram[1]
+                self.histogram = np_histogram[0].tolist()
+                self.bins = np_histogram[1].tolist()
             else:
                 raise ValueError(
                     'Expected np_histogram to be a tuple of (values, bin_edges) or sequence to be specified')


Test patch:
Repository: wandb/wandb

Issue:
TeeHandler has no close method
```
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/wandb/sdk/wandb_run.py",
line 1172, in _atexit_cleanup
self._on_finish()
File "/opt/conda/lib/python3.7/site-packages/wandb/sdk/wandb_run.py",
line 1292, in _on_finish
self._console_stop() # TODO: there's a race here with jupyter console
logging
File "/opt/conda/lib/python3.7/site-packages/wandb/sdk/wandb_run.py",
line 1203, in _console_stop
self._restore()
File "/opt/conda/lib/python3.7/site-packages/wandb/sdk/wandb_run.py",
line 1140, in _restore
self._out_redir.uninstall()
File "/opt/conda/lib/python3.7/site-packages/wandb/lib/redirect.py",
line 207, in uninstall
self._redirect(to_fd=self._old_fp.fileno(), close=True)
File "/opt/conda/lib/python3.7/site-packages/wandb/lib/redirect.py",
line 161, in _redirect
fp.close()
AttributeError: 'TeeHandler' object has no attribute 'close'
```


Discussion:
Issue-Label Bot is automatically applying the label `bug` to this issue, with a confidence of 0.95. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback! 

 Links: [app homepage](https://github.com/marketplace/issue-label-bot), [dashboard](https://mlbot.net/data/wandb/client) and [code](https://github.com/hamelsmu/MLapp) for this bot.
I am running into the exact same bug using the 0.10.4 version on Linux. I posted on the WandB slack and I think they are working on a solution.

This happens to me at the end of every run (whether successful or model crashes).

Resolving patch:
diff --git a/wandb/lib/redirect.py b/wandb/lib/redirect.py
--- a/wandb/lib/redirect.py
+++ b/wandb/lib/redirect.py
@@ -164,7 +164,10 @@ def _redirect(self, to_fd, unbuffered=False, close=False):
             fp = getattr(sys, self._stream)
             # TODO(jhr): does this still work under windows?  are we leaking a fd?
             # Do not close old filedescriptor as others might be using it
-            fp.close()
+            try:
+                fp.close()
+            except Exception:
+                pass  # Stream might be wrapped by another program which doesn't support closing.
         os.dup2(to_fd, self._old_fd)
         if self._io_wrapped:
             if close:


Test patch:
Repository: wandb/wandb

Issue:
Allow renaming groups of completed runs
Is there any way to move a 'run' to another 'group' or changing the name of 'group'? I mistakenly set wrong group name for a run but couldn't find how to fix it!


Discussion:
Issue-Label Bot is automatically applying the label `enhancement` to this issue, with a confidence of 0.60. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback! 

 Links: [app homepage](https://github.com/marketplace/issue-label-bot), [dashboard](https://mlbot.net/data/wandb/client) and [code](https://github.com/hamelsmu/MLapp) for this bot.
I think this would be a very useful thing to have. It would be absurd to request the user the rerun his/her multiple days long training session just to get the grouping right. Some people want to keep things well organised, which is likely the very reason they started using wandb in the first place.
This issue is stale because it has been open 60 days with no activity.
+1
+1

Resolving patch:
diff --git a/wandb/apis/public.py b/wandb/apis/public.py
--- a/wandb/apis/public.py
+++ b/wandb/apis/public.py
@@ -1041,8 +1041,8 @@ def update(self):
         """
         mutation = gql(
             """
-        mutation UpsertBucket($id: String!, $description: String, $display_name: String, $notes: String, $tags: [String!], $config: JSONString!) {
-            upsertBucket(input: {id: $id, description: $description, displayName: $display_name, notes: $notes, tags: $tags, config: $config}) {
+        mutation UpsertBucket($id: String!, $description: String, $display_name: String, $notes: String, $tags: [String!], $config: JSONString!, $groupName: String) {
+            upsertBucket(input: {id: $id, description: $description, displayName: $display_name, notes: $notes, tags: $tags, config: $config, groupName: $groupName}) {
                 bucket {
                     ...RunFragment
                 }
@@ -1060,6 +1060,7 @@ def update(self):
             notes=self.notes,
             display_name=self.display_name,
             config=self.json_config,
+            groupName=self.group,
         )
         self.summary.update()
 


Test patch:
Repository: wandb/wandb

Issue:
[CLI] Recursion error when saving a numpy array with dtype float 128
**Description**
Hi there, there seems to be a bug when trying to log a np.float128 array onto wandb. It ends up giving a "RecursionError: maximum recursion depth exceeded in comparison" error. Code to reproduce it is attached below. 

**Wandb features**
wandb.log and init. 

**How to reproduce**
```python
import numpy as np
import wandb
wandb.init()
x = np.float128(0.0)
wandb.log({"test": x})
```


**Environment**
Weights and Biases version: 0.10.31
Python version: 3.9.5


Discussion:

Resolving patch:
diff --git a/wandb/util.py b/wandb/util.py
--- a/wandb/util.py
+++ b/wandb/util.py
@@ -460,6 +460,13 @@ def json_friendly(obj):
         obj = obj.item()
         if isinstance(obj, float) and math.isnan(obj):
             obj = None
+        elif isinstance(obj, np.generic) and obj.dtype.kind == "f":
+            # obj is a numpy float with precision greater than that of native python float
+            # (i.e., float96 or float128). in this case obj.item() does not return a native
+            # python float to avoid loss of precision, so we need to explicitly cast this
+            # down to a 64bit float
+            obj = float(obj)
+
     elif isinstance(obj, bytes):
         obj = obj.decode("utf-8")
     elif isinstance(obj, (datetime, date)):


Test patch:
diff --git a/tests/wandb_run_test.py b/tests/wandb_run_test.py
--- a/tests/wandb_run_test.py
+++ b/tests/wandb_run_test.py
@@ -4,8 +4,9 @@
 
 import os
 import sys
+import numpy as np
+import platform
 import pytest
-import yaml
 import wandb
 from wandb import wandb_sdk
 from wandb.proto.wandb_internal_pb2 import RunPreemptingRecord
@@ -60,6 +61,27 @@ def test_run_pub_history(fake_run, record_q, records_util):
     # TODO(jhr): check history vals
 
 
+@pytest.mark.skipif(
+    platform.system() == "Windows", reason="numpy.float128 does not exist on windows"
+)
+def test_numpy_high_precision_float_downcasting(fake_run, record_q, records_util):
+    # CLI: GH2255
+    run = fake_run()
+    run.log(dict(this=np.float128(0.0)))
+    r = records_util(record_q)
+    assert len(r.records) == 1
+    assert len(r.summary) == 0
+    history = r.history
+    assert len(history) == 1
+
+    found = False
+    for item in history[0].item:
+        if item.key == "this":
+            assert item.value_json == "0.0"
+            found = True
+    assert found
+
+
 def test_log_code_settings(live_mock_server, test_settings):
     with open("test.py", "w") as f:
         f.write('print("test")')
Repository: wandb/wandb

Issue:
Binary sklearn LogisticRegression and feature importance
Hi wandb team,

I am trying to plot the feature importance of a LogisticRegression model for binary classification problem. Then 
`model.coef_.shape == (1, n_features)`
and this check fails :
https://github.com/wandb/client/blob/63a5dd08e72fc20d3fe0eb5d441843870b0ed7f5/wandb/sklearn/__init__.py#L646
(unless we have n_features == 1)

I believe we should (at least) squeeze `importance` before the check and not have the else branch?

/Jens




Discussion:
Hi @dalgaard this seems reasonable. Let me look into this and get back to you.

Resolving patch:
diff --git a/wandb/sklearn/calculate/feature_importances.py b/wandb/sklearn/calculate/feature_importances.py
--- a/wandb/sklearn/calculate/feature_importances.py
+++ b/wandb/sklearn/calculate/feature_importances.py
@@ -26,7 +26,8 @@ def feature_importances(model, feature_names):
         importances = model.feature_log_prob_
 
     if len(importances.shape) > 1:
-        if np.prod(importances.shape) > importances.shape[0]:
+        n_significant_dims = sum([i > 1 for i in importances.shape])
+        if n_significant_dims > 1:
             nd = len(importances.shape)
             wandb.termwarn(
                 f"{nd}-dimensional feature importances array passed to plot_feature_importances. "


Test patch:
diff --git a/functional_tests/sklearn/02-fix-error-cond-feature-importances.py b/functional_tests/sklearn/02-fix-error-cond-feature-importances.py
new file mode 100644
--- /dev/null
+++ b/functional_tests/sklearn/02-fix-error-cond-feature-importances.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+"""Demonstrate fix for error condition for plotting feature importances in sklearn
+
+Reproduction for WB-6697
+
+---
+id: 0.sklearn.02-fix-error-cond-feature-importances
+plugin:
+  - wandb
+depend:
+  requirements:
+    - sklearn
+    - numpy
+assert:
+  - :wandb:runs_len: 1
+  - :wandb:runs[0][exitcode]: 0
+  - :yea:exit: 0
+  - :op:not_contains_regex:
+    - :wandb:runs[0][output][stderr]
+    - These importances will not be plotted
+  - :op:contains:
+    - :wandb:runs[0][telemetry][1]  # imports before
+    - 5  # sklearn
+  - :op:contains:
+    - :wandb:runs[0][telemetry][2]  # imports after
+    - 5  # sklearn
+"""
+
+import numpy as np
+from sklearn.linear_model import LogisticRegression
+import wandb
+
+wandb.init()
+
+# Load data
+X = np.random.uniform(size=(100, 10))
+
+# binary classification problem
+y = np.round(np.random.uniform(size=100)).astype(int)
+
+# Train model, log feature importances.
+model = LogisticRegression()
+model.fit(X, y)
+
+# before the fix in wb-6697 this should have produced a warning and
+# caused the feature importances not to be logged
+wandb.sklearn.plot_feature_importances(model)
Repository: wandb/wandb

Issue:
[Q] Drop dependency on backported configparser?
If I'm reading the setup.py correctly, python version must be 3.6+ which means wandb shouldn't need the backported configparser as a dep? and should be able to get along using the stdlib one?

[configparser dependency](https://github.com/wandb/client/blob/master/requirements.txt#L13)


Discussion:
@jbylund looks like a vestigial dep from when we supported `2.7` and `3.5` but let me double check. 
Looks like typing, enum34, and subprocess32 can maybe also be added to the list to go?

Resolving patch:
diff --git a/wandb/sdk/internal/internal_api.py b/wandb/sdk/internal/internal_api.py
--- a/wandb/sdk/internal/internal_api.py
+++ b/wandb/sdk/internal/internal_api.py
@@ -14,11 +14,7 @@
 import requests
 import socket
 import sys
-
-if os.name == "posix" and sys.version_info[0] < 3:
-    import subprocess32 as subprocess  # type: ignore
-else:
-    import subprocess  # type: ignore[no-redef]
+import subprocess
 
 from copy import deepcopy
 import six
@@ -912,7 +908,7 @@ def create_run_queue(self, entity, project, queue_name, access):
                 success
                 queueID
             }
-            
+
         }
         """
         )
diff --git a/wandb/sdk/internal/meta.py b/wandb/sdk/internal/meta.py
--- a/wandb/sdk/internal/meta.py
+++ b/wandb/sdk/internal/meta.py
@@ -10,6 +10,7 @@
 import multiprocessing
 import os
 from shutil import copyfile
+import subprocess
 import sys
 from urllib.parse import unquote
 
@@ -24,11 +25,6 @@
 )
 from ..lib.git import GitRepo
 
-if os.name == "posix" and sys.version_info[0] < 3:
-    import subprocess32 as subprocess  # type: ignore[import]
-else:
-    import subprocess  # type: ignore[no-redef]
-
 
 logger = logging.getLogger(__name__)
 


Test patch:
Repository: wandb/wandb

Issue:
[CLI]: args for "Command" are not saved with the run when using `wandb.require("service")`
### Describe the bug

When `wandb.require("service")` is used and a new wandb experiment is created, the command line arguments of the python script are not saved at all - not in the local files/logs and not in the server.  

To reproduce:
```python 
import sys
import wandb
sys.argv=["script.py", "--arg1", "--arg2"]
wandb.require("service")
wandb.init()
```
The web UI will show `Command` `script.py`  

---
Expected behavior can be seen with the following code:
```python 
import sys
import wandb
sys.argv=["script.py", "--arg1", "--arg2"]
wandb.init()
```
The web UI will show `Command` `script.py --arg1 --arg2`  

### Environment

WandB version: 0.12.11

OS: Ubuntu 20.04

Python version: 3.9.7



Discussion:

Resolving patch:
diff --git a/wandb/sdk/service/service_base.py b/wandb/sdk/service/service_base.py
--- a/wandb/sdk/service/service_base.py
+++ b/wandb/sdk/service/service_base.py
@@ -5,10 +5,10 @@
 """
 
 from abc import abstractmethod
+from collections.abc import Iterable, Mapping
 import datetime
 import enum
-from typing import Any, Dict
-from typing import TYPE_CHECKING
+from typing import Any, Dict, TYPE_CHECKING
 
 from wandb.proto import wandb_server_pb2 as spb
 from wandb.sdk.wandb_settings import Settings
@@ -39,8 +39,10 @@ def _pbmap_apply_dict(
             sv.float_value = v
         elif isinstance(v, str):
             sv.string_value = v
-        elif isinstance(v, tuple):
+        elif isinstance(v, Iterable) and not isinstance(v, (str, bytes, Mapping)):
             sv.tuple_value.string_values.extend(v)
+        else:
+            raise Exception("unsupported type")
         m[k].CopyFrom(sv)
 
 


Test patch: