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

Issue:
Update Noxfiles to use new Nox
Nox recently made a [big change](https://github.com/theacodes/nox/blob/master/CHANGELOG.md#2018823) from declarative to imperative and broke the Noxfile API.

We need to update our Noxfiles to work with the new API and update our test scripts to install `nox` (instead of `nox-automation`) and invoke `python3 -m nox {args}`.

Most projects just need to do a few steps:

1. Remove usage of `session_{name}` sessions and use `@nox.session` instead.
2. Don't use `session.interpreter`, use `@nox.session(py='...')`
3. Don't use `nox.parametrize` for multiple Pythons, use `@nox.session(py=['..', '..'])`.


Discussion:
Reopening:  the [root noxfile](https://github.com/googleapis/google-cloud-python/blob/master/nox.py) needs updating as well.
@theacodes it looks like making the new `nox` work on CircleCI (e.g., to build docs) needs a new Docker image, as well.

Resolving patch:
diff --git a/nox.py b/noxfile.py
similarity index 78%
rename from nox.py
rename to noxfile.py
--- a/nox.py
+++ b/noxfile.py
@@ -17,16 +17,10 @@
 import nox
 
 
-@nox.session
+@nox.session(python='3.6')
 def docs(session):
     """Build the docs."""
 
-    # Build docs against the latest version of Python, because we can.
-    session.interpreter = 'python3.6'
-
-    # Set the virtualenv dirname.
-    session.virtualenv_dirname = 'docs'
-
     # Install Sphinx and also all of the google-cloud-* packages.
     session.chdir(os.path.realpath(os.path.dirname(__file__)))
     session.install('-r', os.path.join('docs', 'requirements.txt'))
@@ -36,13 +30,9 @@ def docs(session):
         'bash', os.path.join('.', 'test_utils', 'scripts', 'update_docs.sh'))
 
 
-@nox.session
+@nox.session(python='3.6')
 def lint_setup_py(session):
     """Verify that setup.py is valid (including RST check)."""
-    session.interpreter = 'python3.6'
-
-    # Set the virtualenv dirname.
-    session.virtualenv_dirname = 'setup'
 
     session.install('docutils', 'Pygments')
     session.run(


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

Issue:
Re-generate library using tasks/synth.py
This PR was created by autosynth.


Discussion:

Resolving patch:
diff --git a/tasks/synth.py b/tasks/synth.py
--- a/tasks/synth.py
+++ b/tasks/synth.py
@@ -25,6 +25,7 @@
 excludes = [
     'README.rst',
     'setup.py',
+    'nox*.py',
     'docs/conf.py',
     'docs/index.rst',
 ]


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

Issue:
Re-generate library using kms/synth.py
This PR was created by autosynth.


Discussion:
synth should not be touching the nox config:  even if it did, the file is now `noxfile.py`.

Resolving patch:
diff --git a/kms/synth.py b/kms/synth.py
--- a/kms/synth.py
+++ b/kms/synth.py
@@ -33,7 +33,8 @@
 s.move(
     library,
     excludes=[
+        'README.rst',
         'setup.py',
+        'nox*.py',
         'docs/**/*',
-        'README.rst',
     ])


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

Issue:
Monitoring: where is CallOptions on monitoring API example?
[OS] macOS Sierra 10.12.6
[Versions]

- Python 3.6.1

```
google-api-core==1.2.1
google-api-python-client==1.7.3
google-auth==1.5.0
google-auth-httplib2==0.0.3
google-cloud-monitoring==0.30.0
googleapis-common-protos==1.5.3
```

----

## CallOptions class was not found!

Hi. I'm new to GCP and Stackdriver. I wanted to use Google Kubernetes Engine and its auto scaling by custom metrics. Then, it is required to export the metrics to Stackdriver Monitoring, so I am trying to do it.

But, After installing above-mentioned libraries, the example code on monitoring API README document failed. The pit hole is that `CallOptions` was not found, thus I've searched it in this repository and some other repositories.

And finally, I couldn't find it...

`CallOptions` is defined in gax.python, but the package is currently deprecated and moved to google-api-core. So I guess that also the dependency is currently corrupted or the some examples are out-of-date.

Please tell me how handle this problem.

_Thank you for the great package and platform._


Discussion:
@miyatin0212 Thanks very much for the report!  The examples you are seeing are outdated.  You should be able to use the `pages` attribute of the response iterator without needing to pass a token, e.g.:

```python
for page in client.list_monitored_resource_descriptors(name).pages:
    for element in page:
        # process element
        pass
```
I have opened https://github.com/googleapis/gapic-generator/issues/2388 to track the issue for examples in generated code.

Resolving patch:
diff --git a/vision/google/cloud/vision_helpers/__init__.py b/vision/google/cloud/vision_helpers/__init__.py
--- a/vision/google/cloud/vision_helpers/__init__.py
+++ b/vision/google/cloud/vision_helpers/__init__.py
@@ -40,8 +40,12 @@ def annotate_image(self, request, retry=None, timeout=None):
 
         Args:
             request (:class:`~.vision_v1.types.AnnotateImageRequest`)
-            options (:class:`google.gax.CallOptions`): Overrides the default
-                settings for this call, e.g, timeout, retries, etc.
+            retry (Optional[google.api_core.retry.Retry]):  A retry object used
+                to retry requests. If ``None`` is specified, requests will not
+                be retried.
+            timeout (Optional[float]): The amount of time, in seconds, to wait
+                for the request to complete. Note that if ``retry`` is
+                specified, the timeout applies to each individual attempt.
 
         Returns:
             :class:`~.vision_v1.types.AnnotateImageResponse` The API response.


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

Issue:
Bigtable: ConditionalRow not passing parameters to CheckAndMutateRowRequest
Since `google-cloud-bigtable>=0.30.0`, the `commit()` function of `ConditionalRow` seems to be completely broken:
- values for `true_mutations`, `false_mutations` and `predicate_filter / self._filter.to_pb()` exist in `ConditionalRow`, but are not passed to `data_client.check_and_mutate_row()`
- the return value `resp` is a single `google.cloud.bigtable_v2.types.CheckAndMutateRowResponse`, which doesn't support indexing

https://github.com/googleapis/google-cloud-python/blob/b34a859cc8915cb7e6b6ca6ec7cca40e203c5832/bigtable/google/cloud/bigtable/row.py#L521-L525

Both changes were part of the huge #5178 commit: https://github.com/googleapis/google-cloud-python/commit/86102c959c6852d6b02c2fe3ddeea946a003bee6#diff-0320c7c7abd68618413e8879c6269554R536


Discussion:

Resolving patch:
diff --git a/bigtable/google/cloud/bigtable/row.py b/bigtable/google/cloud/bigtable/row.py
--- a/bigtable/google/cloud/bigtable/row.py
+++ b/bigtable/google/cloud/bigtable/row.py
@@ -520,9 +520,13 @@ def commit(self):
 
         data_client = self._table._instance._client.table_data_client
         resp = data_client.check_and_mutate_row(
-            table_name=self._table.name, row_key=self._row_key,)
+            table_name=self._table.name,
+            row_key=self._row_key,
+            predicate_filter=self._filter.to_pb(),
+            true_mutations=true_mutations,
+            false_mutations=false_mutations)
         self.clear()
-        return resp[0].predicate_matched
+        return resp.predicate_matched
 
     # pylint: disable=arguments-differ
     def set_cell(self, column_family_id, column, value, timestamp=None,


Test patch:
diff --git a/bigtable/tests/unit/test_row.py b/bigtable/tests/unit/test_row.py
--- a/bigtable/tests/unit/test_row.py
+++ b/bigtable/tests/unit/test_row.py
@@ -445,7 +445,7 @@ def test_commit(self):
             predicate_matched=predicate_matched)
 
         # Patch the stub used by the API method.
-        api.transport.check_and_mutate_row.side_effect = [[response_pb]]
+        api.transport.check_and_mutate_row.side_effect = [response_pb]
         client._table_data_client = api
 
         # Create expected_result.
Repository: googleapis/google-cloud-python

Issue:
Release 'api_core-1.6.0a2'? or 'api_core-1.5.1'?
I'd like to use the changes from https://github.com/googleapis/google-cloud-python/pull/6310 in the library I'm working on.

Not sure about the version number for that one, since:

- I don't know what else has been released since 1.6.0a1
- I don't know what is intended by 1.6.0a1 in https://github.com/googleapis/google-cloud-python/pull/6267 (is it a pre-release?)


Discussion:
@tswast I believe @lukesneeringer is the one who can answer your question about PR #6267 and the `api_core-1.6.0a1` release.

My take:  given that we follow the "keep `master` releasable at all times" development practice, I believe that we should move the changes from #6267 off onto a branch (or even just revert it and re-merge later) to allow for making an `api_core-1.5.1` release from master, including your bugfix from #6310.

As an alternative, we could make an `api_core-1.5-maint` branch from 7527a4ed546f7f202529a8d323302302fd728ee4 (the last commit on `master` touching `api_core/` before #6267), and cherry pick e368317c9ff99db572a0463e9dbd5e77294cfcd4 into it from #6310 in order to make the `api_core-1.5.1` release you need.

Resolving patch:
diff --git a/api_core/setup.py b/api_core/setup.py
--- a/api_core/setup.py
+++ b/api_core/setup.py
@@ -22,7 +22,7 @@
 
 name = 'google-api-core'
 description = 'Google API client core library'
-version = '1.6.0a1'
+version = '1.5.1'
 # Should be one of:
 # 'Development Status :: 3 - Alpha'
 # 'Development Status :: 4 - Beta'


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

Issue:
Cloud Assets: Autosynth fails to find the generated output
```bash
cd asset
python3 synth.py
```

Output:
```
synthtool > Ensuring dependencies.
synthtool > Pulling artman image.
synthtool > Cloning googleapis.
synthtool > Running generator for google/cloud/asset/artman_cloudasset_v1beta1.yaml.
Traceback (most recent call last):
  File "synth.py", line 36, in <module>
    artman_output_name=f"cloudasset-{version}",
  File "[removed]/.local/lib/python3.6/site-packages/synthtool/gcp/gapic_generator.py", line 100, in py_library
    return self._generate_code(service, version, "python", **kwargs)
  File "[removed]/.local/lib/python3.6/site-packages/synthtool/gcp/gapic_generator.py", line 183, in _generate_code
    f"Unable to find generated output of artman: {genfiles}."
FileNotFoundError: Unable to find generated output of artman: [removed]/.cache/synthtool/googleapis/artman-genfiles/python/cloudasset-v1beta1.
```


Discussion:

Resolving patch:
diff --git a/asset/synth.py b/asset/synth.py
--- a/asset/synth.py
+++ b/asset/synth.py
@@ -33,7 +33,7 @@
         "asset",
         version,
         config_path=f"/google/cloud/asset/artman_cloudasset_{version}.yaml",
-        artman_output_name=f"cloudasset-{version}",
+        artman_output_name=f"asset-{version}",
     )
 
     s.move(library, excludes=excludes)


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

Issue:
Pub/Sub: mistake in publisher client example
It should have been `from google.cloud.pubsub_v1 import PublisherClient` in this line: https://github.com/googleapis/google-cloud-python/blob/23a3204770f68a56dba12d1a37058398773f3daf/pubsub/google/cloud/pubsub_v1/publisher/client.py#L156


Discussion:
@anguillanneuf Is the example a mistake, or is it just a question of style?  The next line uses the module-qualified name: https://github.com/googleapis/google-cloud-python/blob/23a3204770f68a56dba12d1a37058398773f3daf/pubsub/google/cloud/pubsub_v1/publisher/client.py#L156-L157

Some folks prefer "import only modules" as a practice (I'm not one of them, but the usage doesn't bother me, either).
There is no `publisher_client` in google.cloud.pubsub_v1 in `google-cloud-pubsub==0.38.0`. 

```
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud.pubsub_v1 import publisher_client
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'publisher_client'
>>> from google.cloud.pubsub_v1 import PublisherClient
>>> 
```
OK, the docstrings in the generated code all use this pattern:

```python
>>> from google.cloud import pubsub_v1
>>> publisher_client = pubsub_v1.PublisherClient()
```

I will fix in the hand-written docstrings for `pubsub_v1.publisher.client.Client.publish`, as well as in `pubsub_v1.subcriber.client.Client.subscribe`, which has a similar problem.

Resolving patch:
diff --git a/pubsub/google/cloud/pubsub_v1/publisher/client.py b/pubsub/google/cloud/pubsub_v1/publisher/client.py
--- a/pubsub/google/cloud/pubsub_v1/publisher/client.py
+++ b/pubsub/google/cloud/pubsub_v1/publisher/client.py
@@ -153,8 +153,8 @@ def publish(self, topic, data, **attrs):
         period of time has elapsed.
 
         Example:
-            >>> from google.cloud.pubsub_v1 import publisher_client
-            >>> client = publisher_client.PublisherClient()
+            >>> from google.cloud import pubsub_v1
+            >>> client = pubsub_v1.PublisherClient()
             >>> topic = client.topic_path('[PROJECT]', '[TOPIC]')
             >>> data = b'The rain in Wales falls mainly on the snails.'
             >>> response = client.publish(topic, data, username='guido')
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
@@ -129,9 +129,9 @@ def subscribe(
 
         .. code-block:: python
 
-            from google.cloud.pubsub_v1 import subscriber
+            from google.cloud import pubsub_v1
 
-            subscriber_client = pubsub.SubscriberClient()
+            subscriber_client = pubsub_v1.SubscriberClient()
 
             # existing subscription
             subscription = subscriber_client.subscription_path(


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

Issue:
Please support array_contains in queries
`array_contains` is supported in most other languages (Python and Ruby are holdouts) :
https://firebase.google.com/docs/firestore/query-data/queries#array_membership

Is there a timeframe for when this might become available for Python?


Discussion:

Resolving patch:
diff --git a/firestore/google/cloud/firestore_v1beta1/query.py b/firestore/google/cloud/firestore_v1beta1/query.py
--- a/firestore/google/cloud/firestore_v1beta1/query.py
+++ b/firestore/google/cloud/firestore_v1beta1/query.py
@@ -39,6 +39,7 @@
     _EQ_OP: enums.StructuredQuery.FieldFilter.Operator.EQUAL,
     '>=': enums.StructuredQuery.FieldFilter.Operator.GREATER_THAN_OR_EQUAL,
     '>': enums.StructuredQuery.FieldFilter.Operator.GREATER_THAN,
+    'array_contains': enums.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS,
 }
 _BAD_OP_STRING = 'Operator string {!r} is invalid. Valid choices are: {}.'
 _BAD_OP_NAN_NULL = (


Test patch:
diff --git a/firestore/tests/unit/test_query.py b/firestore/tests/unit/test_query.py
--- a/firestore/tests/unit/test_query.py
+++ b/firestore/tests/unit/test_query.py
@@ -965,6 +965,7 @@ def test_success(self):
         self.assertEqual(self._call_fut('=='), op_class.EQUAL)
         self.assertEqual(self._call_fut('>='), op_class.GREATER_THAN_OR_EQUAL)
         self.assertEqual(self._call_fut('>'), op_class.GREATER_THAN)
+        self.assertEqual(self._call_fut('array_contains'), op_class.ARRAY_CONTAINS)
 
     def test_failure(self):
         with self.assertRaises(ValueError):
Repository: googleapis/google-cloud-python

Issue:
Firestore: 'Query.where' needs to raise for sentinels / transforms
The following conformance tests assert that attempting to use `DELETE_FIELD`, `SERVER_TIMESTAMP`, `ArrayRemove`, or `ArrayUnion` as the value of a `Query.where` must raise an exception, which the current implementation does not do:

- `query-arrayremove-where.textproto`
- `query-arrayunion-where.textproto`
- `query-del-where.textproto`
- `query-st-where.textproto`


Discussion:

Resolving patch:
diff --git a/firestore/google/cloud/firestore_v1beta1/query.py b/firestore/google/cloud/firestore_v1beta1/query.py
--- a/firestore/google/cloud/firestore_v1beta1/query.py
+++ b/firestore/google/cloud/firestore_v1beta1/query.py
@@ -46,6 +46,7 @@
 _BAD_OP_STRING = 'Operator string {!r} is invalid. Valid choices are: {}.'
 _BAD_OP_NAN_NULL = (
     'Only an equality filter ("==") can be used with None or NaN values')
+_INVALID_WHERE_TRANSFORM = 'Transforms cannot be used as where values.'
 _BAD_DIR_STRING = 'Invalid direction {!r}. Must be one of {!r} or {!r}.'
 _INVALID_CURSOR_TRANSFORM = 'Transforms cannot be used as cursor values.'
 _MISSING_ORDER_BY = (
@@ -234,6 +235,8 @@ def where(self, field_path, op_string, value):
                 ),
                 op=enums.StructuredQuery.UnaryFilter.Operator.IS_NAN,
             )
+        elif isinstance(value, (transforms.Sentinel, transforms._ValueList)):
+            raise ValueError(_INVALID_WHERE_TRANSFORM)
         else:
             filter_pb = query_pb2.StructuredQuery.FieldFilter(
                 field=query_pb2.StructuredQuery.FieldReference(


Test patch:
diff --git a/firestore/tests/unit/test_query.py b/firestore/tests/unit/test_query.py
--- a/firestore/tests/unit/test_query.py
+++ b/firestore/tests/unit/test_query.py
@@ -199,12 +199,38 @@ def test_where_le_nan(self):
         with self.assertRaises(ValueError):
             self._where_unary_helper(float('nan'), 0, op_string='<=')
 
+
+    def test_where_w_delete(self):
+        from google.cloud.firestore_v1beta1 import DELETE_FIELD
+
+        with self.assertRaises(ValueError):
+            self._where_unary_helper(DELETE_FIELD, 0)
+
+    def test_where_w_server_timestamp(self):
+        from google.cloud.firestore_v1beta1 import SERVER_TIMESTAMP
+
+        with self.assertRaises(ValueError):
+            self._where_unary_helper(SERVER_TIMESTAMP, 0)
+
+    def test_where_w_array_remove(self):
+        from google.cloud.firestore_v1beta1 import ArrayRemove
+
+        with self.assertRaises(ValueError):
+            self._where_unary_helper(ArrayRemove([1, 3, 5]), 0)
+
+    def test_where_w_array_union(self):
+        from google.cloud.firestore_v1beta1 import ArrayUnion
+
+        with self.assertRaises(ValueError):
+            self._where_unary_helper(ArrayUnion([2, 4, 8]), 0)
+
     def test_order_by_invalid_path(self):
         query = self._make_one(mock.sentinel.parent)
 
         with self.assertRaises(ValueError):
             query.order_by('*')
 
+
     def test_order_by(self):
         from google.cloud.firestore_v1beta1.gapic import enums
Repository: googleapis/google-cloud-python

Issue:
Firestore: passing empty list to 'Query.select' implies '__name__'
The `query-select-empty.textproto` conformance test mandates this behavior.


Discussion:
We can apply this constraint during `_to_protobuf`.

Resolving patch:
diff --git a/firestore/google/cloud/firestore_v1beta1/query.py b/firestore/google/cloud/firestore_v1beta1/query.py
--- a/firestore/google/cloud/firestore_v1beta1/query.py
+++ b/firestore/google/cloud/firestore_v1beta1/query.py
@@ -535,6 +535,23 @@ def _filters_pb(self):
             return query_pb2.StructuredQuery.Filter(
                 composite_filter=composite_filter)
 
+    @staticmethod
+    def _normalize_projection(projection):
+        """Helper:  convert field paths to message."""
+        if projection is not None:
+
+            fields = list(projection.fields)
+
+            if not fields:
+                field_ref = query_pb2.StructuredQuery.FieldReference(
+                    field_path='__name__',
+                )
+                return query_pb2.StructuredQuery.Projection(
+                    fields=[field_ref],
+                )
+
+        return projection
+
     @staticmethod
     def _normalize_cursor(cursor, orders):
         """Helper: convert cursor to a list of values based on orders."""
@@ -580,11 +597,12 @@ def _to_protobuf(self):
             google.cloud.firestore_v1beta1.types.StructuredQuery: The
             query protobuf.
         """
+        projection = self._normalize_projection(self._projection)
         start_at = self._normalize_cursor(self._start_at, self._orders)
         end_at = self._normalize_cursor(self._end_at, self._orders)
 
         query_kwargs = {
-            'select': self._projection,
+            'select': projection,
             'from': [
                 query_pb2.StructuredQuery.CollectionSelector(
                     collection_id=self._parent.id,


Test patch:
diff --git a/firestore/tests/unit/test_query.py b/firestore/tests/unit/test_query.py
--- a/firestore/tests/unit/test_query.py
+++ b/firestore/tests/unit/test_query.py
@@ -476,6 +476,23 @@ def test__filters_pb_multi(self):
         )
         self.assertEqual(filter_pb, expected_pb)
 
+    def test__normalize_projection_none(self):
+        query = self._make_one(mock.sentinel.parent)
+        self.assertIsNone(query._normalize_projection(None))
+
+    def test__normalize_projection_empty(self):
+        projection = self._make_projection_for_select([])
+        query = self._make_one(mock.sentinel.parent)
+        normalized = query._normalize_projection(projection)
+        field_paths = [
+            field_ref.field_path for field_ref in normalized.fields]
+        self.assertEqual(field_paths, ['__name__'])
+
+    def test__normalize_projection_non_empty(self):
+        projection = self._make_projection_for_select(['a', 'b'])
+        query = self._make_one(mock.sentinel.parent)
+        self.assertIs(query._normalize_projection(projection), projection)
+
     def test__normalize_cursor_none(self):
         query = self._make_one(mock.sentinel.parent)
         self.assertIsNone(query._normalize_cursor(None, query._orders))