internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: engnadeau/pybotics

Issue:
Add Package to PyPi



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,14 +1,59 @@
+import pypandoc
 from setuptools import setup
+import os
+import git
+
+# tag version
+repo = git.Repo(os.getcwd())
+tag = repo.tags[-1]
+version = tag.name
+
+# requirements
+with open('requirements.txt') as f:
+    requirements = f.read().splitlines()
+
+# long description
+# TODO: pypandoc.convert() function returns wrong RST format, but saving/loading a file works
+file_path = os.path.abspath(os.path.dirname(__file__))
+pypandoc.convert_file('README.md', 'rst', outputfile=os.path.join(file_path, 'README.rst'))
+with open(os.path.join(file_path, 'README.rst'), encoding='utf-8') as f:
+    description = f.read()
 
 setup(
     name='pybotics',
-    version='0.1.3',
-    packages=['examples', 'pybotics', 'tests'],
+    version=version,
+    packages=['pybotics'],
     url='https://github.com/nnadeau/pybotics',
     license='MIT',
     author='Nicholas Nadeau',
-    author_email='',
+    author_email='nicholas.nadeau@gmail.com',
     description='Python Toolbox for Robotics',
+    long_description=description,
+    install_requires=requirements,
     setup_requires=['pytest-runner'],
-    tests_require=['pytest']
+    tests_require=['pytest'],
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Intended Audience :: Developers',
+        'Intended Audience :: Education',
+        'Intended Audience :: End Users/Desktop',
+        'Intended Audience :: Manufacturing',
+        'Intended Audience :: Science/Research',
+        'Topic :: Education',
+        'Topic :: Scientific/Engineering',
+        'Topic :: Scientific/Engineering :: Artificial Intelligence',
+        'Topic :: Scientific/Engineering :: Human Machine Interfaces',
+        'Topic :: Scientific/Engineering :: Mathematics',
+        'Topic :: Scientific/Engineering :: Physics',
+        'Topic :: Utilities',
+        'License :: OSI Approved :: MIT License',
+        'Programming Language :: Python :: 3 :: Only',
+        'Programming Language :: Python :: 3',
+        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
+        'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
+    ],
+    keywords='python robot robotics research automation kinematics geometry',
 )


Test patch:
diff --git a/tests/test_robot.py b/tests/test_robot.py
--- a/tests/test_robot.py
+++ b/tests/test_robot.py
@@ -53,7 +53,11 @@ def test_ik(robot):
 
         robot.joint_angles = test_joints_list[0]
         ik_joints = robot.ik(expected_transform)
-        assert ik_joints is not None
+
+        # TODO: design IK to not be iterative?
+        # TODO: deal with IK returning None if no solution is found
+        if ik_joints is None:
+            continue
 
         robot.joint_angles = ik_joints
         result_transform = robot.fk()
Repository: engnadeau/pybotics

Issue:
Update Python requirements in README and on PyPi
- Requirements badge should reflect current requirements
- https://pypi.python.org/pypi/pybotics


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -39,8 +39,6 @@
         'License :: OSI Approved :: MIT License',
         'Programming Language :: Python :: 3 :: Only',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.2',
-        'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',


Test patch:
Repository: engnadeau/pybotics

Issue:
Fix PyPI README
## Expected Behavior
- The look of https://pypi.org/project/pybotics/0.2.7/

## Actual Behavior
- Broke RST format: https://pypi.python.org/pypi/pybotics/0.3.0



Discussion:

Resolving patch:
diff --git a/convert_readme.py b/convert_readme.py
deleted file mode 100644
--- a/convert_readme.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import pypandoc
-import os
-import logging
-
-logging.basicConfig(level=logging.INFO)
-
-logging.info('Converting markdown README to RST for PyPI')
-logging.info('Pandoc version:\t{}'.format(pypandoc.get_pandoc_version()))
-
-root_path = os.path.dirname(__file__)
-logging.info('Root path:\t{}'.format(root_path))
-
-input_file = os.path.join(root_path, 'README.md')
-output_file = os.path.join(root_path, 'README.rst')
-
-logging.info('Input file:\t{}'.format(input_file))
-logging.info('Output file:\t{}'.format(output_file))
-
-pypandoc.convert_file(input_file, 'rst', outputfile=os.path.join(root_path, output_file))
-logging.info('Conversion complete')


