internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: googleapis/google-cloud-python

Issue:
BigQuery: SchemaField cannot load resource with missing `mode` property
The [mode property](https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#schema.fields.mode) is optional in the REST API, but this code fails:

```
SchemaField.from_api_repr({'name': 'colname', 'type': 'INT64'})
```

I believe this is due to the line

```
mode=api_repr['mode'].upper(),
```

which does not properly handle when the `mode` property is missing.

Related to https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3723 as it is often convenient to omit the mode parameter when defining a schema file by hand.



Discussion:

Resolving patch:
diff --git a/bigquery/google/cloud/bigquery/schema.py b/bigquery/google/cloud/bigquery/schema.py
--- a/bigquery/google/cloud/bigquery/schema.py
+++ b/bigquery/google/cloud/bigquery/schema.py
@@ -56,10 +56,13 @@ def from_api_repr(cls, api_repr):
             google.cloud.biquery.schema.SchemaField:
                 The ``SchemaField`` object.
         """
+        # Handle optional properties with default values
+        mode = api_repr.get('mode', 'NULLABLE')
+        fields = api_repr.get('fields', ())
         return cls(
             field_type=api_repr['type'].upper(),
-            fields=[cls.from_api_repr(f) for f in api_repr.get('fields', ())],
-            mode=api_repr['mode'].upper(),
+            fields=[cls.from_api_repr(f) for f in fields],
+            mode=mode.upper(),
             name=api_repr['name'],
         )
 


Test patch:
diff --git a/bigquery/tests/unit/test_schema.py b/bigquery/tests/unit/test_schema.py
--- a/bigquery/tests/unit/test_schema.py
+++ b/bigquery/tests/unit/test_schema.py
@@ -102,6 +102,16 @@ def test_from_api_repr(self):
         self.assertEqual(field.fields[0].field_type, 'INTEGER')
         self.assertEqual(field.fields[0].mode, 'NULLABLE')
 
+    def test_from_api_repr_defaults(self):
+        field = self._get_target_class().from_api_repr({
+            'name': 'foo',
+            'type': 'record',
+        })
+        self.assertEqual(field.name, 'foo')
+        self.assertEqual(field.field_type, 'RECORD')
+        self.assertEqual(field.mode, 'NULLABLE')
+        self.assertEqual(len(field.fields), 0)
+
     def test_name_property(self):
         name = 'lemon-ness'
         schema_field = self._make_one(name, 'INTEGER')
Repository: googleapis/google-cloud-python

Issue:
Monitoring TimeSeries.Query docs: broken links
Today (9 March), I received a notice from a link checker that the file at [http://gcloud-python.readthedocs.io/en/latest/monitoring/query.html](http://gcloud-python.readthedocs.io/en/latest/monitoring/query.html) had two bad links to the Stackdriver Monitoring API reference.

Here are two warnings I found:

W,https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list#Aligner,http://gcloud-python.readthedocs.io/en/latest/monitoring/query.html,Anchor: Aligner not found.
W,https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list#Reducer,http://gcloud-python.readthedocs.io/en/latest/monitoring/query.html,Anchor: Reducer not found.

The Aligner and Reducer tags are no longer in the monitoring/api/ref_v3/rest/v3/projects.timeSeries/list.html file. This is a generated file, and in the most recent regeneration of the API (published on 8 March), these two tags and the content associated with them was moved (by the generating tool) to monitoring/api/ref_v3/rest/v3/projects.alertPolicies.html. 
Here's the [alertPolicies](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies) page.

I apologize for this. I was able to pre-emptively fix the links in my own docs that this change would break, but I had no way to know from where else these anchors might be linked to. And I cannot "fix" this with the usual URL redirects mechanism we use when pages move. This is content in a page.

I have filed a bug against the generator for this behavior. 





Discussion:
@chemelnucfin can you take care of this?

Resolving patch:
diff --git a/monitoring/google/cloud/monitoring/query.py b/monitoring/google/cloud/monitoring/query.py
--- a/monitoring/google/cloud/monitoring/query.py
+++ b/monitoring/google/cloud/monitoring/query.py
@@ -383,7 +383,7 @@ def align(self, per_series_aligner, seconds=0, minutes=0, hours=0):
 
         .. _supported aligners:
             https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\
-            projects.timeSeries/list#Aligner
+            projects.alertPolicies#Aligner
         """
         new_query = self.copy()
         new_query._per_series_aligner = per_series_aligner
@@ -420,7 +420,7 @@ def reduce(self, cross_series_reducer, *group_by_fields):
 
         .. _supported reducers:
             https://cloud.google.com/monitoring/api/ref_v3/rest/v3/\
-            projects.timeSeries/list#Reducer
+            projects.alertPolicies#Reducer
         """
         new_query = self.copy()
         new_query._cross_series_reducer = cross_series_reducer


Test patch:
Repository: googleapis/google-cloud-python

Issue:
Release spanner 1.2.0
Batch query support is merged.

Note that `development_status` is still showing beta.


Discussion:
On it.
Need to release api_core first: https://github.com/GoogleCloudPlatform/google-cloud-python/pull/5029
Updated api-core version: https://github.com/GoogleCloudPlatform/google-cloud-python/pull/5030
Fixed release status in https://github.com/GoogleCloudPlatform/google-cloud-python/pull/5031

Resolving patch:
diff --git a/spanner/setup.py b/spanner/setup.py
--- a/spanner/setup.py
+++ b/spanner/setup.py
@@ -22,7 +22,7 @@
 
 name = 'google-cloud-spanner'
 description = 'Cloud Spanner API client library'
-version = '1.1.0'
+version = '1.2.0'
 # Should be one of:
 # 'Development Status :: 3 - Alpha'
 # 'Development Status :: 4 - Beta'


Test patch:
Repository: googleapis/google-cloud-python

Issue:
Release spanner-1.3.0
The only real item is the new `COMMIT_TIMESTAMP` constant (PR #5102).


Discussion:
I am going to do this first thing on Monday morning. (No friday releases)

Resolving patch:
diff --git a/spanner/google/cloud/spanner_v1/__init__.py b/spanner/google/cloud/spanner_v1/__init__.py
--- a/spanner/google/cloud/spanner_v1/__init__.py
+++ b/spanner/google/cloud/spanner_v1/__init__.py
@@ -31,7 +31,7 @@
 COMMIT_TIMESTAMP = 'spanner.commit_timestamp()'
 """Placeholder be used to store commit timestamp of a transaction in a column.
 
-This value can only be used for timestamp columns that have set the option 
+This value can only be used for timestamp columns that have set the option
 ``(allow_commit_timestamp=true)`` in the schema.
 """
 
diff --git a/spanner/setup.py b/spanner/setup.py
--- a/spanner/setup.py
+++ b/spanner/setup.py
@@ -22,7 +22,7 @@
 
 name = 'google-cloud-spanner'
 description = 'Cloud Spanner API client library'
-version = '1.2.0'
+version = '1.3.0'
 # Should be one of:
 # 'Development Status :: 3 - Alpha'
 # 'Development Status :: 4 - Beta'


Test patch:
Repository: googleapis/google-cloud-python

Issue:
'ExtractJob.destination_uri_file_counts' docstring copy pasta
In #5241, @yiga2 reported:

> BTW, there is also an issue with the documentation - see discrepancy @ 
> https://google-cloud-python.readthedocs.io/en/latest/bigquery/reference.html#google.cloud.bigquery.job.ExtractJob.destination_uri_file_counts

and elaborated later:

> For the doc, it seems `Returns: number of DML rows affected by the job, or None if job is not yet complete.` is from another property.


Discussion:

Resolving patch:
diff --git a/bigquery/google/cloud/bigquery/job.py b/bigquery/google/cloud/bigquery/job.py
--- a/bigquery/google/cloud/bigquery/job.py
+++ b/bigquery/google/cloud/bigquery/job.py
@@ -1541,14 +1541,17 @@ def destination_uri_file_counts(self):
         See:
         https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#statistics.extract.destinationUriFileCounts
 
-        :rtype: int or None
-        :returns: number of DML rows affectd by the job, or None if job is not
-                  yet complete.
-        """
-        result = self._job_statistics().get('destinationUriFileCounts')
-        if result is not None:
-            result = int(result)
-        return result
+        Returns:
+            a list of integer counts, each representing the number of files
+            per destination URI or URI pattern specified in the extract
+            configuration. These values will be in the same order as the URIs
+            specified in the 'destinationUris' field.  Returns None if job is
+            not yet complete.
+        """
+        counts = self._job_statistics().get('destinationUriFileCounts')
+        if counts is not None:
+            return [int(count) for count in counts]
+        return None
 
     def _build_resource(self):
         """Generate a resource for :meth:`begin`."""


Test patch:
diff --git a/bigquery/tests/system.py b/bigquery/tests/system.py
--- a/bigquery/tests/system.py
+++ b/bigquery/tests/system.py
@@ -843,6 +843,7 @@ def test_extract_table_w_job_config(self):
         self.to_delete.insert(0, destination)
         got = destination.download_as_string().decode('utf-8')
         self.assertIn('"Bharney Rhubble"', got)
+        self.assertEqual(job.destination_uri_file_counts, [1])
 
     def test_copy_table(self):
         # If we create a new table to copy from, the test won't work
diff --git a/bigquery/tests/unit/test_job.py b/bigquery/tests/unit/test_job.py
--- a/bigquery/tests/unit/test_job.py
+++ b/bigquery/tests/unit/test_job.py
@@ -1604,8 +1604,8 @@ def test_destination_uri_file_counts(self):
         extract_stats = statistics['extract'] = {}
         self.assertIsNone(job.destination_uri_file_counts)
 
-        extract_stats['destinationUriFileCounts'] = str(file_counts)
-        self.assertEqual(job.destination_uri_file_counts, file_counts)
+        extract_stats['destinationUriFileCounts'] = [str(file_counts)]
+        self.assertEqual(job.destination_uri_file_counts, [file_counts])
 
     def test_from_api_repr_missing_identity(self):
         self._setUpConstants()
Repository: googleapis/google-cloud-python

Issue:
usage documentation: please mention unicode
http://google-cloud-python.readthedocs.io/en/latest/datastore/usage.html please add (in the first example) a mention that storing strings should be done with u:
entity['name'] = u'Jane'

Not using unicode will make the datastore convert them to blobs.


Discussion:

Resolving patch:
diff --git a/datastore/google/cloud/datastore/__init__.py b/datastore/google/cloud/datastore/__init__.py
--- a/datastore/google/cloud/datastore/__init__.py
+++ b/datastore/google/cloud/datastore/__init__.py
@@ -25,6 +25,7 @@
    >>> key
    <Key('EntityKind', 1234), project=...>
    >>> entity = datastore.Entity(key)
+   >>> entity['question'] = u'Life, universe?'  # Explicit unicode for text
    >>> entity['answer'] = 42
    >>> entity
    <Entity('EntityKind', 1234) {'answer': 42}>


Test patch:
Repository: googleapis/google-cloud-python

Issue:
Release 'error_reporting-0.30.0'
PR #5345 fixes the incompatibility of `0.29.1` with the current `logging-1.6.0` release.


Discussion:

Resolving patch:
diff --git a/error_reporting/setup.py b/error_reporting/setup.py
--- a/error_reporting/setup.py
+++ b/error_reporting/setup.py
@@ -22,7 +22,7 @@
 
 name = 'google-cloud-error-reporting'
 description = 'Stackdriver Error Reporting API client library'
-version = '0.29.1'
+version = '0.30.0'
 # Should be one of:
 # 'Development Status :: 3 - Alpha'
 # 'Development Status :: 4 - Beta'


Test patch:
Repository: googleapis/google-cloud-python

Issue:
General: v0.33.0 pip install fails
In a fresh Python v2.7.12 virtualenv on linux:
```
pip install google-cloud
```

Results in:
```
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-3_n60m/google-cloud/setup.py", line 22, in <module>
        with open(os.path.join(PACKAGE_ROOT, 'setup-README.rst')) as file_obj:
    IOError: [Errno 2] No such file or directory: '/tmp/pip-install-3_n60m/google-cloud/setup-README.rst'
```

Note:
```
pip install google-cloud==0.32.0
```
works fine.

I believe it has to do with recent changes: https://github.com/GoogleCloudPlatform/google-cloud-python/commit/71e5d4bf94745580834b86c3e92ac4186c3115c0


Discussion:
We have the same on Python 3.6
I got this problem on Amazon EMR - it looks like the archive was changed yesterday at 10:30 am and something broke (maybe just the file "setup-README.rst" is missing?):
```
...
Collecting google-cloud>=0.32.0 (from mrjob)
  Downloading https://files.pythonhosted.org/packages/49/9a/943f0e217990c37e119101bbb739d86201ec1fdf59152ecc2dba93c5a8ad/google-cloud-0.33.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/mnt/tmp/pip-build-P0PK73/google-cloud/setup.py", line 22, in <module>
        with open(os.path.join(PACKAGE_ROOT, 'setup-README.rst')) as file_obj:
    IOError: [Errno 2] No such file or directory: '/mnt/tmp/pip-build-P0PK73/google-cloud/setup-README.rst'
    
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /mnt/tmp/pip-build-P0PK73/google-cloud

(from lines 14-43 of s3://tw-emr-synonyms/tmp/logs/j-G6AEP8ORKNR2/node/i-016376a9dc3b31913/bootstrap-actions/1/stderr.gz)
```

If this is already patched: can you tell how long it will take to be distributed to the repository in "files.pythonhosted.org" and picked up by Amazon EMR?

The `google-cloud` umbrella package is deprecated, and will (after 2018-06-18) no longer actually have any of the API libraries as dependencies.  Please just install the API library / libraries you actually need, e.g.:

```bash
$ /path/to/venv/bin/pip install google-cloud-datastore
```
@crwilcox We likely *do* need to get the `MANIFEST.in` fixed for the umbrella package, so that it picks up the `legacy/*` files needed.
Python 3.4, 3.5 also failing.
mrjsob also not working. Thanks Google!
@tseaver you are correct. I will patch this today. This shouldn't be failing. 


Resolving patch:
diff --git a/legacy/google-cloud/setup.py b/legacy/google-cloud/setup.py
--- a/legacy/google-cloud/setup.py
+++ b/legacy/google-cloud/setup.py
@@ -76,7 +76,7 @@
 
 setup(
     name='google-cloud',
-    version='0.33.0',
+    version='0.33.1',
     description='API Client library for Google Cloud',
     long_description=README,
     install_requires=REQUIREMENTS,


Test patch:
Repository: googleapis/google-cloud-python

Issue:
Updated SubscriberClient docs
`subscribe_experimental` was promoted to `subscribe` but the docs for the `SubscriberClient` still suggested using `subscribe_experimental`


Discussion:

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed (or fixed any issues), please reply here (e.g. `I signed it!`) and we'll verify it.

----

#### What to do if you already signed the CLA

##### Individual signers

*   It's possible we don't have your GitHub username or you're using a different email address on your commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).

##### Corporate signers

*   Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to [go/cla#troubleshoot](go/cla#troubleshoot) ([Public version](https://opensource.google.com/docs/cla/#troubleshoot)).
*   The email used to register you as an authorized contributor must be the email used for the Git commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
*   The email used to register you as an authorized contributor must also be [attached to your GitHub account](https://github.com/settings/emails).
		

<!-- need_sender_cla -->

Resolving patch:
diff --git a/pubsub/google/cloud/pubsub_v1/subscriber/client.py b/pubsub/google/cloud/pubsub_v1/subscriber/client.py
--- a/pubsub/google/cloud/pubsub_v1/subscriber/client.py
+++ b/pubsub/google/cloud/pubsub_v1/subscriber/client.py
@@ -135,7 +135,7 @@ def callback(message):
                 print(message)
                 message.ack()
 
-            future = subscriber.subscribe_experimental(
+            future = subscriber.subscribe(
                 subscription, callback)
 
             try:


Test patch:
Repository: googleapis/google-cloud-python

Issue:
Monitoring alias package is missing new service clients
https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/monitoring/google/cloud/monitoring.py is missing the new clients added to https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/monitoring/google/cloud/monitoring_v3/__init__.py

Should be a relatively easy fix.


Discussion:

Resolving patch:
diff --git a/monitoring/google/cloud/monitoring.py b/monitoring/google/cloud/monitoring.py
--- a/monitoring/google/cloud/monitoring.py
+++ b/monitoring/google/cloud/monitoring.py
@@ -15,14 +15,21 @@
 from __future__ import absolute_import
 
 from google.cloud.monitoring_v3.query import Query
+from google.cloud.monitoring_v3 import AlertPolicyServiceClient
 from google.cloud.monitoring_v3 import GroupServiceClient
 from google.cloud.monitoring_v3 import MetricServiceClient
+from google.cloud.monitoring_v3 import NotificationChannelServiceClient
+from google.cloud.monitoring_v3 import UptimeCheckServiceClient
 from google.cloud.monitoring_v3 import enums
 from google.cloud.monitoring_v3 import types
 
 __all__ = (
     'enums',
     'types',
+    'AlertPolicyServiceClient',
     'GroupServiceClient',
+    'MetricServiceClient',
+    'NotificationChannelServiceClient',
+    'UptimeCheckServiceClient',
     'Query',
-    'MetricServiceClient', )
+)


Test patch:
Repository: googleapis/google-cloud-python

Issue:
Release spanner 1.4.0
This pull request was generated using releasetool.

Fixes #5466 5465


Discussion:

Resolving patch:
diff --git a/spanner/setup.py b/spanner/setup.py
--- a/spanner/setup.py
+++ b/spanner/setup.py
@@ -22,7 +22,7 @@
 
 name = 'google-cloud-spanner'
 description = 'Cloud Spanner API client library'
-version = '1.3.0'
+version = '1.4.0'
 # Should be one of:
 # 'Development Status :: 3 - Alpha'
 # 'Development Status :: 4 - Beta'


Test patch:
Repository: googleapis/google-cloud-python

Issue:
Core: rename x-goog-header-params -> x-goog-request-params
Typo causing problems with Tasks API.


Discussion:

Resolving patch:
diff --git a/api_core/google/api_core/gapic_v1/routing_header.py b/api_core/google/api_core/gapic_v1/routing_header.py
--- a/api_core/google/api_core/gapic_v1/routing_header.py
+++ b/api_core/google/api_core/gapic_v1/routing_header.py
@@ -22,7 +22,7 @@
 
 from six.moves.urllib.parse import urlencode
 
-ROUTING_METADATA_KEY = 'x-goog-header-params'
+ROUTING_METADATA_KEY = 'x-goog-request-params'
 
 
 def to_routing_header(params):


Test patch:
Repository: googleapis/google-cloud-python

Issue:
google.cloud.logging.handlers: send messages to stderr
Would it be ok if we do the print at https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/logging/google/cloud/logging/handlers/transports/background_thread.py#L222
to stderr instead? So it doesn't disturb the output of the software?

Thanks


Discussion:
Definitely!

On Tue, Jul 3, 2018, 1:32 PM Helen Koike <notifications@github.com> wrote:

> Would it be ok if we do the print at
> https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/logging/google/cloud/logging/handlers/transports/background_thread.py#L222
> to stderr instead? So it doesn't disturb the output of the software?
>
> Thanks
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/GoogleCloudPlatform/google-cloud-python/issues/5565>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAPUc2gWvAYhJ0ZtlaKBAFQdbLC09nYTks5uC9TggaJpZM4VBldz>
> .
>


Resolving patch:
diff --git a/logging/google/cloud/logging/handlers/transports/background_thread.py b/logging/google/cloud/logging/handlers/transports/background_thread.py
--- a/logging/google/cloud/logging/handlers/transports/background_thread.py
+++ b/logging/google/cloud/logging/handlers/transports/background_thread.py
@@ -21,6 +21,7 @@
 
 import atexit
 import logging
+import sys
 import threading
 import time
 
@@ -195,7 +196,9 @@ def stop(self, grace_period=None):
             self._queue.put_nowait(_WORKER_TERMINATOR)
 
             if grace_period is not None:
-                print('Waiting up to %d seconds.' % (grace_period,))
+                print(
+                    'Waiting up to %d seconds.' % (grace_period,),
+                    file=sys.stderr)
 
             self._thread.join(timeout=grace_period)
 
@@ -216,12 +219,15 @@ def _main_thread_terminated(self):
         if not self._queue.empty():
             print(
                 'Program shutting down, attempting to send %d queued log '
-                'entries to Stackdriver Logging...' % (self._queue.qsize(),))
+                'entries to Stackdriver Logging...' % (self._queue.qsize(),),
+                file=sys.stderr)
 
         if self.stop(self._grace_period):
-            print('Sent all pending logs.')
+            print('Sent all pending logs.', file=sys.stderr)
         else:
-            print('Failed to send %d pending logs.' % (self._queue.qsize(),))
+            print(
+                'Failed to send %d pending logs.' % (self._queue.qsize(),),
+                file=sys.stderr)
 
     def enqueue(self, record, message, resource=None, labels=None):
         """Queues a log entry to be written by the background thread.


Test patch: