Skip to content

Commit

Permalink
Removed **provisional** from computed_properties (#39543)
Browse files Browse the repository at this point in the history
* removed **provisional** from computed_properties

* updated changelog

* added computed_properties keyword argument to function def

* annotated computed_properties tests

* added replace computed_properties feature with tests

* added replace computed_properties feature with tests

* changed test class annotation to cosmosQuery, removed extra annotations

---------

Co-authored-by: Andrew Mathew <andrewmathew@microsoft.com>
  • Loading branch information
andrewmathew1 and Andrew Mathew authored Feb 13, 2025
1 parent 87d4a32 commit 3c200e5
Show file tree
Hide file tree
Showing 9 changed files with 526 additions and 357 deletions.
2 changes: 2 additions & 0 deletions sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
### 4.9.1b5 (Unreleased)

#### Features Added
* Added ability to replace `computed_properties` through `replace_container` method. See [PR 39543](https://github.com/Azure/azure-sdk-for-python/pull/39543)

#### Breaking Changes

#### Bugs Fixed

#### Other Changes
* Un-marked `computed_properties` keyword as **provisional**. See [PR 39543](https://github.com/Azure/azure-sdk-for-python/pull/39543)

### 4.9.1b4 (2025-02-06)

Expand Down
13 changes: 9 additions & 4 deletions sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ async def create_container(
initial_headers: Optional[Dict[str, str]] = None,
etag: Optional[str] = None,
match_condition: Optional[MatchConditions] = None,
computed_properties: Optional[List[Dict[str, str]]] = None,
analytical_storage_ttl: Optional[int] = None,
vector_embedding_policy: Optional[Dict[str, Any]] = None,
change_feed_policy: Optional[Dict[str, Any]] = None,
Expand All @@ -199,7 +200,7 @@ async def create_container(
has changed, and act according to the condition specified by the `match_condition` parameter.
:keyword match_condition: The match condition to use upon the etag.
:paramtype match_condition: ~azure.core.MatchConditions
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
:keyword response_hook: A callable invoked with the response metadata.
Expand Down Expand Up @@ -255,7 +256,6 @@ async def create_container(
definition["conflictResolutionPolicy"] = conflict_resolution_policy
if analytical_storage_ttl is not None:
definition["analyticalStorageTtl"] = analytical_storage_ttl
computed_properties = kwargs.pop('computed_properties', None)
if computed_properties is not None:
definition["computedProperties"] = computed_properties
if vector_embedding_policy is not None:
Expand Down Expand Up @@ -296,6 +296,7 @@ async def create_container_if_not_exists(
initial_headers: Optional[Dict[str, str]] = None,
etag: Optional[str] = None,
match_condition: Optional[MatchConditions] = None,
computed_properties: Optional[List[Dict[str, str]]] = None,
analytical_storage_ttl: Optional[int] = None,
vector_embedding_policy: Optional[Dict[str, Any]] = None,
change_feed_policy: Optional[Dict[str, Any]] = None,
Expand Down Expand Up @@ -324,7 +325,7 @@ async def create_container_if_not_exists(
has changed, and act according to the condition specified by the `match_condition` parameter.
:keyword match_condition: The match condition to use upon the etag.
:paramtype match_condition: ~azure.core.MatchConditions
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
:keyword response_hook: A callable invoked with the response metadata.
Expand All @@ -344,7 +345,6 @@ async def create_container_if_not_exists(
:returns: A `ContainerProxy` instance representing the new container.
:rtype: ~azure.cosmos.aio.ContainerProxy
"""
computed_properties = kwargs.pop("computed_properties", None)
try:
container_proxy = self.get_container_client(id)
await container_proxy.read(
Expand Down Expand Up @@ -504,6 +504,7 @@ async def replace_container(
etag: Optional[str] = None,
match_condition: Optional[MatchConditions] = None,
analytical_storage_ttl: Optional[int] = None,
computed_properties: Optional[List[Dict[str, str]]] = None,
full_text_policy: Optional[Dict[str, Any]] = None,
**kwargs: Any
) -> ContainerProxy:
Expand All @@ -530,6 +531,9 @@ async def replace_container(
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
note that analytical storage can only be enabled on Synapse Link enabled accounts.
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
:keyword response_hook: A callable invoked with the response metadata.
:paramtype response_hook: Callable[[Dict[str, str], Dict[str, Any]], None]
:keyword Dict[str, Any] full_text_policy: **provisional** The full text policy for the container.
Expand Down Expand Up @@ -571,6 +575,7 @@ async def replace_container(
"defaultTtl": default_ttl,
"conflictResolutionPolicy": conflict_resolution_policy,
"analyticalStorageTtl": analytical_storage_ttl,
"computedProperties": computed_properties,
"fullTextPolicy": full_text_policy
}.items()
if value is not None
Expand Down
13 changes: 9 additions & 4 deletions sdk/cosmos/azure-cosmos/azure/cosmos/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def create_container( # pylint:disable=docstring-missing-param
etag: Optional[str] = None,
match_condition: Optional[MatchConditions] = None,
analytical_storage_ttl: Optional[int] = None,
computed_properties: Optional[List[Dict[str, str]]] = None,
vector_embedding_policy: Optional[Dict[str, Any]] = None,
change_feed_policy: Optional[Dict[str, Any]] = None,
full_text_policy: Optional[Dict[str, Any]] = None,
Expand All @@ -200,7 +201,7 @@ def create_container( # pylint:disable=docstring-missing-param
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
note that analytical storage can only be enabled on Synapse Link enabled accounts.
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
:keyword Dict[str, Any] vector_embedding_policy: **provisional** The vector embedding policy for the container.
Expand Down Expand Up @@ -249,7 +250,6 @@ def create_container( # pylint:disable=docstring-missing-param
definition["conflictResolutionPolicy"] = conflict_resolution_policy
if analytical_storage_ttl is not None:
definition["analyticalStorageTtl"] = analytical_storage_ttl
computed_properties = kwargs.pop('computed_properties', None)
if computed_properties is not None:
definition["computedProperties"] = computed_properties
if vector_embedding_policy is not None:
Expand Down Expand Up @@ -298,6 +298,7 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param
etag: Optional[str] = None,
match_condition: Optional[MatchConditions] = None,
analytical_storage_ttl: Optional[int] = None,
computed_properties: Optional[List[Dict[str, str]]] = None,
vector_embedding_policy: Optional[Dict[str, Any]] = None,
change_feed_policy: Optional[Dict[str, Any]] = None,
full_text_policy: Optional[Dict[str, Any]] = None,
Expand Down Expand Up @@ -326,7 +327,7 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
note that analytical storage can only be enabled on Synapse Link enabled accounts.
:keyword List[Dict[str, str]] computed_properties: **provisional** Sets The computed properties for this
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
:keyword Dict[str, Any] vector_embedding_policy: The vector embedding policy for the container. Each vector
Expand All @@ -341,7 +342,6 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param
:raises ~azure.cosmos.exceptions.CosmosHttpResponseError: The container read or creation failed.
:rtype: ~azure.cosmos.ContainerProxy
"""
computed_properties = kwargs.pop("computed_properties", None)
try:
container_proxy = self.get_container_client(id)
container_proxy.read(
Expand Down Expand Up @@ -559,6 +559,7 @@ def replace_container( # pylint:disable=docstring-missing-param
etag: Optional[str] = None,
match_condition: Optional[MatchConditions] = None,
analytical_storage_ttl: Optional[int] = None,
computed_properties: Optional[List[Dict[str, str]]] = None,
full_text_policy: Optional[Dict[str, Any]] = None,
**kwargs: Any
) -> ContainerProxy:
Expand All @@ -583,6 +584,9 @@ def replace_container( # pylint:disable=docstring-missing-param
:keyword int analytical_storage_ttl: Analytical store time to live (TTL) for items in the container. A value of
None leaves analytical storage off and a value of -1 turns analytical storage on with no TTL. Please
note that analytical storage can only be enabled on Synapse Link enabled accounts.
:keyword List[Dict[str, str]] computed_properties: Sets The computed properties for this
container in the Azure Cosmos DB Service. For more Information on how to use computed properties visit
`here: https://learn.microsoft.com/azure/cosmos-db/nosql/query/computed-properties?tabs=dotnet`
:keyword Callable response_hook: A callable invoked with the response metadata.
:keyword Dict[str, Any] full_text_policy: **provisional** The full text policy for the container.
Used to denote the default language to be used for all full text indexes, or to individually
Expand Down Expand Up @@ -628,6 +632,7 @@ def replace_container( # pylint:disable=docstring-missing-param
"defaultTtl": default_ttl,
"conflictResolutionPolicy": conflict_resolution_policy,
"analyticalStorageTtl": analytical_storage_ttl,
"computedProperties": computed_properties,
"fullTextPolicy": full_text_policy,
}.items()
if value is not None
Expand Down
Loading

0 comments on commit 3c200e5

Please sign in to comment.