Test patch:
Repository: engnadeau/pybotics

Issue:
Strip README badges from PyPi RST version



Discussion:
Badges are actually quite nice when well organized

Resolving patch:
diff --git a/clean_readme.py b/clean_readme.py
new file mode 100644
--- /dev/null
+++ b/clean_readme.py
@@ -0,0 +1,25 @@
+from pandocfilters import toJSONFilter
+
+
+def strip_links(key, value, *_):
+    # strip readme badges
+    if key == 'Para':
+        if value[0]['t'] == 'Link' and value[0]['c'][0][0]['t'] == 'Image':
+            return []
+
+    # turn links to text
+    if key == 'Link':
+        return value[0]
+
+    # strip raw html, logo, and ruled lines
+    if key in ['RawBlock', 'HorizontalRule', 'Image']:
+        return []
+
+
+if __name__ == "__main__":
+    toJSONFilter(strip_links)
+
+    # debugging
+    # with open('README.json') as f:
+    #     doc = json.load(f)
+    #     walk(doc, strip_links, '', '')
diff --git a/update_version.py b/update_version.py
--- a/update_version.py
+++ b/update_version.py
@@ -10,9 +10,36 @@
 logging.info('Root path:\t{}'.format(root_path))
 
 repo = git.Repo(root_path)
-tag = repo.tags[-1]
-version = tag.name
-logging.info('Latest git tag:\t{}'.format(version))
+logging.info('Repo:\t{}'.format(repo))
+
+latest_tag = repo.tags[-1]
+logging.info('Latest tag:\t{}'.format(latest_tag))
+
+travis_commit = os.environ.get('TRAVIS_COMMIT')
+logging.info('Travis commit:\t{}'.format(travis_commit))
+
+sha = repo.head.object.hexsha
+logging.info('Last commit sha:\t{}'.format(sha))
+
+short_sha = repo.git.rev_parse(sha, short=4)
+logging.info('Last commit short sha:\t{}'.format(short_sha))
+
+travis_branch = os.environ.get('TRAVIS_BRANCH')
+logging.info('Travis branch:\t{}'.format(travis_branch))
+
+travis_pr_branch = os.environ.get('TRAVIS_PULL_REQUEST_BRANCH')
+logging.info('Travis PR branch:\t{}'.format(travis_pr_branch))
+
+travis_tag = os.environ.get('TRAVIS_TAG')
+travis_tag = travis_tag if travis_tag is not None else ''
+logging.info('Travis tag:\t{}'.format(travis_tag))
+
+if len(travis_tag) > 0:
+    version = '{}'.format(latest_tag)
+else:
+    version = '{}.dev{}'.format(latest_tag, int(short_sha, 16))
+
+logging.info('Package version:\t{}'.format(version))
 
 output_file = os.path.join(root_path, 'VERSION')
 logging.info('Writing version info to:\t{}'.format(output_file))


Test patch:
Repository: engnadeau/pybotics

Issue:
pybotics\robot.py:32: Unused attribute 'name'
## Expected Behavior
- `vulture` passes

## Actual Behavior
- `vulture` fails

## Steps to Reproduce the Problem
1. `vulture .`

## Specifications
```
Platform: Windows-10-10.0.15063-SP0
Machine: AMD64
Python: 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)]
module 'pybotics' has no attribute '__version__'
NumPy: 1.13.0
SciPy: 0.19.1
```



Discussion:

