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

Issue:
Hardcoded namespace default in lib_openshift/oc_adm_router
#### Description

Provide a brief description of your issue here. For example:

> On a multi master install, if the first master goes down we can no
> longer scaleup the cluster with new nodes or masters.


##### Version

```
$ ansible --version
ansible 2.4.2.0

$ git describe
openshift-ansible-3.7.27-1-22-g99841ad50
```

##### Steps To Reproduce
1. Configure `openshift_hosted_routers` with namespace != default
2. Run config.yml playbook


##### Expected Results
Router successfully deployed in custom namespace 

##### Observed Results
Router successfully deployed in default namespace 

Maybe, because the Namespace default is hardcoded here:

https://github.com/openshift/openshift-ansible/blob/26caf813c55a090279260436ec315d8331bcc2e4/roles/lib_openshift/library/oc_adm_router.py#L2653


Discussion:

Resolving patch:
diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py
--- a/roles/lib_openshift/library/oc_adm_router.py
+++ b/roles/lib_openshift/library/oc_adm_router.py
@@ -2692,7 +2692,7 @@ def __init__(self,
            - secret/router-certs
            - clusterrolebinding/router-router-role
         '''
-        super(Router, self).__init__('default', router_config.kubeconfig, verbose)
+        super(Router, self).__init__(router_config.namespace, router_config.kubeconfig, verbose)
         self.config = router_config
         self.verbose = verbose
         self.router_parts = [{'kind': 'dc', 'name': self.config.name},
diff --git a/roles/lib_openshift/src/class/oc_adm_router.py b/roles/lib_openshift/src/class/oc_adm_router.py
--- a/roles/lib_openshift/src/class/oc_adm_router.py
+++ b/roles/lib_openshift/src/class/oc_adm_router.py
@@ -27,7 +27,7 @@ def __init__(self,
            - secret/router-certs
            - clusterrolebinding/router-router-role
         '''
-        super(Router, self).__init__('default', router_config.kubeconfig, verbose)
+        super(Router, self).__init__(router_config.namespace, router_config.kubeconfig, verbose)
         self.config = router_config
         self.verbose = verbose
         self.router_parts = [{'kind': 'dc', 'name': self.config.name},


Test patch:
Repository: openshift/openshift-ansible

Issue:
Hardcoded namespace default in lib_openshift/oc_adm_router
#### Description

Provide a brief description of your issue here. For example:

> On a multi master install, if the first master goes down we can no
> longer scaleup the cluster with new nodes or masters.


##### Version

```
$ ansible --version
ansible 2.4.2.0

$ git describe
openshift-ansible-3.7.27-1-22-g99841ad50
```

##### Steps To Reproduce
1. Configure `openshift_hosted_routers` with namespace != default
2. Run config.yml playbook


##### Expected Results
Router successfully deployed in custom namespace 

##### Observed Results
Router successfully deployed in default namespace 

Maybe, because the Namespace default is hardcoded here:

https://github.com/openshift/openshift-ansible/blob/26caf813c55a090279260436ec315d8331bcc2e4/roles/lib_openshift/library/oc_adm_router.py#L2653


Discussion:

Resolving patch:
diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py
--- a/roles/lib_openshift/library/oc_adm_router.py
+++ b/roles/lib_openshift/library/oc_adm_router.py
@@ -2705,7 +2705,7 @@ def __init__(self,
            - secret/router-certs
            - clusterrolebinding/router-router-role
         '''
-        super(Router, self).__init__('default', router_config.kubeconfig, verbose)
+        super(Router, self).__init__(router_config.namespace, router_config.kubeconfig, verbose)
         self.config = router_config
         self.verbose = verbose
         self.router_parts = [{'kind': 'dc', 'name': self.config.name},
diff --git a/roles/lib_openshift/src/class/oc_adm_router.py b/roles/lib_openshift/src/class/oc_adm_router.py
--- a/roles/lib_openshift/src/class/oc_adm_router.py
+++ b/roles/lib_openshift/src/class/oc_adm_router.py
@@ -27,7 +27,7 @@ def __init__(self,
            - secret/router-certs
            - clusterrolebinding/router-router-role
         '''
-        super(Router, self).__init__('default', router_config.kubeconfig, verbose)
+        super(Router, self).__init__(router_config.namespace, router_config.kubeconfig, verbose)
         self.config = router_config
         self.verbose = verbose
         self.router_parts = [{'kind': 'dc', 'name': self.config.name},


Test patch:
Repository: openshift/openshift-ansible

Issue:
Fix multimaster OpenStack deployment failure
When trying to deploy multimaster OpenStack with nsupdate and either no
load balancer or OpenStack LBaaS, the creation of the DNS records would
fail.

This is because it was still relying on the old `lb` inventory group for
all multimaster scenarios, rather than just in the
`openshift_openstack_use_lbaas_load_balancer` case.

So we define a new inventory variable
`openshift_openstack_private_api_ip` (which is already defined in the
Heat templates) and use that instead.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1588428


Discussion:
/lgtm
[APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/openshift/openshift-ansible/pull/8668#" title="Author self-approved">tomassedovic</a>*, *<a href="https://github.com/openshift/openshift-ansible/pull/8668#issuecomment-395464489" title="LGTM">tzumainn</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[playbooks/openstack/OWNERS](https://github.com/openshift/openshift-ansible/blob/master/playbooks/openstack/OWNERS)~~ [tomassedovic,tzumainn]
- ~~[roles/openshift_openstack/OWNERS](https://github.com/openshift/openshift-ansible/blob/master/roles/openshift_openstack/OWNERS)~~ [tomassedovic,tzumainn]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
/test gcp
/test gcp
/test gcp

Resolving patch:
diff --git a/playbooks/openstack/inventory.py b/playbooks/openstack/inventory.py
--- a/playbooks/openstack/inventory.py
+++ b/playbooks/openstack/inventory.py
@@ -9,7 +9,6 @@
 
 from __future__ import print_function
 
-from collections import Mapping
 import json
 import os
 
@@ -105,13 +104,8 @@ def _get_hostvars(server, docker_storage_mountpoints):
     if server.metadata['host-type'] == 'cns':
         hostvars['glusterfs_devices'] = ['/dev/nvme0n1']
 
-    node_labels = server.metadata.get('node_labels')
-    # NOTE(shadower): the node_labels value must be a dict not string
-    if not isinstance(node_labels, Mapping):
-        node_labels = json.loads(node_labels)
-
-    if node_labels:
-        hostvars['openshift_node_labels'] = node_labels
+    group_name = server.metadata.get('openshift_node_group_name')
+    hostvars['openshift_node_group_name'] = group_name
 
     # check for attached docker storage volumes
     if 'os-extended-volumes:volumes_attached' in server:


Test patch:
Repository: openshift/openshift-ansible

Issue:
Update the naming of openshift on rhv to ovirt
Updated all references of rhv to use ovirt insread,
since this is an upstream repo.

Signed-off-by: Shirly Radco <sradco@redhat.com>

Please review: @yanivlavi @cwilkers


Discussion:
Can one of the admins verify this patch?
I understand the following commands:
- `bot, add author to whitelist`
- `bot, test pull request`
- `bot, test pull request once`
/ok-to-test
I'm a RHV PM and the best practice is using oVirt in all the code and CLI.
RHV branding is kept for UI and docs.
/assign @vrutkovs
/cc @cwilkers
/assign @vrutkovs
Looks fine, lets squash the commits
New changes are detected. LGTM label has been removed.
[APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/openshift/openshift-ansible/pull/9724#pullrequestreview-149015485" title="LGTM">cwilkers</a>*, *<a href="https://github.com/openshift/openshift-ansible/pull/9724#" title="Author self-approved">sradco</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:


Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -74,7 +74,7 @@ def find_playbooks():
     all_playbooks = set()
     included_playbooks = set()
 
-    exclude_dirs = ('adhoc', 'tasks', 'rhv')
+    exclude_dirs = ('adhoc', 'tasks', 'ovirt')
     for yaml_file in find_files(
             os.path.join(os.getcwd(), 'playbooks'),
             exclude_dirs, None, r'^[^\.].*\.ya?ml$'):


Test patch:
Repository: openshift/openshift-ansible

Issue:
During upgrade openvswitch is being stopped even when we have openshift_use_openshift_sdn=false
#### Description

when we specify openshift_use_openshift_sdn=false in the hosts file it is supposed that other solution will manage the networking. During upgrade stop_services.yml stops openvswitch even when we have openshift_use_openshift_sdn=false. In some cases the management of the nodes is via openvswitch and this playbook makes the nodes inaccessible. I will send a PR not to stop openvswitch if openshift_use_openshift_sdn=false is specified.


##### Version

Please put the following version information in the code block
indicated below.

* Your ansible version per `ansible --version`

If you're operating from a **git clone**:

* The output of `git describe`

If you're running from playbooks installed via RPM

* The output of `rpm -q openshift-ansible`

Place the output between the code block below:

```
[root@ocp-master demos]# rpm -q openshift-ansible
openshift-ansible-3.9.14-1.git.3.c62bc34.el7.noarch
[root@ocp-master demos]#

```

##### Steps To Reproduce
run upgrade.yml with openshift_use_openshift_sdn=false

##### Expected Results
not to stop openvswitch


##### Observed Results
It stops openvswitch.

##### Additional Information

Provide any additional information which may help us diagnose the
issue.

* Your operating system and version, ie: RHEL 7.2, Fedora 23 (`$ cat /etc/redhat-release`)
* Your inventory file (especially any non-standard configuration parameters)
* Sample code, etc

```
[root@ocp-master demos]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.5 (Maipo)
```



Discussion:

Resolving patch:
diff --git a/roles/lib_utils/action_plugins/sanity_checks.py b/roles/lib_utils/action_plugins/sanity_checks.py
--- a/roles/lib_utils/action_plugins/sanity_checks.py
+++ b/roles/lib_utils/action_plugins/sanity_checks.py
@@ -20,7 +20,8 @@
                    ('openshift_use_nuage', False),
                    ('openshift_use_contiv', False),
                    ('openshift_use_calico', False),
-                   ('openshift_use_kuryr', False))
+                   ('openshift_use_kuryr', False),
+                   ('openshift_use_nsx', False))
 
 ENTERPRISE_TAG_REGEX_ERROR = """openshift_image_tag must be in the format
 v#.#[.#[.#]]. Examples: v1.2, v3.4.1, v3.5.1.3,


Test patch:
Repository: py-pdf/pypdf

Issue:
Multiple definitions in dictionary error
Getting a Multiple definitions in dictionary at byte 0x3ee546 for key /CPUCstFn1 for file
http://docs.cpuc.ca.gov/PublishedDocs/Efile/G000/M075/K768/75768464.PDF
when doing reader.getPage()
The file opens without an issue in Foxit.



Discussion:

Resolving patch:
diff --git a/PyPDF2/generic.py b/PyPDF2/generic.py
--- a/PyPDF2/generic.py
+++ b/PyPDF2/generic.py
@@ -587,11 +587,8 @@ def readFromStream(stream, pdf):
             tok = readNonWhitespace(stream)
             stream.seek(-1, 1)
             value = readObject(stream, pdf)
-            if key in data:
-                # multiple definitions of key not permitted
-                raise utils.PdfReadError("Multiple definitions in dictionary at byte %s for key %s" \
-                                           % (utils.hexStr(stream.tell()), key))
-            data[key] = value
+            if not data.get(key):
+                data[key] = value
         pos = stream.tell()
         s = readNonWhitespace(stream)
         if s == b_('s') and stream.read(5) == b_('tream'):


Test patch:
Repository: py-pdf/pypdf

Issue:
PdfFileReader barfs on unicode _namedDest ... needs to check isinstance(dest, basestring)
I noticed the way you are keeping 2to3 compatability with isinstance(x, basestring) in pagerange.py using this Str indirection.  I propose we move this Str to utils, and import it into pagerange.py and pdf.py.  Will submit a pull request later tonight. 



Discussion:

Resolving patch:
diff --git a/PyPDF2/pagerange.py b/PyPDF2/pagerange.py
--- a/PyPDF2/pagerange.py
+++ b/PyPDF2/pagerange.py
@@ -8,10 +8,7 @@
 """
 
 import re
-
-# "Str" maintains compatibility with Python 2.x.
-# The next line is obfuscated like this so 2to3 won't change it.
-Str = getattr(__builtins__, "basestring", str)
+from .utils import Str
 
 _INT_RE = r"(0|-?[1-9]\d*)"  # A decimal int, don't allow "-0".
 PAGE_RANGE_RE = "^({int}|({int}?(:{int}?(:{int}?)?)))$".format(int=_INT_RE)
diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py
--- a/PyPDF2/pdf.py
+++ b/PyPDF2/pdf.py
@@ -61,7 +61,7 @@
 import codecs
 from .generic import *
 from .utils import readNonWhitespace, readUntilWhitespace, ConvertFunctionsToVirtualList
-from .utils import b_, u_, ord_, chr_, str_, string_type, formatWarning
+from .utils import Str, b_, u_, ord_, chr_, str_, string_type, formatWarning
 
 if version_info < ( 2, 4 ):
    from sets import ImmutableSet as frozenset
@@ -1004,7 +1004,7 @@ def _buildOutline(self, node):
         if dest:
             if isinstance(dest, ArrayObject):
                 outline = self._buildDestination(title, dest)
-            elif isinstance(dest, str) and dest in self._namedDests:
+            elif isinstance(dest, Str) and dest in self._namedDests:
                 outline = self._namedDests[dest]
                 outline[NameObject("/Title")] = title
             else:
diff --git a/PyPDF2/utils.py b/PyPDF2/utils.py
--- a/PyPDF2/utils.py
+++ b/PyPDF2/utils.py
@@ -1,5 +1,3 @@
-# vim: sw=4:expandtab:foldmethod=marker
-#
 # Copyright (c) 2006, Mathieu Fenniak
 # All rights reserved.
 #
@@ -33,6 +31,16 @@
 __author__ = "Mathieu Fenniak"
 __author_email__ = "biziqe@mathieu.fenniak.net"
 
+
+# "Str" maintains compatibility with Python 2.x.
+# The next line is obfuscated like this so 2to3 won't change it.
+try: 
+    import __builtin__ as builtins
+except ImportError:  # Py3
+    import builtins
+Str = getattr(builtins, "basestring", str)
+
+
 #custom implementation of warnings.formatwarning
 def formatWarning(message, category, filename, lineno, line=None):
     file = filename.replace("/", "\\").rsplit("\\", 1)[1] # find the file name


Test patch:
Repository: py-pdf/pypdf

Issue:
Question: How to merge cropped PDF page with full pdf page in PyPDF?
I am trying to merge two pdf pages using PyPDF2:

```
background_page = background_pdf.getPage(0)
overlay = some_pdf.getPage(0)

# crop overlaying page vertically
overlay.mediaBox.lowerRight = (
    overlay.mediaBox.getUpperRight_x(),
    overlay.mediaBox.getUpperRight_y() / 2
)
# merge
background_page.mergePage(overlay)
```

Unfortunately cropping doesn't happen. `mediaBox` of the overlaying page appears to be ignored and I see entire page in the output.

Does anyone have any idea of how I can achieve this?

I posted this on SO as well http://stackoverflow.com/questions/27512246/how-to-merge-cropped-pdf-page-with-full-pdf-page-in-pypdf



Discussion:
Try

```
background_page = background_pdf.getPage(0)
overlay = some_pdf.getPage(0)

# crop overlaying page vertically
overlay.mediaBox.lowerRight = (
    overlay.mediaBox.getUpperRight_x(),
    overlay.mediaBox.getUpperRight_y() / 2
)
# merge
overlay.mergePage(background_page) # Switched

output = PdfFileWriter()
output.addPage(overlay) # Add the Overlay Page
```

If I merge pages this way then my overlay ends up being underneath the background. Is there a way to crop a page and save it in a new pdf without any data for the entire page? Right now if I crop a page using `mediaBox`  and write it to the output file I can easily get entire page again if I change the `mediaBox` back to its original values. I hope this makes sense. Thanks!

Hi @lananelson, I'm having a similar problem but can't figure out how to solve it. Did you find a way around it?

I'm cropping a page `mediaBox` and saving the PDF. If I open the file using any standard PDF reader I see the content cropped the way I wanted, but if I print it I get the original page as if no cropping had occurred.

@tincho89 I moved on from this a while ago and unfortunately don't exactly remember what the solution was (I don't have access to the repo anymore either). I think in your case you could try creating a blank page with the desired cropped dimensions and then merge your cropped page on top of it. 

@lananelson thanks for the response.

I was doing a proof of concept so I'm going to work on it again on some weeks, that approach looks good though. Will try it!

Thanks!


Resolving patch:
diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py
--- a/PyPDF2/pdf.py
+++ b/PyPDF2/pdf.py
@@ -2264,6 +2264,10 @@ def _mergePage(self, page2, page2transformation=None, ctm=None, expand=False):
 
         page2Content = page2.getContents()
         if page2Content is not None:
+            page2Content = ContentStream(page2Content, self.pdf)
+            page2Content.operations.insert(0, [map(FloatObject, [page2.trimBox.getLowerLeft_x(), page2.trimBox.getLowerLeft_y(), page2.trimBox.getWidth(), page2.trimBox.getHeight()]), "re"])
+            page2Content.operations.insert(1, [[], "W"])
+            page2Content.operations.insert(2, [[], "n"])
             if page2transformation is not None:
                 page2Content = page2transformation(page2Content)
             page2Content = PageObject._contentStreamRename(


Test patch:
Repository: py-pdf/pypdf

Issue:
PdfReadError: EOF marker not found error when opening pdf files generated from selenium snapshot
I am using selenium and Ghost to capture screenshots as `pdf`. The code for saving screenshot is

```
driver.get('http://localhost/report/10?page=1')
driver.save_screenshot('page1.pdf')
```

Now i can open these files in a pdf viewer(I am using Okular) and they look fine. But when i try to open them using this code

```
from PyPDF2 import PdfFileReader
input1 = PdfFileReader(open("page1.pdf", "rb"))
```

It gives error `PdfReadError: EOF marker not found`. The reason i am trying to open this file using `PdfFileReader` is that i need to merge several pdfs into one and for that i need to open these pdfs. I found a github issue https://github.com/mstamy2/PyPDF2/issues/34 and it says it was resolved but i still face this issue. My pypdf version is 1.24



Discussion:

Resolving patch:
diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py
--- a/PyPDF2/pdf.py
+++ b/PyPDF2/pdf.py
@@ -1820,12 +1820,12 @@ def read(self, stream):
         stream.seek(-1, 2)
         if not stream.tell():
             raise PdfReadError('Cannot read an empty file')
-        last1K = stream.tell() - 1024 + 1 # offset of last 1024 bytes of stream
+        last1M = stream.tell() - 1024 * 1024 + 1 # offset of last MB of stream
         line = b_('')
         while line[:5] != b_("%%EOF"):
-            if stream.tell() < last1K:
+            if stream.tell() < last1M:
                 raise PdfReadError("EOF marker not found")
-            line = self.readNextEndLine(stream, last1K)
+            line = self.readNextEndLine(stream)
             if debug: print("  line:",line)
 
         # find startxref entry - the location of the xref table


Test patch:
Repository: openvinotoolkit/training_extensions

Issue:
POT -> PTQ transition in docs
Steps to be done:
- Rename POT -> PTQ
- Replace POT docs links with NNCF.PTQ docs
- Mention that the output model would be quantized to INT8

Related pages: 
https://openvinotoolkit.github.io/training_extensions/stable/guide/explanation/additional_features/models_optimization.html
https://openvinotoolkit.github.io/training_extensions/stable/guide/tutorials/base/how_to_train/classification.html#optimization and other tasks


Discussion:

Resolving patch:
diff --git a/src/otx/cli/tools/eval.py b/src/otx/cli/tools/eval.py
--- a/src/otx/cli/tools/eval.py
+++ b/src/otx/cli/tools/eval.py
@@ -49,8 +49,8 @@ def get_args():
     )
     parser.add_argument(
         "--load-weights",
-        help="Load model weights from previously saved checkpoint."
-        "It could be a trained/optimized model (POT only) or exported model.",
+        help="Load model weights from previously saved checkpoint. "
+        "It could be a trained/optimized model (with PTQ only) or exported model.",
     )
     parser.add_argument(
         "-o",


Test patch:
Repository: python/peps

Issue:
pep2rss disregards PEPs written in reStructuredText format
This can be seen at https://www.python.org/dev/peps/peps.rss/ where the last (most recent) RSS entry is the last PEP written in plaintext.


Discussion:

Resolving patch:
diff --git a/pep2rss.py b/pep2rss.py
--- a/pep2rss.py
+++ b/pep2rss.py
@@ -15,8 +15,10 @@ def firstline_startingwith(full_path, text):
             return line[len(text):].strip()
     return None
 
-# get list of peps with creation time (from "Created:" string in pep .txt)
+# get list of peps with creation time
+# (from "Created:" string in pep .rst or .txt)
 peps = glob.glob('pep-*.txt')
+peps.extend(glob.glob('pep-*.rst'))
 def pep_creation_dt(full_path):
     created_str = firstline_startingwith(full_path, 'Created:')
     # bleh, I was hoping to avoid re but some PEPs editorialize


Test patch:
Repository: python/peps

Issue:
pep2rss can raise UnicodeEncodeError on certain platforms
This is due to the default encoding of [`open()`](https://docs.python.org/3/library/functions.html#open) being platform dependent.

For example, on Windows (CP-1252), it can raise
`UnicodeEncodeError: 'charmap' codec can't encode character '\u0141' in position 1545: character maps to <undefined>`
when handling the character, 'Ł', in the name of the author of [PEP 569](https://www.python.org/dev/peps/pep-0569/).
https://github.com/python/peps/blob/433faca4cf1bb8a0550d01b86b2b4581b3eda460/pep-0569.rst#L5


Discussion:

Resolving patch:
diff --git a/pep2rss.py b/pep2rss.py
--- a/pep2rss.py
+++ b/pep2rss.py
@@ -1,16 +1,15 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # usage: pep-hook.py $REPOS $REV
 # (standard post-commit args)
 
 import os, glob, time, datetime, stat, re, sys
-import codecs
 import PyRSS2Gen as rssgen
 
 RSS_PATH = os.path.join(sys.argv[1], 'peps.rss')
 
 def firstline_startingwith(full_path, text):
-    for line in codecs.open(full_path, encoding="utf-8"):
+    for line in open(full_path, encoding="utf-8"):
         if line.startswith(text):
             return line[len(text):].strip()
     return None
@@ -69,5 +68,5 @@ def pep_creation_dt(full_path):
     lastBuildDate = datetime.datetime.now(),
     items = items)
 
-with open(RSS_PATH, 'w') as fp:
-    fp.write(rss.to_xml())
+with open(RSS_PATH, 'w', encoding="utf-8") as fp:
+    fp.write(rss.to_xml(encoding="utf-8"))


Test patch: