anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: juniper/py-junos-eznc
Issue: sw.install all_re option documentation is incorrect 

https://github.com/Juniper/py-junos-eznc/blob/dabef6dc29af8017d5eb8ae4be70daa7a42b77d6/lib/jnpr/junos/utils/sw.py#L782-L785

Will raise a PR to fix this in a week.

Changed files:
lib/jnpr/junos/utils/sw.py

diff --git a/lib/jnpr/junos/utils/sw.py b/lib/jnpr/junos/utils/sw.py
index cc3ac3c7..0aac9676 100644
--- a/lib/jnpr/junos/utils/sw.py
+++ b/lib/jnpr/junos/utils/sw.py
@@ -781,9 +781,9 @@ class SW(Util):
           checksum, then skip the copy to optimize time.
 
         :param bool all_re:
-          (Optional) When ``True`` (default) perform the software install on
-          all Routing Engines of the Junos device. When ``False``  if the
-          only preform the software install on the current Routing Engine.
+          (Optional) When ``True`` (default) install the package on
+          all Routing Engines of the Junos device. When ``False`` perform
+          the software install only on the current Routing Engine.
 
         :param bool vmhost:
           (Optional) A boolean indicating if this is a software update of the
Repository: juniper/py-junos-eznc
Issue: PyEZ 2.0.0 version StartShell throws UnicodeDecodeError for special chars

xxxx@xxxx-re0> request routing-engine login other-routing-engine
▒▒Last login: Fri Sep  2 09:39:55 on tty??

--- JUNOS 15.1R4.6 Kernel 64-bit  JNPR-10.1-20160616.329709_builder_stable_10
▒xxxx@xxxx-re1>

``` python
    result = ss.run('request routing-engine login other-routing-engine', '> ')
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/start_shell.py", line 132, in run
    got = ''.join(self.wait_for(this, timeout))
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/start_shell.py", line 62, in wait_for
    data = data.decode('utf-8')
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte
```


Changed files:
lib/jnpr/junos/utils/start_shell.py

diff --git a/lib/jnpr/junos/utils/start_shell.py b/lib/jnpr/junos/utils/start_shell.py
index b6a7e124..07956c0e 100644
--- a/lib/jnpr/junos/utils/start_shell.py
+++ b/lib/jnpr/junos/utils/start_shell.py
@@ -59,7 +59,7 @@ class StartShell(object):
             if rd:
                 data = chan.recv(_RECVSZ)
                 if isinstance(data, bytes):
-                    data = data.decode('utf-8')
+                    data = data.decode('utf-8', 'replace')
                 got.append(data)
                 if re.search(r'{0}\\s?$'.format(this), data):
                     break
Repository: juniper/py-junos-eznc
Issue: Device password setter doesn't work

The Device class includes a setter for the password property with the comment:
"Change the authentication password value.  This is handy in case the calling program needs to attempt different passwords."

However, this setter doesn't work:

```
>>> from jnpr.junos import Device
>>> r0 = Device(host='r0',password='incorrect')
>>> r0._password
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Device' object has no attribute '_password'
>>> r0._auth_password
'incorrect'
>>> r0.open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 414, in open
    raise EzErrors.ConnectAuthError(self)
jnpr.junos.exception.ConnectAuthError: ConnectAuthError(r0)
>>> r0.password = 'user123'
>>> r0._password
'user123'
>>> r0._auth_password
'incorrect'
>>> r0.open()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/device.py", line 414, in open
    raise EzErrors.ConnectAuthError(self)
jnpr.junos.exception.ConnectAuthError: ConnectAuthError(r0)
```

It ends up setting the self._password attribute when it should have set the self._auth_password attribute.


Changed files:
lib/jnpr/junos/device.py, tests/unit/test_device.py