Resolving patch:
diff --git a/pybotics/robot.py b/pybotics/robot.py
--- a/pybotics/robot.py
+++ b/pybotics/robot.py
@@ -19,8 +19,7 @@ class Robot:
     def __init__(self,
                  robot_model: np.ndarray,
                  tool: Tool = Tool(),
-                 world_frame: np.ndarray = None,
-                 name: str = 'Pybot') -> None:
+                 world_frame: np.ndarray = None) -> None:
         """Construct a Robot object.
 
         :param robot_model: Modified Denavit-Hartenberg (MDH) parameters, size=[number of joints, 4]
@@ -29,7 +28,6 @@ def __init__(self,
         :param name: robot name
         """
         # public members
-        self.name = name
         self.robot_model = robot_model.reshape((-1, 4))
         self.tool = tool
         self.world_frame = np.eye(4) if world_frame is None else world_frame


Test patch:
Repository: engnadeau/pybotics

Issue:
Flaky `test_fk()` results
- Fails occasionally due to a small difference in the x-component of the transform matrix
  - https://ci.appveyor.com/project/nnadeau/pybotics/build/1.0.732/job/c9mmdfvctt9jasie
  - https://ci.appveyor.com/project/nnadeau/pybotics/build/1.0.732/job/qs645jqgd49iwa3s
- This corresponds to the first row of the UR10 resources
```
-45.0,147.0,-39.0,96.0,49.0,67.0,-0.10936549564013165,0.9937209495290638,0.02361912001841469,341.25528339185024,-0.30766985716369466,-0.011247226994026319,-0.9514266965341137,-658.5887448195482,-0.       9451869906829335,-0.11132014351410438,0.30696804115695675,-625.3245786240964,0.0,0.0,0.0,1.0
```



Discussion:

Resolving patch:
diff --git a/pybotics/predefined_models.py b/pybotics/predefined_models.py
--- a/pybotics/predefined_models.py
+++ b/pybotics/predefined_models.py
@@ -1,4 +1,5 @@
 """Predefined robot models."""
+from copy import deepcopy
 from typing import Any
 
 import numpy as np  # type: ignore
@@ -25,7 +26,7 @@ class KukaLBRiiwa7(Robot):
 
     def __init__(self, **kwargs: Any) -> None:
         """Init robot."""
-        super().__init__(self.kinematic_chain, **kwargs)
+        super().__init__(deepcopy(self.kinematic_chain), **kwargs)
 
 
 class MecademicMeca500(Robot):
@@ -45,7 +46,7 @@ class MecademicMeca500(Robot):
 
     def __init__(self, **kwargs: Any) -> None:
         """Init robot."""
-        super().__init__(self.kinematic_chain, **kwargs)
+        super().__init__(deepcopy(self.kinematic_chain), **kwargs)
 
 
 class PUMA560(Robot):
@@ -65,7 +66,7 @@ class PUMA560(Robot):
 
     def __init__(self, **kwargs: Any) -> None:
         """Init robot."""
-        super().__init__(self.kinematic_chain, **kwargs)
+        super().__init__(deepcopy(self.kinematic_chain), **kwargs)
 
 
 class UR10(Robot):
@@ -85,4 +86,4 @@ class UR10(Robot):
 
     def __init__(self, **kwargs: Any) -> None:
         """Init robot."""
-        super().__init__(self.kinematic_chain, **kwargs)
+        super().__init__(deepcopy(self.kinematic_chain), **kwargs)


Test patch:
Repository: engnadeau/pybotics

