Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cosmos] mark populate_query_metrics flag to be deleted when used and remove docs #22264

Merged
merged 73 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
61ba8d1
initial commit
simorenoh Aug 13, 2021
15dcceb
Client Constructor (#20310)
annatisch Aug 20, 2021
bda95c3
read database
simorenoh Aug 27, 2021
c9648ab
Update simon_testfile.py
simorenoh Aug 27, 2021
80540dc
with coroutine
simorenoh Aug 30, 2021
1285438
Update simon_testfile.py
simorenoh Aug 30, 2021
992b0cd
small changes
simorenoh Aug 31, 2021
47cb688
async with returns no exceptions
simorenoh Aug 31, 2021
f3fa79f
Merge pull request #1 from Azure/simonmoreno/async
simorenoh Aug 31, 2021
0c49739
async read container
simorenoh Sep 1, 2021
47f4af5
async item read
simorenoh Sep 2, 2021
c97c946
cleaning up
simorenoh Sep 3, 2021
fcd95db
create item/ database methods
simorenoh Sep 13, 2021
36c5b90
item delete working
simorenoh Sep 13, 2021
44db2a2
docs replace functionality
simorenoh Sep 16, 2021
ec5b6ed
upsert functionality
simorenoh Sep 17, 2021
d63d052
Merge pull request #2 from simorenoh/item-read
simorenoh Oct 8, 2021
5d74c8f
missing query methods
simorenoh Oct 11, 2021
89fc2f7
CRUD for udf, sproc, triggers
simorenoh Oct 12, 2021
fdaa880
Merge branch 'Azure:main' into async-client
simorenoh Oct 12, 2021
3f9baf2
Merge branch 'Azure:main' into async-client
simorenoh Oct 12, 2021
d6650bc
Merge branch 'Azure:main' into query-functionality
simorenoh Oct 12, 2021
043dfe0
initial query logic + container methods
simorenoh Oct 13, 2021
befdb41
Merge branch 'async-client' into query-functionality
simorenoh Oct 13, 2021
8cffbe2
Merge pull request #3 from simorenoh/query-functionality
simorenoh Oct 13, 2021
72de7c8
missing some execution logic and tests
simorenoh Oct 21, 2021
5b805b8
oops
simorenoh Oct 21, 2021
8d8d0c4
fully working queries
simorenoh Oct 22, 2021
b597ca8
small fix to query_items()
simorenoh Oct 22, 2021
18319df
Update _cosmos_client_connection_async.py
simorenoh Oct 22, 2021
162c44d
Update _cosmos_client_connection.py
simorenoh Oct 22, 2021
ebbac51
documentation update
simorenoh Oct 22, 2021
43f78e6
Merge branch 'Azure:main' into main
simorenoh Oct 22, 2021
470aa5b
updated MIT dates and get_user_client() description
simorenoh Oct 22, 2021
74da690
Update CHANGELOG.md
simorenoh Oct 22, 2021
7104d63
Merge branch 'Azure:main' into main
simorenoh Oct 25, 2021
20718c7
Delete simon_testfile.py
simorenoh Oct 25, 2021
d825eaa
Merge pull request #4 from simorenoh/async-client
simorenoh Oct 25, 2021
e3c27a5
leftover retry utility
simorenoh Oct 25, 2021
3b778ad
Update README.md
simorenoh Oct 25, 2021
c6e352e
docs and removed six package
simorenoh Oct 28, 2021
8971a25
Merge remote-tracking branch 'upstream/main'
simorenoh Oct 28, 2021
52736ac
changes based on comments
simorenoh Nov 4, 2021
ad98039
small change in type hints
simorenoh Nov 4, 2021
f76c595
updated readme
simorenoh Nov 9, 2021
3f02a65
fixes based on conversations
simorenoh Nov 10, 2021
e719869
added missing type comments
simorenoh Nov 11, 2021
d03ee05
Merge branch 'Azure:main' into main
simorenoh Nov 11, 2021
02c52ee
update changelog for ci pipeline
simorenoh Nov 23, 2021
2cb4551
added typehints, moved params into keywords, added decorators, made _…
simorenoh Nov 29, 2021
cf20d35
changes based on sync with central sdk
simorenoh Dec 2, 2021
f456817
remove is_system_key from scripts (only used in execute_sproc)
simorenoh Dec 3, 2021
ea9bd16
Revert "remove is_system_key from scripts (only used in execute_sproc)"
simorenoh Dec 3, 2021
709d2eb
async script proxy using composition
simorenoh Dec 3, 2021
3277dd8
pylint
simorenoh Dec 3, 2021
a57cb4d
capitalized constants
simorenoh Dec 6, 2021
014578b
Apply suggestions from code review
simorenoh Dec 6, 2021
0d79695
closing python code snippet
simorenoh Dec 6, 2021
fdabea1
last doc updates
simorenoh Dec 7, 2021
016d0dd
Update sdk/cosmos/azure-cosmos/CHANGELOG.md
tjprescott Dec 7, 2021
8228aa9
version update
simorenoh Dec 7, 2021
7ae1cd0
Merge branch 'Azure:main' into main
simorenoh Dec 13, 2021
7e8e953
cosmos updates for release
simorenoh Dec 13, 2021
77c139a
send user warning for use of populate_query_metrics flag
simorenoh Dec 27, 2021
99997e9
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-python …
simorenoh Jan 12, 2022
215340a
Merge branch 'main' into populate-query-metrics-warning
simorenoh Apr 5, 2022
00b9d49
Update CHANGELOG.md
simorenoh Apr 5, 2022
691fb65
Update container.py
simorenoh May 2, 2022
eea2c59
Merge branch 'main' into populate-query-metrics-warning
simorenoh May 3, 2022
22c40fc
added tests
simorenoh May 4, 2022
e7e5c79
Merge branch 'Azure-main' into populate-query-metrics-warning
simorenoh May 12, 2022
a6c0c66
avoid index errors
simorenoh May 12, 2022
1813f9b
Update CHANGELOG.md
simorenoh May 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Method call will now require an 'id' field to be present in the document body.
- Marked the GetAuthorizationMethod for deprecation since it will no longer be public in a future release.
- Added samples showing how to configure retry options for both the sync and async clients.
- Deprecated the `connection_retry_policy` and `retry_options` options in the sync client.
- Added user warning to non-query methods trying to use `populate_query_metrics` options.

### 4.3.0b4 (2022-04-07)

Expand Down
63 changes: 49 additions & 14 deletions sdk/cosmos/azure-cosmos/azure/cosmos/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
"""Create, read, update and delete items in the Azure Cosmos DB SQL API service.
"""

from typing import Any, Dict, List, Optional, Union, Iterable, cast # pylint: disable=unused-import
from typing import Any, Dict, List, Optional, Union, Iterable, cast, overload # pylint: disable=unused-import


import warnings
from azure.core.tracing.decorator import distributed_trace # type: ignore

from ._cosmos_client_connection import CosmosClientConnection
Expand Down Expand Up @@ -108,21 +110,29 @@ def _set_partition_key(self, partition_key):
return CosmosClientConnection._return_undefined_or_empty_partition_key(self.is_system_key)
return partition_key

@overload
def read(
self,
*,
populate_partition_key_range_statistics: Optional[bool] = None,
populate_quota_info: Optional[bool] = None,
**kwargs
):
...


@distributed_trace
def read(
self,
populate_query_metrics=None, # type: Optional[bool]
populate_partition_key_range_statistics=None, # type: Optional[bool]
populate_quota_info=None, # type: Optional[bool]
*args,
**kwargs # type: Any
):
# type: (...) -> Dict[str, Any]
"""Read the container properties.

:param populate_query_metrics: Enable returning query metrics in response headers.
simorenoh marked this conversation as resolved.
Show resolved Hide resolved
:param populate_partition_key_range_statistics: Enable returning partition key
:keyword bool populate_partition_key_range_statistics: Enable returning partition key
range statistics in response headers.
:param populate_quota_info: Enable returning collection storage quota information in response headers.
:keyword bool populate_quota_info: Enable returning collection storage quota information in response headers.
:keyword str session_token: Token for use with Session consistency.
:keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request.
:keyword Callable response_hook: A callable invoked with the response metadata.
Expand All @@ -133,8 +143,15 @@ def read(
"""
request_options = build_options(kwargs)
response_hook = kwargs.pop('response_hook', None)
if populate_query_metrics is not None:
populate_query_metrics = args[0] if args else None or kwargs.pop('populate_query_metrics', None)
simorenoh marked this conversation as resolved.
Show resolved Hide resolved
if populate_query_metrics:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics
simorenoh marked this conversation as resolved.
Show resolved Hide resolved
populate_partition_key_range_statistics = kwargs.pop("populate_partition_key_range_statistics", None)
populate_quota_info = kwargs.pop("populate_quota_info", None)
simorenoh marked this conversation as resolved.
Show resolved Hide resolved
if populate_partition_key_range_statistics is not None:
request_options["populatePartitionKeyRangeStatistics"] = populate_partition_key_range_statistics
if populate_quota_info is not None:
Expand Down Expand Up @@ -164,7 +181,6 @@ def read_item(

:param item: The ID (name) or dict representing item to retrieve.
:param partition_key: Partition key for the item to retrieve.
:param populate_query_metrics: Enable returning query metrics in response headers.
simorenoh marked this conversation as resolved.
Show resolved Hide resolved
:param post_trigger_include: trigger id to be used as post operation trigger.
:keyword str session_token: Token for use with Session consistency.
:keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request.
Expand Down Expand Up @@ -195,6 +211,10 @@ def read_item(
if partition_key is not None:
request_options["partitionKey"] = self._set_partition_key(partition_key)
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics
if post_trigger_include is not None:
request_options["postTriggerInclude"] = post_trigger_include
Expand All @@ -219,7 +239,6 @@ def read_all_items(
"""List all the items in the container.

:param max_item_count: Max number of items to be returned in the enumeration operation.
:param populate_query_metrics: Enable returning query metrics in response headers.
:keyword str session_token: Token for use with Session consistency.
:keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request.
:keyword Callable response_hook: A callable invoked with the response metadata.
Expand All @@ -236,6 +255,10 @@ def read_all_items(
if max_item_count is not None:
feed_options["maxItemCount"] = max_item_count
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
feed_options["populateQueryMetrics"] = populate_query_metrics
max_integrated_cache_staleness_in_ms = kwargs.pop('max_integrated_cache_staleness_in_ms', None)
if max_integrated_cache_staleness_in_ms:
Expand Down Expand Up @@ -409,7 +432,6 @@ def replace_item(

:param item: The ID (name) or dict representing item to be replaced.
:param body: A dict-like object representing the item to replace.
:param populate_query_metrics: Enable returning query metrics in response headers.
:param pre_trigger_include: trigger id to be used as pre operation trigger.
:param post_trigger_include: trigger id to be used as post operation trigger.
:keyword str session_token: Token for use with Session consistency.
Expand All @@ -428,6 +450,10 @@ def replace_item(
response_hook = kwargs.pop('response_hook', None)
request_options["disableAutomaticIdGeneration"] = True
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics
if pre_trigger_include is not None:
request_options["preTriggerInclude"] = pre_trigger_include
Expand Down Expand Up @@ -457,7 +483,6 @@ def upsert_item(
does not already exist, it is inserted.

:param body: A dict-like object representing the item to update or insert.
:param populate_query_metrics: Enable returning query metrics in response headers.
:param pre_trigger_include: trigger id to be used as pre operation trigger.
:param post_trigger_include: trigger id to be used as post operation trigger.
:keyword str session_token: Token for use with Session consistency.
Expand All @@ -474,6 +499,10 @@ def upsert_item(
response_hook = kwargs.pop('response_hook', None)
request_options["disableAutomaticIdGeneration"] = True
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics
if pre_trigger_include is not None:
request_options["preTriggerInclude"] = pre_trigger_include
Expand Down Expand Up @@ -507,7 +536,6 @@ def create_item(
:func:`ContainerProxy.upsert_item` method.

:param body: A dict-like object representing the item to create.
:param populate_query_metrics: Enable returning query metrics in response headers.
:param pre_trigger_include: trigger id to be used as pre operation trigger.
:param post_trigger_include: trigger id to be used as post operation trigger.
:param indexing_directive: Indicate whether the document should be omitted from indexing.
Expand All @@ -527,6 +555,10 @@ def create_item(

request_options["disableAutomaticIdGeneration"] = not kwargs.pop('enable_automatic_id_generation', False)
if populate_query_metrics:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics
if pre_trigger_include is not None:
request_options["preTriggerInclude"] = pre_trigger_include
Expand Down Expand Up @@ -559,7 +591,6 @@ def delete_item(

:param item: The ID (name) or dict representing item to be deleted.
:param partition_key: Specifies the partition key value for the item.
:param populate_query_metrics: Enable returning query metrics in response headers.
:param pre_trigger_include: trigger id to be used as pre operation trigger.
:param post_trigger_include: trigger id to be used as post operation trigger.
:keyword str session_token: Token for use with Session consistency.
Expand All @@ -577,6 +608,10 @@ def delete_item(
if partition_key is not None:
request_options["partitionKey"] = self._set_partition_key(partition_key)
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics
if pre_trigger_include is not None:
request_options["preTriggerInclude"] = pre_trigger_include
Expand Down
20 changes: 16 additions & 4 deletions sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ def create_database( # pylint: disable=redefined-builtin
Create a new database with the given ID (name).

:param id: ID (name) of the database to create.
:param bool populate_query_metrics: Enable returning query metrics in response headers.
:param int offer_throughput: The provisioned throughput for this offer.
:keyword str session_token: Token for use with Session consistency.
:keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request.
Expand All @@ -264,6 +263,10 @@ def create_database( # pylint: disable=redefined-builtin
request_options = build_options(kwargs)
response_hook = kwargs.pop('response_hook', None)
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics
if offer_throughput is not None:
request_options["offerThroughput"] = offer_throughput
Expand Down Expand Up @@ -350,7 +353,6 @@ def list_databases(
"""List the databases in a Cosmos DB SQL database account.

:param int max_item_count: Max number of items to be returned in the enumeration operation.
:param bool populate_query_metrics: Enable returning query metrics in response headers.
:keyword str session_token: Token for use with Session consistency.
:keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request.
:keyword Callable response_hook: A callable invoked with the response metadata.
Expand All @@ -362,6 +364,10 @@ def list_databases(
if max_item_count is not None:
feed_options["maxItemCount"] = max_item_count
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
feed_options["populateQueryMetrics"] = populate_query_metrics

result = self.client_connection.ReadDatabases(options=feed_options, **kwargs)
Expand All @@ -387,7 +393,6 @@ def query_databases(
:param bool enable_cross_partition_query: Allow scan on the queries which couldn't be
served as indexing was opted out on the requested paths.
:param int max_item_count: Max number of items to be returned in the enumeration operation.
:param bool populate_query_metrics: Enable returning query metrics in response headers.
:keyword str session_token: Token for use with Session consistency.
:keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request.
:keyword Callable response_hook: A callable invoked with the response metadata.
Expand All @@ -401,6 +406,10 @@ def query_databases(
if max_item_count is not None:
feed_options["maxItemCount"] = max_item_count
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
feed_options["populateQueryMetrics"] = populate_query_metrics

if query:
Expand Down Expand Up @@ -430,7 +439,6 @@ def delete_database(
:param database: The ID (name), dict representing the properties or :class:`DatabaseProxy`
instance of the database to delete.
:type database: str or dict(str, str) or ~azure.cosmos.DatabaseProxy
:param bool populate_query_metrics: Enable returning query metrics in response headers.
:keyword str session_token: Token for use with Session consistency.
:keyword dict[str,str] initial_headers: Initial headers to be sent as part of the request.
:keyword str etag: An ETag value, or the wildcard character (*). Used to check if the resource
Expand All @@ -443,6 +451,10 @@ def delete_database(
request_options = build_options(kwargs)
response_hook = kwargs.pop('response_hook', None)
if populate_query_metrics is not None:
warnings.warn(
"the populate_query_metrics flag does not apply to this method and will be removed in the future",
UserWarning,
)
request_options["populateQueryMetrics"] = populate_query_metrics

database_link = self._get_database_link(database)
Expand Down
Loading