diff --git a/lib/jnpr/junos/device.py b/lib/jnpr/junos/device.py
index e000479a..e63245ab 100644
--- a/lib/jnpr/junos/device.py
+++ b/lib/jnpr/junos/device.py
@@ -129,7 +129,7 @@ class Device(object):
         Change the authentication password value.  This is handy in case
         the calling program needs to attempt different passwords.
         """
-        self._password = value
+        self._auth_password = value
 
     # ------------------------------------------------------------------------
     # property: logfile
diff --git a/tests/unit/test_device.py b/tests/unit/test_device.py
index 79d9a7cd..65734233 100644
--- a/tests/unit/test_device.py
+++ b/tests/unit/test_device.py
@@ -221,7 +221,7 @@ class TestDevice(unittest.TestCase):
 
     def test_device_set_password(self):
         self.dev.password = 'secret'
-        self.assertEqual(self.dev._password, 'secret')
+        self.assertEqual(self.dev._auth_password, 'secret')
 
     def test_device_get_timeout(self):
         self.assertEqual(self.dev.timeout, 30)
Repository: juniper/py-junos-eznc
Issue: Config.lock() return exception when normalize is on

> > > dev=Device('172.27.62.164',user='root',passwd='lab123',normalize=True)
> > > dev.open()
> > > Device(172.27.62.164)
> > > cu=Config(dev)
> > > cu.lock()
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in <module>
> > >   File "/root/pyez2.0/lib/python2.7/site-packages/jnpr/junos/utils/config.py", line 467, in lock
> > >     raise LockError(rsp=JXML.remove_namespaces(err.xml))
> > > AttributeError: 'exceptions.AttributeError' object has no attribute 'xml'

If normalize is not enabled, no problem
This problem is introduced in pyez 2.0


Changed files:
lib/jnpr/junos/device.py

diff --git a/lib/jnpr/junos/device.py b/lib/jnpr/junos/device.py
index 9c335e50..c2bd3712 100644
--- a/lib/jnpr/junos/device.py
+++ b/lib/jnpr/junos/device.py
@@ -919,7 +919,7 @@ class Device(_Connection):
             #    protocol: operation-failed
             #    error: device asdf not found
             # </rpc-reply>
-            if rpc_rsp_e.text.strip() is not '':
+            if rpc_rsp_e.text is not None and rpc_rsp_e.text.strip() is not '':
                 return rpc_rsp_e
             # no children, so assume it means we are OK
             return True
Repository: juniper/py-junos-eznc
Issue: domain-name configured in configuration group is not checked by facts_domain()

facts_domain() does not check to see if a domain-name is configured in a configuration group.

Given a configuration like this:

```user@r0> show configuration groups global system domain-name 
example.com;

user@r0> show configuration system domain-name 

user@r0> show configuration system domain-name | display inheritance no-comments 
domain-name example.com;

```

facts_domain() will not find the example.com domain in the configuration.

In most cases, it will successfully revert to finding the configuration in the resolv.conf file, but I'm not sure that would work in logical-system configs + configuration groups.

In all cases where the configuration is being checked for a certain value, it would be best to check the inherited config.
```


Changed files:
lib/jnpr/junos/facts/domain.py

diff --git a/lib/jnpr/junos/facts/domain.py b/lib/jnpr/junos/facts/domain.py
index 92eb03ad..fc968d75 100644
--- a/lib/jnpr/junos/facts/domain.py
+++ b/lib/jnpr/junos/facts/domain.py
@@ -1,5 +1,6 @@
 from jnpr.junos.utils.fs import FS
 from jnpr.junos.exception import RpcError
+from jnpr.junos.jxml import INHERIT
 from lxml.builder import E
 
 
@@ -15,7 +16,7 @@ def facts_domain(junos, facts):
 
     try:
         domain_filter_xml = E('configuration', E('system', E('domain-name')))
-        domain = junos.rpc.get_config(domain_filter_xml)
+        domain = junos.rpc.get_config(filter_xml=domain_filter_xml, options=INHERIT)
         domain_name = domain.xpath('.//domain-name')
         if len(domain_name) > 0:
             facts['domain'] = domain_name[0].text
Repository: juniper/py-junos-eznc
Issue: Configuration Table Options cannot be set in YAML

The options keyword is not properly being supported.  Currently the only working way it so specify during the get  `table.get(options={})`

Should be able to set things in the following manner

``` yaml
ConfigTable:
    get: groups
    item:
    args_key: name
    options: {}
    view: ConfigView
```

or

``` yaml
from jnpr.junos.jxml import INHERIT
ConfigTable:
    get: groups
    item:
    args_key: name
    options: INHERIT
    view: ConfigView
```


Changed files:
tests/unit/factory/test_cfgtable.py, lib/jnpr/junos/factory/cfgtable.py

diff --git a/lib/jnpr/junos/factory/cfgtable.py b/lib/jnpr/junos/factory/cfgtable.py
index c66a7ccc..4981257d 100644
--- a/lib/jnpr/junos/factory/cfgtable.py
+++ b/lib/jnpr/junos/factory/cfgtable.py
@@ -20,6 +20,7 @@ class CfgTable(Table):
         self.ITEM_NAME_XPATH = self._data_dict.get('key', 'name')
         self.ITEM_XPATH = self._data_dict['get']
         self.view = self._data_dict.get('view')
+        self._options = self._data_dict.get('options')
 
     # -----------------------------------------------------------------------
     # PROPERTIES
@@ -210,7 +211,10 @@ class CfgTable(Table):
         if 'options' in kvargs:
             options = kvargs.get('options') or {}
         else:
-            options = jxml.INHERIT_GROUPS
+            if self._options is not None:
+                options = self._options
+            else:
+                options = jxml.INHERIT_GROUPS
 
         # for debug purposes
         self._get_cmd = get_cmd
diff --git a/tests/unit/factory/test_cfgtable.py b/tests/unit/factory/test_cfgtable.py
index e915bb8f..0f61b897 100644
--- a/tests/unit/factory/test_cfgtable.py
+++ b/tests/unit/factory/test_cfgtable.py
@@ -46,6 +46,12 @@ yaml_data = \\
         fullgroup: { full-name: group }
       fields_auth:
         pass: encrypted-password
+
+    GroupTable:
+        get: groups
+        item:
+        args_key: name
+        options: {}
       """
 globals().update(FactoryLoader().load(yaml.load(yaml_data)))
 
@@ -86,6 +92,13 @@ class TestFactoryCfgTable(unittest.TestCase):
         self.zit.get(security_zone='untrust', options={'inherit': 'defaults', 'groups': 'groups'})
         self.assertEqual(self.zit._get_opt, {'inherit': 'defaults', 'groups': 'groups'})
 
+    @patch('jnpr.junos.Device.execute')
+    def test_cfgtable_table_options(self, mock_execute):
+        mock_execute.side_effect = self._mock_manager
+        gt = GroupTable(self.dev)
+        gt.get()
+        self.assertEqual(gt._get_opt, {})
+
     def test_optable_get_key_required_error(self):
         self.assertRaises(ValueError, self.zit.get)
Repository: juniper/py-junos-eznc
Issue: jnpr.junos.utils.config.load does not support replace

Similar to #118 except for the "replace" load method where conf sections marked with "replace" are replaced rather than overriding the entire config.


Changed files:
lib/jnpr/junos/utils/config.py

diff --git a/lib/jnpr/junos/utils/config.py b/lib/jnpr/junos/utils/config.py
index f68e313c..7aaad4ee 100644
--- a/lib/jnpr/junos/utils/config.py
+++ b/lib/jnpr/junos/utils/config.py
@@ -162,6 +162,10 @@ class Config(Util):
           determines if the contents completely replace the existing
           configuration.  options are [True/False], default: False
 
+        kvargs['merge']
+          if set to :True: will set the load-config action to merge.
+          the default load-config action is 'replace'
+
         kvargs['template_path']
           path to a jinja2 template file.  used in conjection with the
           kvargs['template_vars'] option, this will perform a templating