Issue:
Strip links/badges/images from README for PyPi
- While the new PyPi Warehouse supports markdown, images/badges/links are slow to load and will not work if they use relative paths (e.g., https://test.pypi.org/project/pybotics/201803222157/#description)
- These elements should be stripped from the README prior to upload


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,7 @@ def main() -> None:
           long_description=get_readme(),
           long_description_content_type='text/markdown',
           use_scm_version=True,
-          setup_requires=['setuptools_scm'],
+          setup_requires=['setuptools', 'setuptools_scm'],
           install_requires=get_requirements(),  # type: ignore
           tests_require=['pytest'],
           classifiers=[


Test patch:
Repository: engnadeau/pybotics

Issue:
Create a way to add your own arm model[FEATURE]
## User Story

<!-- A clear and concise description of what the problem is. 
I want to add my own arm configuration to the list of pre-trained models.

## Potential Solutions

<!-- A clear and concise description of what you want to happen. -->
If there was a comment next to each line of one of the arrays containing the pre-trained model saying what exactly each value was supposed to represent, that would help.
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
I tried looking at the spec sheets of the arms and matching up values but I couldn't figure much out. 




Discussion:

Resolving patch:
diff --git a/pybotics/predefined_models.py b/pybotics/predefined_models.py
--- a/pybotics/predefined_models.py
+++ b/pybotics/predefined_models.py
@@ -1,4 +1,8 @@
-"""Predefined robot models."""
+"""Predefined robot models.
+
+These models correspond to the Modified Denavit–Hartenberg parameters:
+https://en.wikipedia.org/wiki/Denavit%E2%80%93Hartenberg_parameters
+"""
 import numpy as np  # type: ignore
 
 


Test patch:
Repository: DataDog/dd-agent

Issue:
cacti support on CentOS 5 is broken
```
import rrdtool
```

fails in our check even after python-rrdtool is installed. Cause: it only installs cacti for python2.4, not python2.6.

In other words, when you run:

```
yum install python-rrdtool
```

the `rrdtool` module is only available under python(2.4), not python2.6.

datadog-agent-base runs with python2.6 if it's installed along with datadog-agent.

Solution:
1. if python2.4 is installed (which is the case for CentOS5), force datadog-agent base to run with python2.4, not python2.6.



Discussion:
Here's the offending line: https://github.com/DataDog/dd-agent/blob/master/packaging/datadog-agent/rpm/supervisor.conf#L16

Using simply `/usr/bin/python` will force the right python (2.4) on CentOS5 and 6 (where it runs 2.6)


Resolving patch:
diff --git a/config.py b/config.py
--- a/config.py
+++ b/config.py
@@ -25,7 +25,7 @@ def get_parsed_args():
     return options, args
 
 def get_version():
-    return "2.2.9"
+    return "2.2.10"
 
 def skip_leading_wsp(f):
     "Works on a file, returns a file-like object"


Test patch:
Repository: DataDog/dd-agent

Issue:
Cacti support: if an RRD file is missing, skip it and don't crash the check
File does not actually exist. Not sure why but the check should cope with it more gracefully.

```
2012-04-20 07:58:28,092 - checks - ERROR - Cannot check CactiTraceback (most recent call last):
File "/usr/share/datadog/agent/checks/cacti.py", line 195, in check metrics.extend(
File "/usr/share/datadog/agent/checks/cacti.py", line 109, in _read_rrd c_funcs = self._consolidation_funcs(rrd_path, rrdtool)
File "/usr/share/datadog/agent/checks/cacti.py", line 98, in _consolidation_funcs info = rrdtool.info(rrd_path)error: opening '/var/www/html/cacti/rra/sjl01lscomtest01_tcpinuse_32539.rrd': No such file or directory
```



Discussion:

Resolving patch:
diff --git a/checks/cacti.py b/checks/cacti.py
--- a/checks/cacti.py
+++ b/checks/cacti.py
@@ -3,6 +3,8 @@
 import os
 import time
 
+class RRDReadException(Exception): pass
+
 class Cacti(Check):
     CFUNC_TO_AGGR = {
         'AVERAGE': 'avg',
@@ -95,7 +97,12 @@ def _consolidation_funcs(self, rrd_path, rrdtool):
         ''' Determine the available consolidation functions for this rrd '''
         import rrdtool
 
-        info = rrdtool.info(rrd_path)
+        try:
+            info = rrdtool.info(rrd_path)
+        except:
+            self.logger.warn("Unable to read RRD file at %s" % (rrd_path))
+            raise RRDReadException(rrdpath)
+
         funcs = []
         for k,v in info.items():
             if k.endswith('.cf'):
@@ -106,7 +113,12 @@ def _read_rrd(self, rrd_path, host_name, device_name):
         import rrdtool
 
         metrics = []
-        c_funcs = self._consolidation_funcs(rrd_path, rrdtool)
+        try:
+            c_funcs = self._consolidation_funcs(rrd_path, rrdtool)
+        except RRDReadException:
+            # Unable to read RRD file, ignore it by returning an empty list
+            return []
+
         start = self.last_ts.get(rrd_path, 0)
 
         for c in c_funcs:
diff --git a/config.py b/config.py
--- a/config.py
+++ b/config.py
@@ -25,7 +25,7 @@ def get_parsed_args():
     return options, args
 
 def get_version():
-    return "2.2.11"
+    return "2.2.12"
 
 def skip_leading_wsp(f):
     "Works on a file, returns a file-like object"


Test patch:
Repository: DataDog/dd-agent

Issue:
Send the api key in the headers instead of the http body
If the api key is in the headers, that means the dispatcher won't need to deserialize the whole agent payload just to read the api key and can just queue the payload string without using any cpu on the frontends. 



Discussion:

Resolving patch:
diff --git a/emitter.py b/emitter.py
--- a/emitter.py
+++ b/emitter.py
@@ -33,12 +33,15 @@ def http_emitter(message, logger, agentConfig):
         logger.debug('http_emitter: attempting postback: ' + agentConfig['ddUrl'])
         
         # Build the request handler
-        request = urllib2.Request(agentConfig['ddUrl'] + '/intake/', postBackData, headers(agentConfig))
-        
-        # Do the request, log any errors
-        response = urllib2.urlopen(request)
-        
-        logger.debug('http_emitter: postback response: ' + str(response.read()))
+        apiKey = message.get('apiKey', None)
+        if apiKey:
+            request = urllib2.Request("%s/intake?api_key=%s" % (agentConfig['ddUrl'], apiKey), postBackData, headers(agentConfig))
+            # Do the request, log any errors
+            response = urllib2.urlopen(request)
+            
+            logger.debug('http_emitter: postback response: ' + str(response.read()))
+        else:
+            logger.error("No api key, not sending payload")
             
     except urllib2.HTTPError, e:
         logger.error('http_emitter: HTTPError = ' + str(e))


Test patch:
Repository: DataDog/dd-agent

Issue:
DogstatsD should handle batch queries
From the statsd README:

"All metrics can also be batch send in a single UDP packet, separated by a newline character."



Discussion:

Resolving patch:
diff --git a/config.py b/config.py
--- a/config.py
+++ b/config.py
@@ -68,7 +68,7 @@ def _windows_config_path():
     result = _SHGetFolderPath(0, CSIDL_COMMON_APPDATA, 0, 0, path_buf)
     common_data = path_buf.value
 
-    path = os.path.join(common_data, 'Datadog Agent', DATADOG_CONF)
+    path = os.path.join(common_data, 'Datadog', DATADOG_CONF)
     if os.path.exists(path):
         return path
     raise DDConfigNotFound(path)
@@ -334,7 +334,7 @@ def set_win32_cert_path():
     will be able to override this in a clean way. For now, we have to monkey patch
     tornado.httpclient._DEFAULT_CA_CERTS
     '''
-    crt_path = os.path.join(os.environ['PROGRAMFILES'], 'Datadog Agent',
+    crt_path = os.path.join(os.environ['PROGRAMFILES'], 'Datadog', 'Datadog Agent',
         'ca-certificates.crt')
     import tornado.simple_httpclient
     tornado.simple_httpclient._DEFAULT_CA_CERTS = crt_path


Test patch:
Repository: DataDog/dd-agent

Issue:
Dogstream aggregate should sum counters
Right now if you submit a counter from dogstream it just sends that value multiple times for the same timestamp. It should sum across before sending the metric.



Discussion:
To be a bit more clear --

`checks.datadog.Dogstream._aggregate()` takes the median value for each second, regardless of whether a value is a counter or a gauge.

Thus, a single packet sent to datadog can include multiple values for a counter (at different seconds); however, all but one value per second will be discarded -- whereas for a counter, the correct behavior is clearly to sum them.


Resolving patch:
diff --git a/checks/datadog.py b/checks/datadog.py
--- a/checks/datadog.py
+++ b/checks/datadog.py
@@ -304,7 +304,7 @@ def _aggregate(self, values):
             if metric_type == 'gauge':
                 val = float(val)
             elif metric_type == 'counter':
-                val = int(val)
+                val = sum(vals)
 
             output.append((metric, timestamp, val, attributes))
 


Test patch:
diff --git a/tests/test_datadog.py b/tests/test_datadog.py
--- a/tests/test_datadog.py
+++ b/tests/test_datadog.py
@@ -152,8 +152,8 @@ def test_dogstream_counter(self):
         
         expected_output = {
             "dogstream": [
-                ('test.metric.a', 1000000000, 5, self.counter),
-                ('test.metric.a', 1000000005, 8, self.counter),
+                ('test.metric.a', 1000000000, 42, self.counter),
+                ('test.metric.a', 1000000005, 27, self.counter),
             ]
         }
Repository: DataDog/dd-agent

Issue:
add all host name values to status
For easier debugging



Discussion:

Resolving patch:
diff --git a/checks/check_status.py b/checks/check_status.py
--- a/checks/check_status.py
+++ b/checks/check_status.py
@@ -237,14 +237,33 @@ class CollectorStatus(AgentStatus):
 
     NAME = 'Collector'
 
-    def __init__(self, check_statuses=None, emitter_statuses=None):
+    def __init__(self, check_statuses=None, emitter_statuses=None, metadata=None):
         AgentStatus.__init__(self)
         self.check_statuses = check_statuses or []
         self.emitter_statuses = emitter_statuses or []
+        if metadata is not None:
+            self.metadata = ','.join(k + ':' + v for (k,v) in metadata.items())
+        else:
+            self.metadata = []
 
     def body_lines(self):
-        # Checks.d Status
+        # Hostnames
         lines = [
+            'Hostnames',
+            '=========',
+            ''
+        ]
+        if not self.metadata:
+            lines.append("  No host information available yet.")
+        else:
+            host_info = dict(item.split(":") for item in self.metadata.split(","))
+            for key, host in host_info.items():
+                lines.append("  " + key + ": " + host)
+
+        lines.append('')
+
+        # Checks.d Status
+        lines += [
             'Checks',
             '======',
             ''
@@ -276,7 +295,8 @@ def body_lines(self):
         lines += [
             "",
             "Emitters",
-            "========"
+            "========",
+            ""
         ]
         if not self.emitter_statuses:
             lines.append("  No emitters have run yet.")
diff --git a/checks/collector.py b/checks/collector.py
--- a/checks/collector.py
+++ b/checks/collector.py
@@ -56,6 +56,7 @@ def __init__(self, agentConfig, emitters, systemStats):
         socket.setdefaulttimeout(15)
         self.run_count = 0
         self.continue_running = True
+        self.metadata_cache = None
         
         # Unix System Checks
         self._unix_system_checks = {
@@ -319,7 +320,7 @@ def run(self, checksd=None):
 
         # Persist the status of the collection run.
         try:
-            CollectorStatus(check_statuses, emitter_statuses).persist()
+            CollectorStatus(check_statuses, emitter_statuses, self.metadata_cache).persist()
         except Exception:
             logger.exception("Error persisting collector status")
 
@@ -378,6 +379,7 @@ def _build_payload(self):
         # Periodically send the host metadata.
         if self._is_first_run() or self._should_send_metadata():
             payload['meta'] = self._get_metadata()
+            self.metadata_cache = payload['meta']
             # Add static tags from the configuration file
             if self.agentConfig['tags'] is not None:
                 payload['tags'] = self.agentConfig['tags']


Test patch: