Skip to content

Commit 0b947fc

Browse files
chore(firestore): prep for firestore pipelines GA (#16549)
Misc changes in prep for GA release of pipelines: - re-enable releases for firestore - remove notes about pipelines being in preview - added individual beta labels for search/dml classes and methods - expose options in raw_stage - renamed Type to PipelineDataType - moved helper classes (options, enums) into pipeline_types - expose pipeline classes in top-level \_\_init__.py
1 parent 479e44d commit 0b947fc

File tree

14 files changed

+504
-363
lines changed

14 files changed

+504
-363
lines changed

.librarian/config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ libraries:
1414
- id: bigframes
1515
release_blocked: true
1616
- generate_blocked: true
17-
id: google-cloud-firestore
18-
release_blocked: true
1917
- generate_blocked: true
2018
id: google-cloud-dialogflow
2119
- id: google-crc32c

packages/google-cloud-firestore/google/cloud/firestore/__init__.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
AsyncClient,
3131
AsyncCollectionReference,
3232
AsyncDocumentReference,
33+
AsyncPipeline,
34+
AsyncPipelineStream,
3335
AsyncQuery,
3436
AsyncTransaction,
3537
AsyncWriteBatch,
@@ -43,15 +45,31 @@
4345
ExistsOption,
4446
ExplainOptions,
4547
FieldFilter,
48+
FindNearestOptions,
4649
GeoPoint,
4750
Increment,
4851
LastUpdateOption,
4952
Maximum,
5053
Minimum,
5154
Or,
55+
Ordering,
56+
Pipeline,
57+
PipelineDataType,
58+
PipelineExplainOptions,
59+
PipelineResult,
60+
PipelineSnapshot,
61+
PipelineSource,
62+
PipelineStream,
5263
Query,
5364
ReadAfterWriteError,
65+
SampleOptions,
66+
SearchOptions,
67+
SubPipeline,
68+
TimeGranularity,
69+
TimePart,
70+
TimeUnit,
5471
Transaction,
72+
UnnestOptions,
5573
Watch,
5674
WriteBatch,
5775
WriteOption,
@@ -68,6 +86,8 @@
6886
"AsyncClient",
6987
"AsyncCollectionReference",
7088
"AsyncDocumentReference",
89+
"AsyncPipeline",
90+
"AsyncPipelineStream",
7191
"AsyncQuery",
7292
"async_transactional",
7393
"AsyncTransaction",
@@ -83,18 +103,34 @@
83103
"ExistsOption",
84104
"ExplainOptions",
85105
"FieldFilter",
106+
"FindNearestOptions",
86107
"GeoPoint",
87108
"Increment",
88109
"LastUpdateOption",
89110
"Maximum",
90111
"Minimum",
91112
"Or",
113+
"Ordering",
114+
"Pipeline",
115+
"PipelineDataType",
116+
"PipelineExplainOptions",
117+
"PipelineResult",
118+
"PipelineSnapshot",
119+
"PipelineSource",
120+
"PipelineStream",
92121
"Query",
93122
"ReadAfterWriteError",
94123
"SERVER_TIMESTAMP",
124+
"SampleOptions",
125+
"SearchOptions",
126+
"SubPipeline",
127+
"TimeGranularity",
128+
"TimePart",
129+
"TimeUnit",
95130
"Transaction",
96131
"transactional",
97132
"types",
133+
"UnnestOptions",
98134
"Watch",
99135
"WriteBatch",
100136
"WriteOption",

packages/google-cloud-firestore/google/cloud/firestore_v1/__init__.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,44 @@
3333
from google.cloud.firestore_v1.async_client import AsyncClient
3434
from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
3535
from google.cloud.firestore_v1.async_document import AsyncDocumentReference
36+
from google.cloud.firestore_v1.async_pipeline import AsyncPipeline
3637
from google.cloud.firestore_v1.async_query import AsyncQuery
3738
from google.cloud.firestore_v1.async_transaction import (
3839
AsyncTransaction,
3940
async_transactional,
4041
)
4142
from google.cloud.firestore_v1.base_aggregation import CountAggregation
4243
from google.cloud.firestore_v1.base_document import DocumentSnapshot
44+
from google.cloud.firestore_v1.base_pipeline import SubPipeline
4345
from google.cloud.firestore_v1.base_query import And, FieldFilter, Or
4446
from google.cloud.firestore_v1.batch import WriteBatch
4547
from google.cloud.firestore_v1.client import Client
4648
from google.cloud.firestore_v1.collection import CollectionReference
4749
from google.cloud.firestore_v1.document import DocumentReference
50+
from google.cloud.firestore_v1.pipeline import Pipeline
51+
from google.cloud.firestore_v1.pipeline_result import (
52+
AsyncPipelineStream,
53+
PipelineResult,
54+
PipelineSnapshot,
55+
PipelineStream,
56+
)
57+
from google.cloud.firestore_v1.pipeline_source import PipelineSource
58+
from google.cloud.firestore_v1.pipeline_types import (
59+
FindNearestOptions,
60+
Ordering,
61+
PipelineDataType,
62+
SampleOptions,
63+
SearchOptions,
64+
TimeGranularity,
65+
TimePart,
66+
TimeUnit,
67+
UnnestOptions,
68+
)
4869
from google.cloud.firestore_v1.query import CollectionGroup, Query
49-
from google.cloud.firestore_v1.query_profile import ExplainOptions
70+
from google.cloud.firestore_v1.query_profile import (
71+
ExplainOptions,
72+
PipelineExplainOptions,
73+
)
5074
from google.cloud.firestore_v1.transaction import Transaction, transactional
5175
from google.cloud.firestore_v1.transforms import (
5276
DELETE_FIELD,
@@ -115,6 +139,8 @@
115139
"AsyncClient",
116140
"AsyncCollectionReference",
117141
"AsyncDocumentReference",
142+
"AsyncPipeline",
143+
"AsyncPipelineStream",
118144
"AsyncQuery",
119145
"async_transactional",
120146
"AsyncTransaction",
@@ -130,18 +156,34 @@
130156
"ExistsOption",
131157
"ExplainOptions",
132158
"FieldFilter",
159+
"FindNearestOptions",
133160
"GeoPoint",
134161
"Increment",
135162
"LastUpdateOption",
136163
"Maximum",
137164
"Minimum",
138165
"Or",
166+
"Ordering",
167+
"Pipeline",
168+
"PipelineDataType",
169+
"PipelineExplainOptions",
170+
"PipelineResult",
171+
"PipelineSnapshot",
172+
"PipelineSource",
173+
"PipelineStream",
139174
"Query",
140175
"ReadAfterWriteError",
141176
"SERVER_TIMESTAMP",
177+
"SampleOptions",
178+
"SearchOptions",
179+
"SubPipeline",
180+
"TimeGranularity",
181+
"TimePart",
182+
"TimeUnit",
142183
"Transaction",
143184
"transactional",
144185
"types",
186+
"UnnestOptions",
145187
"Watch",
146188
"WriteBatch",
147189
"WriteOption",

packages/google-cloud-firestore/google/cloud/firestore_v1/async_pipeline.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
"""
15-
.. warning::
16-
**Preview API**: Firestore Pipelines is currently in preview and is
17-
subject to potential breaking changes in future releases
18-
"""
1914

2015
from __future__ import annotations
2116

@@ -61,9 +56,7 @@ class AsyncPipeline(_BasePipeline):
6156
6257
Use `client.pipeline()` to create instances of this class.
6358
64-
.. warning::
65-
**Preview API**: Firestore Pipelines is currently in preview and is
66-
subject to potential breaking changes in future releases
59+
6760
"""
6861

6962
_client: AsyncClient

packages/google-cloud-firestore/google/cloud/firestore_v1/base_pipeline.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
from google.cloud.firestore_v1 import pipeline_stages as stages
21+
from google.cloud.firestore_v1 import pipeline_types as types
2122
from google.cloud.firestore_v1.base_vector_query import DistanceMeasure
2223
from google.cloud.firestore_v1.pipeline_expressions import (
2324
AggregateFunction,
@@ -37,6 +38,7 @@
3738
if TYPE_CHECKING: # pragma: NO COVER
3839
from google.cloud.firestore_v1.async_client import AsyncClient
3940
from google.cloud.firestore_v1.client import Client
41+
from google.cloud.firestore_v1.types.document import Value
4042

4143
_T = TypeVar("_T", bound="_BasePipeline")
4244

@@ -274,7 +276,7 @@ def find_nearest(
274276
field: str | Expression,
275277
vector: Sequence[float] | "Vector",
276278
distance_measure: "DistanceMeasure",
277-
options: stages.FindNearestOptions | None = None,
279+
options: types.FindNearestOptions | None = None,
278280
) -> "_BasePipeline":
279281
"""
280282
Performs vector distance (similarity) search with given parameters on the
@@ -395,11 +397,14 @@ def sort(self, *orders: stages.Ordering) -> "_BasePipeline":
395397
return self._append(stages.Sort(*orders))
396398

397399
def search(
398-
self, query_or_options: str | BooleanExpression | stages.SearchOptions
400+
self, query_or_options: str | BooleanExpression | types.SearchOptions
399401
) -> "_BasePipeline":
400402
"""
401403
Adds a search stage to the pipeline.
402404
405+
.. note::
406+
This feature is currently in beta and is subject to change.
407+
403408
This stage filters documents based on the provided query expression.
404409
405410
Example:
@@ -425,7 +430,7 @@ def search(
425430
"""
426431
return self._append(stages.Search(query_or_options))
427432

428-
def sample(self, limit_or_options: int | stages.SampleOptions) -> "_BasePipeline":
433+
def sample(self, limit_or_options: int | types.SampleOptions) -> "_BasePipeline":
429434
"""
430435
Performs a pseudo-random sampling of the documents from the previous stage.
431436
@@ -489,7 +494,7 @@ def unnest(
489494
self,
490495
field: str | Selectable,
491496
alias: str | Field | None = None,
492-
options: stages.UnnestOptions | None = None,
497+
options: types.UnnestOptions | None = None,
493498
) -> "_BasePipeline":
494499
"""
495500
Produces a document for each element in an array field from the previous stage document.
@@ -548,7 +553,12 @@ def unnest(
548553
"""
549554
return self._append(stages.Unnest(field, alias, options))
550555

551-
def raw_stage(self, name: str, *params: Expression) -> "_BasePipeline":
556+
def raw_stage(
557+
self,
558+
name: str,
559+
*params: Expression,
560+
options: dict[str, Expression | Value] | None = None,
561+
) -> "_BasePipeline":
552562
"""
553563
Adds a stage to the pipeline by specifying the stage name as an argument. This does not offer any
554564
type safety on the stage params and requires the caller to know the order (and optionally names)
@@ -566,11 +576,12 @@ def raw_stage(self, name: str, *params: Expression) -> "_BasePipeline":
566576
Args:
567577
name: The name of the stage.
568578
*params: A sequence of `Expression` objects representing the parameters for the stage.
579+
options: An optional dictionary of stage options.
569580
570581
Returns:
571582
A new Pipeline object with this stage appended to the stage list
572583
"""
573-
return self._append(stages.RawStage(name, *params))
584+
return self._append(stages.RawStage(name, *params, options=options or {}))
574585

575586
def offset(self, offset: int) -> "_BasePipeline":
576587
"""
@@ -704,6 +715,9 @@ def delete(self) -> "_BasePipeline":
704715
"""
705716
Deletes the documents from the current pipeline stage.
706717
718+
.. note::
719+
This feature is currently in beta and is subject to change.
720+
707721
Example:
708722
>>> from google.cloud.firestore_v1.pipeline_expressions import Field
709723
>>> pipeline = client.pipeline().collection("logs")
@@ -720,6 +734,9 @@ def update(self, *transformed_fields: "Selectable") -> "_BasePipeline":
720734
"""
721735
Performs an update operation using documents from previous stages.
722736
737+
.. note::
738+
This feature is currently in beta and is subject to change.
739+
723740
If called without `transformed_fields`, this method updates the documents in
724741
place based on the data flowing through the pipeline.
725742

packages/google-cloud-firestore/google/cloud/firestore_v1/pipeline.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
"""
15-
.. warning::
16-
**Preview API**: Firestore Pipelines is currently in preview and is
17-
subject to potential breaking changes in future releases.
18-
"""
1914

2015
from __future__ import annotations
2116

@@ -58,9 +53,7 @@ class Pipeline(_BasePipeline):
5853
5954
Use `client.pipeline()` to create instances of this class.
6055
61-
.. warning::
62-
**Preview API**: Firestore Pipelines is currently in preview and is
63-
subject to potential breaking changes in future releases.
56+
6457
"""
6558

6659
_client: Client

0 commit comments

Comments
 (0)