@@ -178,7 +182,10 @@ class Config(Util):
           used in conjection with the other template options.  this option
           contains a dictionary of variables to render into the template
         """
-        rpc_xattrs = {'format': 'xml'}      # junos attributes, default to XML
+        rpc_xattrs = {}
+        rpc_xattrs['format'] = 'xml'        # default to XML format
+        rpc_xattrs['action'] = 'replace'    # replace is default action
+
         rpc_contents = None
 
         # support the ability to completely replace the Junos configuration
@@ -187,6 +194,8 @@ class Config(Util):
         overwrite = kvargs.get('overwrite', False)
         if True == overwrite:
             rpc_xattrs['action'] = 'override'
+        elif kvargs.get('merge') is True:
+            del rpc_xattrs['action']
 
         # ---------------------------------------------------------------------
         # private helpers ...
Repository: juniper/py-junos-eznc
Issue: OpTable loading from lxml object

Loading an OpTable via passed in lxml object is missing support.


Changed files:
tests/unit/factory/test_optable.py, lib/jnpr/junos/factory/optable.py

diff --git a/lib/jnpr/junos/factory/optable.py b/lib/jnpr/junos/factory/optable.py
index f7341d21..40867b94 100644
--- a/lib/jnpr/junos/factory/optable.py
+++ b/lib/jnpr/junos/factory/optable.py
@@ -47,6 +47,9 @@ class OpTable(Table):
             self.xml = etree.parse(self._path).getroot()
             return self
 
+        if self.xml is not None:
+            return self
+
         argkey = vargs[0] if len(vargs) else None
 
         rpc_args = {}                     # create empty <dict>
diff --git a/tests/unit/factory/test_optable.py b/tests/unit/factory/test_optable.py
index 9d7118de..a74c1387 100644
--- a/tests/unit/factory/test_optable.py
+++ b/tests/unit/factory/test_optable.py
@@ -38,12 +38,20 @@ class TestFactoryOpTable(unittest.TestCase):
         self.ppt.get('ge-0/0/0')
         self.assertEqual(self.ppt.GET_KEY, 'interface_name')
 
-    def test_optable_local(self):
+    def test_optable_path(self):
         fname = 'local-get-interface-information.xml'
-        self.ppt._path = os.path.join(os.path.dirname(__file__),
-                                      'rpc-reply', fname)
-        self.ppt.get()
-        self.assertEqual(len(self.ppt), 2)
+        path = os.path.join(os.path.dirname(__file__),
+                            'rpc-reply', fname)
+        lppt = PhyPortStatsTable(path=path)
+        lppt.get()
+        self.assertEqual(len(lppt), 2)
+
+    def test_optable_xml(self):
+        fname = 'get-interface-information.xml'
+        xml = self._read_file(fname)
+        lppt = PhyPortStatsTable(xml=xml)
+        lppt.get()
+        self.assertEqual(len(lppt), 2)
 
     @patch('jnpr.junos.Device.execute')
     def test_optable_view_get(self, mock_execute):
Repository: juniper/py-junos-eznc
Issue: JSONLoadError even when JSON config being loaded in proper

```python
    cnf = """{
        "configuration" : {
            "system" : {
                "services" : {
                    "telnet" : [null]
                 }
            }
        }
    }"""
    with Config(dev) as cu:
        cu.load(cnf, format='json')
```
throw JSONLoadError even when JSON config being loaded in proper
This issue got introduced after the changes done for enhancement under https://github.com/Juniper/py-junos-eznc/pull/706



Changed files:
lib/jnpr/junos/device.py

diff --git a/lib/jnpr/junos/device.py b/lib/jnpr/junos/device.py
index dd1758a8..9d392e44 100644
--- a/lib/jnpr/junos/device.py
+++ b/lib/jnpr/junos/device.py
@@ -736,8 +736,11 @@ class _Connection(object):
 
         # From 14.2 onward, junos supports JSON, so now code can be written as
         # dev.rpc.get_route_engine_information({'format': 'json'})
+        # should not convert rpc response to json when loading json config
+        # as response should be rpc-reply xml object.
 
-        if rpc_cmd_e.attrib.get('format') in ['json', 'JSON']:
+        if rpc_cmd_e.tag != 'load-configuration' and \\
+                        rpc_cmd_e.attrib.get('format') in ['json', 'JSON']:
             ver_info = self.facts.get('version_info')
             if ver_info and ver_info.major[0] >= 15 or \\
                     (ver_info.major[0] == 14 and ver_info.major[1] >= 2):
Repository: siliconcompiler/siliconcompiler
Issue: `chip.find_result()` doesn't return local directory for remote runs

I noticed that when calling `chip.find_result()` after a remote run, it seems to return a path to some sort of server temp directory rather than the local build directory. I'm not sure if this is actually intended, but I imagine we want it to return the local build directory instead in order to make the remote runs look transparent.

(sidenote: In #608 I started refactoring the daily tests to use `chip.find_result` instead of asserting the existence of a manually constructed output path in order to eliminate the need to refactor every test whenever the build dir structure changes. Once this issue is fixed, we'll be able to use the same pattern for server tests as well)

Changed files:
siliconcompiler/core.py

diff --git a/siliconcompiler/core.py b/siliconcompiler/core.py
index 77ce3e36..ba431ec1 100644
--- a/siliconcompiler/core.py
+++ b/siliconcompiler/core.py
@@ -3212,7 +3212,9 @@ class Chip:
         lastdir = self._getworkdir(step=laststep, index=lastindex)
         lastcfg = f"{lastdir}/outputs/{self.get('design')}.pkg.json"
         if os.path.isfile(lastcfg):
+            local_dir = self.get('dir')
             self.read_manifest(lastcfg, clobber=True, clear=True)
+            self.set('dir', local_dir)
 
         # Store run in history
         self.cfghistory[self.get('jobname')] = copy.deepcopy(self.cfg)