diff --git a/sdk/monitor/azure-mgmt-monitor/setup.py b/sdk/monitor/azure-mgmt-monitor/setup.py index 4ad645a7aa77..914a143a995b 100644 --- a/sdk/monitor/azure-mgmt-monitor/setup.py +++ b/sdk/monitor/azure-mgmt-monitor/setup.py @@ -68,7 +68,7 @@ install_requires=[ 'msrest>=0.6.21', 'azure-common~=1.1', - 'azure-mgmt-core>=1.2.0,<2.0.0', + 'azure-mgmt-core>=1.3.0,<2.0.0', ], python_requires=">=3.6", ) diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 6636cbd4696f..13c41e50b408 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -2,13 +2,11 @@ ## 1.0.2 (Unreleased) -### Features Added - -### Breaking Changes +- This version and all future versions will require Python 3.7+. Python 2.7 and 3.6 are no longer supported. ### Bugs Fixed -### Other Changes +- Fixed a bug where having a None value in datetime throws ## 1.0.1 (2021-11-09) diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index f8816eab0ab1..d1d40d031cd9 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -16,13 +16,13 @@ The Azure Monitor Query client library is used to execute read-only queries agai ## _Disclaimer_ -_Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ +_Azure SDK Python packages support for Python 2.7 has ended on 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ ## Getting started ### Prerequisites -- Python 2.7, or 3.6 or later +- Python 3.6 or later - An [Azure subscription][azure_subscription] - To query Logs, you need an [Azure Log Analytics workspace][azure_monitor_create_using_portal]. - To query Metrics, you need an Azure resource of any kind (Storage Account, Key Vault, Cosmos DB, etc.). diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py index b23fcd8ec0c8..2739c697b0d6 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_helpers.py @@ -116,7 +116,12 @@ def construct_iso8601(timespan=None): def native_col_type(col_type, value): if col_type == "datetime": - value = Deserializer.deserialize_iso(value) + try: + value = Deserializer.deserialize_iso(value) + except: # pylint: disable=bare-except + # if there is any exception in deserializing the iso, + # return the value to the user + pass elif col_type in ("timespan", "guid"): value = str(value) return value diff --git a/sdk/monitor/azure-monitor-query/dev_requirements.txt b/sdk/monitor/azure-monitor-query/dev_requirements.txt index fdddf49adce6..fcfa054d893f 100644 --- a/sdk/monitor/azure-monitor-query/dev_requirements.txt +++ b/sdk/monitor/azure-monitor-query/dev_requirements.txt @@ -3,4 +3,4 @@ -e ../../core/azure-core -e ../../identity/azure-identity azure-mgmt-loganalytics -aiohttp>=3.0; python_version >= '3.5' +aiohttp>=3.0 diff --git a/sdk/monitor/azure-monitor-query/samples/README.md b/sdk/monitor/azure-monitor-query/samples/README.md index 6b514406aaf3..4105b92bb931 100644 --- a/sdk/monitor/azure-monitor-query/samples/README.md +++ b/sdk/monitor/azure-monitor-query/samples/README.md @@ -31,11 +31,11 @@ The following code samples show common scenarios with the Azure Monitor Query cl ## _Disclaimer_ -_Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_. +_Azure SDK Python packages support for Python 2.7 has ended on 01 January 2022. For more information and questions, refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_. ## Prerequisites -- Python 2.7, or 3.6 or later +- Python 3.6 or later - An [Azure subscription][azure_subscription] - To query Logs, you need an [Azure Log Analytics workspace][azure_monitor_create_using_portal]. - To query Metrics, you need an Azure resource of any kind (Storage Account, Key Vault, Cosmos DB, etc.). diff --git a/sdk/monitor/azure-monitor-query/setup.cfg b/sdk/monitor/azure-monitor-query/setup.cfg deleted file mode 100644 index 3c6e79cf31da..000000000000 --- a/sdk/monitor/azure-monitor-query/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal=1 diff --git a/sdk/monitor/azure-monitor-query/setup.py b/sdk/monitor/azure-monitor-query/setup.py index 7b336ee68a6e..f72bd93c4d17 100644 --- a/sdk/monitor/azure-monitor-query/setup.py +++ b/sdk/monitor/azure-monitor-query/setup.py @@ -63,9 +63,7 @@ classifiers=[ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', @@ -73,6 +71,7 @@ 'Programming Language :: Python :: 3.10', 'License :: OSI Approved :: MIT License', ], + python_requires=">=3.6", zip_safe=False, packages=find_packages(exclude=[ 'tests', @@ -84,8 +83,5 @@ install_requires=[ 'msrest>=0.6.19', 'azure-core<2.0.0,>=1.12.0', - ], - extras_require={ - ":python_version<'3.0'": ['azure-monitor-nspkg'], - } + ] ) diff --git a/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py b/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py index 98fb8d260dec..635fdd2f9162 100644 --- a/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py +++ b/sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py @@ -159,7 +159,7 @@ async def test_logs_query_batch_additional_workspaces(): async def test_logs_single_query_with_render(): credential = _credential() client = LogsQueryClient(credential) - query = """AppRequests""" + query = """AppRequests | take 10""" # returns LogsQueryResult response = await client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True) @@ -171,7 +171,7 @@ async def test_logs_single_query_with_render(): async def test_logs_single_query_with_render_and_stats(): credential = _credential() client = LogsQueryClient(credential) - query = """AppRequests""" + query = """AppRequests | take 10""" # returns LogsQueryResult response = await client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True, include_statistics=True) @@ -184,7 +184,7 @@ async def test_logs_single_query_with_render_and_stats(): async def test_logs_query_result_iterate_over_tables(): client = LogsQueryClient(_credential()) - query = "AppRequests; AppRequests | take 5" + query = "AppRequests | take 10; AppRequests | take 5" response = await client.query_workspace( os.environ['LOG_WORKSPACE_ID'], diff --git a/sdk/monitor/azure-monitor-query/tests/conftest.py b/sdk/monitor/azure-monitor-query/tests/conftest.py deleted file mode 100644 index 2e685fe040dd..000000000000 --- a/sdk/monitor/azure-monitor-query/tests/conftest.py +++ /dev/null @@ -1,33 +0,0 @@ -# -------------------------------------------------------------------------- -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# The MIT License (MIT) -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the ""Software""), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# -------------------------------------------------------------------------- -import platform -import sys - - -# Ignore async tests for Python < 3.5 -collect_ignore_glob = [] -if sys.version_info < (3, 5): - collect_ignore_glob.append("*_async.py") diff --git a/sdk/monitor/azure-monitor-query/tests/test_logs_client.py b/sdk/monitor/azure-monitor-query/tests/test_logs_client.py index 903151418791..8449ad02f7c2 100644 --- a/sdk/monitor/azure-monitor-query/tests/test_logs_client.py +++ b/sdk/monitor/azure-monitor-query/tests/test_logs_client.py @@ -4,6 +4,7 @@ from azure.identity import ClientSecretCredential from azure.core.exceptions import HttpResponseError from azure.monitor.query import LogsQueryClient, LogsBatchQuery, LogsQueryError, LogsTable, LogsQueryResult, LogsTableRow, LogsQueryPartialResult +from azure.monitor.query._helpers import native_col_type def _credential(): credential = ClientSecretCredential( @@ -117,7 +118,7 @@ def test_logs_query_batch_default(): def test_logs_single_query_with_statistics(): credential = _credential() client = LogsQueryClient(credential) - query = """AppRequests""" + query = """AppRequests | take 10""" # returns LogsQueryResult response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_statistics=True) @@ -128,7 +129,7 @@ def test_logs_single_query_with_statistics(): def test_logs_single_query_with_render(): credential = _credential() client = LogsQueryClient(credential) - query = """AppRequests""" + query = """AppRequests | take 10""" # returns LogsQueryResult response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True) @@ -139,7 +140,7 @@ def test_logs_single_query_with_render(): def test_logs_single_query_with_render_and_stats(): credential = _credential() client = LogsQueryClient(credential) - query = """AppRequests""" + query = """AppRequests | take 10""" # returns LogsQueryResult response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True, include_statistics=True) @@ -228,7 +229,7 @@ def test_logs_query_batch_additional_workspaces(): def test_logs_query_result_iterate_over_tables(): client = LogsQueryClient(_credential()) - query = "AppRequests; AppRequests | take 5" + query = "AppRequests | take 10; AppRequests | take 5" response = client.query_workspace( os.environ['LOG_WORKSPACE_ID'], @@ -265,3 +266,10 @@ def test_logs_query_result_row_type(): for row in table.rows: assert row.__class__ == LogsTableRow + +def test_native_col_type(): + val = native_col_type('datetime', None) + assert val is None + + val = native_col_type('datetime', '2020-10-10') + assert val is not None diff --git a/shared_requirements.txt b/shared_requirements.txt index 227fadf9e454..dd41359587b6 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -283,3 +283,4 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-appconfiguration azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-dnsresolver msrest>=0.6.21 #override azure-mgmt-dnsresolver azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-monitor azure-mgmt-core>=1.3.0,<2.0.0