Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into expose_length

* 'master' of https://github.com/Azure/azure-sdk-for-python:
  [textanalytics] add :keyword: to docstrings for TextDocumentInput and DetectLanguageInput (Azure#16542)
  [SB] combine conn str parser logic in base handler and _common (Azure#16464)
  [text analytics] add analyze readme bullet point (Azure#16552)
  resolve issues with failing search documents on mindependency checks (Azure#16553)
  [text analytics] analyze changes (Azure#16418)
  [Core] Added enum meta class (Azure#16316)
  Adding missing supported fields to invoice sample (Azure#16547)
  Update EventHub ci.yml to skip unsupported pypy3 (Azure#16545)
  patching the publishing of artifacts only on successful run (Azure#16539)
  need to bump msrest up one (Azure#16544)
  [EventHub&ServiceBUs] Update readme pointing to uamqp installation guidance (added alpine installation) (Azure#16515)
  add dotenv as a dep for azure-sdk-tools (Azure#16532)
  skip prebuilt from_url tests for now (Azure#16534)
  Latest/Minimum filter retrieved packages by pyVersion compatibility (Azure#16510)
  CertificateCredential accepts certs as bytes (Azure#16410)
  • Loading branch information
iscai-msft committed Feb 5, 2021
2 parents 001942a + 6bae810 commit 630bccc
Show file tree
Hide file tree
Showing 137 changed files with 6,473 additions and 28,692 deletions.
3 changes: 2 additions & 1 deletion eng/dependency_tools.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
../../../tools/azure-sdk-tools
../../../tools/azure-sdk-tools
aiohttp>=3.0; python_version >= '3.5'
4 changes: 2 additions & 2 deletions eng/pipelines/templates/steps/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ steps:
Get-Content $_
}
displayName: 'Show .coverage files'
condition: and(succeededOrFailed(), ${{ parameters.RunCoverage }})
condition: and(succeeded(), ${{ parameters.RunCoverage }})
- task: PublishPipelineArtifact@1
displayName: 'Publish .coverage files'
continueOnError: true
condition: and(succeededOrFailed(), ${{ parameters.RunCoverage }})
condition: and(succeeded(), ${{ parameters.RunCoverage }})
inputs:
targetPath: '$(Build.SourcesDirectory)/_coverage'
artifactType: 'pipeline'
Expand Down
2 changes: 1 addition & 1 deletion eng/tox/install_depend_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def process_requirement(req, dependency_type):

# get available versions on PyPI
client = PyPIClient()
versions = [str(v) for v in client.get_ordered_versions(pkg_name)]
versions = [str(v) for v in client.get_ordered_versions(pkg_name, True)]
logging.info("Versions available on PyPI for %s: %s", pkg_name, versions)

if pkg_name in MINIMUM_VERSION_SUPPORTED_OVERRIDE:
Expand Down
1 change: 1 addition & 0 deletions scripts/devops_tasks/common_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"azure",
"azure-mgmt",
"azure-storage",
"azure-mgmt-regionmove"
]
MANAGEMENT_PACKAGE_IDENTIFIERS = [
"mgmt",
Expand Down
1 change: 1 addition & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

- Added `CaseInsensitiveEnumMeta` class for case-insensitive enums. #16316
- Add `raise_for_status` method onto `HttpResponse`. Calling `response.raise_for_status()` on a response with an error code
will raise an `HttpResponseError`. Calling it on a good response will do nothing #16399

Expand Down
14 changes: 14 additions & 0 deletions sdk/core/azure-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ class MatchConditions(Enum):
IfMissing = 5
```

#### CaseInsensitiveEnumMeta

A metaclass to support case-insensitive enums.
```python
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta

class MyCustomEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
FOO = 'foo'
BAR = 'bar'
```

## Contributing
This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
Expand Down
4 changes: 3 additions & 1 deletion sdk/core/azure-core/azure/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@

from ._pipeline_client import PipelineClient
from ._match_conditions import MatchConditions
from ._enum_meta import CaseInsensitiveEnumMeta


__all__ = [
"PipelineClient",
"MatchConditions"
"MatchConditions",
"CaseInsensitiveEnumMeta"
]

try:
Expand Down
61 changes: 61 additions & 0 deletions sdk/core/azure-core/azure/core/_enum_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# --------------------------------------------------------------------------
#
# 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.
#
# --------------------------------------------------------------------------

from enum import EnumMeta


class CaseInsensitiveEnumMeta(EnumMeta):
"""Enum metaclass to allow for interoperability with case-insensitive strings.
Consuming this metaclass in an SDK should be done in the following manner:
.. code-block:: python
from enum import Enum
from six import with_metaclass
from azure.core import CaseInsensitiveEnumMeta
class MyCustomEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
FOO = 'foo'
BAR = 'bar'
"""

def __getitem__(cls, name):
# disabling pylint bc of pylint bug https://github.com/PyCQA/astroid/issues/713
return super(CaseInsensitiveEnumMeta, cls).__getitem__(name.upper()) # pylint: disable=no-value-for-parameter

def __getattr__(cls, name):
"""Return the enum member matching `name`
We use __getattr__ instead of descriptors or inserting into the enum
class' __dict__ in order to support `name` and `value` being both
properties for enum members (which live in the class' __dict__) and
enum members themselves.
"""
try:
return cls._member_map_[name.upper()]
except KeyError:
raise AttributeError(name)
44 changes: 44 additions & 0 deletions sdk/core/azure-core/tests/test_enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# --------------------------------------------------------------------------
#
# 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.
#
# --------------------------------------------------------------------------
from enum import Enum
from six import with_metaclass

from azure.core import CaseInsensitiveEnumMeta

class MyCustomEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
FOO = 'foo'
BAR = 'bar'


def test_case_insensitive_enums():
assert MyCustomEnum.foo.value == 'foo'
assert MyCustomEnum.FOO.value == 'foo'
assert MyCustomEnum('bar').value == 'bar'
assert 'bar' == MyCustomEnum.BAR
assert 'bar' == MyCustomEnum.bar
assert MyCustomEnum['foo'] == 'foo'
assert MyCustomEnum['FOO'] == 'foo'
assert isinstance(MyCustomEnum.BAR, str)
8 changes: 8 additions & 0 deletions sdk/eventhub/azure-eventhub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ Reference documentation is available [here](https://azuresdkdocs.blob.core.windo
The EventHubs SDK integrates nicely with the [Schema Registry][schemaregistry_service] service and [Avro][avro].
For more information, please refer to [Schema Registry SDK][schemaregistry_repo] and [Schema Registry Avro Serializer SDK][schemaregistry_avroserializer_repo].

### Building uAMQP wheel from source

`azure-eventhub` depends on the [uAMQP](https://pypi.org/project/uamqp/) for the AMQP protocol implementation.
uAMQP wheels are provided for most major operating systems and will be installed automatically when installing `azure-eventhub`.

If you're running on a platform for which uAMQP wheels are not provided, please follow
the [uAMQP Installation](https://github.com/Azure/azure-uamqp-python#installation) guidance to install from source.

### Provide Feedback

If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project.
Expand Down
1 change: 1 addition & 0 deletions sdk/eventhub/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ extends:
safeName: azureeventhubcheckpointstoreblob
- name: azure_mgmt_eventhub
safeName: azuremgmteventhub
SkipPythonVersion: 'pypy3'
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RecognizeInvoiceSampleAsync(object):

async def recognize_invoice(self):
path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__),
"..", "..", "./sample_forms/forms/Invoice_1.pdf"))
"..", "..", "./sample_forms/forms/sample_invoice.jpg"))

# [START recognize_invoices_async]
from azure.core.credentials import AzureKeyCredential
Expand All @@ -55,9 +55,15 @@ async def recognize_invoice(self):
vendor_address = invoice.fields.get("VendorAddress")
if vendor_address:
print("Vendor Address: {} has confidence: {}".format(vendor_address.value, vendor_address.confidence))
vendor_address_recipient = invoice.fields.get("VendorAddressRecipient")
if vendor_address_recipient:
print("Vendor Address Recipient: {} has confidence: {}".format(vendor_address_recipient.value, vendor_address_recipient.confidence))
customer_name = invoice.fields.get("CustomerName")
if customer_name:
print("Customer Name: {} has confidence: {}".format(customer_name.value, customer_name.confidence))
customer_id = invoice.fields.get("CustomerId")
if customer_id:
print("Customer Id: {} has confidence: {}".format(customer_id.value, customer_id.confidence))
customer_address = invoice.fields.get("CustomerAddress")
if customer_address:
print("Customer Address: {} has confidence: {}".format(customer_address.value, customer_address.confidence))
Expand All @@ -76,6 +82,51 @@ async def recognize_invoice(self):
due_date = invoice.fields.get("DueDate")
if due_date:
print("Due Date: {} has confidence: {}".format(due_date.value, due_date.confidence))
purchase_order = invoice.fields.get("PurchaseOrder")
if purchase_order:
print("Purchase Order: {} has confidence: {}".format(purchase_order.value, purchase_order.confidence))
billing_address = invoice.fields.get("BillingAddress")
if billing_address:
print("Billing Address: {} has confidence: {}".format(billing_address.value, billing_address.confidence))
billing_address_recipient = invoice.fields.get("BillingAddressRecipient")
if billing_address_recipient:
print("Billing Address Recipient: {} has confidence: {}".format(billing_address_recipient.value, billing_address_recipient.confidence))
shipping_address = invoice.fields.get("ShippingAddress")
if shipping_address:
print("Shipping Address: {} has confidence: {}".format(shipping_address.value, shipping_address.confidence))
shipping_address_recipient = invoice.fields.get("ShippingAddressRecipient")
if shipping_address_recipient:
print("Shipping Address Recipient: {} has confidence: {}".format(shipping_address_recipient.value, shipping_address_recipient.confidence))
subtotal = invoice.fields.get("SubTotal")
if subtotal:
print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
total_tax = invoice.fields.get("TotalTax")
if total_tax:
print("Total Tax: {} has confidence: {}".format(total_tax.value, total_tax.confidence))
previous_unpaid_balance = invoice.fields.get("PreviousUnpaidBalance")
if previous_unpaid_balance:
print("Previous Unpaid Balance: {} has confidence: {}".format(previous_unpaid_balance.value, previous_unpaid_balance.confidence))
amount_due = invoice.fields.get("AmountDue")
if amount_due:
print("Amount Due: {} has confidence: {}".format(amount_due.value, amount_due.confidence))
service_start_date = invoice.fields.get("ServiceStartDate")
if service_start_date:
print("Service Start Date: {} has confidence: {}".format(service_start_date.value, service_start_date.confidence))
service_end_date = invoice.fields.get("ServiceEndDate")
if service_end_date:
print("Service End Date: {} has confidence: {}".format(service_end_date.value, service_end_date.confidence))
service_address = invoice.fields.get("ServiceAddress")
if service_address:
print("Service Address: {} has confidence: {}".format(service_address.value, service_address.confidence))
service_address_recipient = invoice.fields.get("ServiceAddressRecipient")
if service_address_recipient:
print("Service Address Recipient: {} has confidence: {}".format(service_address_recipient.value, service_address_recipient.confidence))
remittance_address = invoice.fields.get("RemittanceAddress")
if remittance_address:
print("Remittance Address: {} has confidence: {}".format(remittance_address.value, remittance_address.confidence))
remittance_address_recipient = invoice.fields.get("RemittanceAddressRecipient")
if remittance_address_recipient:
print("Remittance Address Recipient: {} has confidence: {}".format(remittance_address_recipient.value, remittance_address_recipient.confidence))
# [END recognize_invoices_async]

async def main():
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RecognizeInvoiceSample(object):

def recognize_invoice(self):
path_to_sample_forms = os.path.abspath(os.path.join(os.path.abspath(__file__),
"..", "./sample_forms/forms/Invoice_1.pdf"))
"..", "./sample_forms/forms/sample_invoice.jpg"))

# [START recognize_invoices]
from azure.core.credentials import AzureKeyCredential
Expand All @@ -54,9 +54,15 @@ def recognize_invoice(self):
vendor_address = invoice.fields.get("VendorAddress")
if vendor_address:
print("Vendor Address: {} has confidence: {}".format(vendor_address.value, vendor_address.confidence))
vendor_address_recipient = invoice.fields.get("VendorAddressRecipient")
if vendor_address_recipient:
print("Vendor Address Recipient: {} has confidence: {}".format(vendor_address_recipient.value, vendor_address_recipient.confidence))
customer_name = invoice.fields.get("CustomerName")
if customer_name:
print("Customer Name: {} has confidence: {}".format(customer_name.value, customer_name.confidence))
customer_id = invoice.fields.get("CustomerId")
if customer_id:
print("Customer Id: {} has confidence: {}".format(customer_id.value, customer_id.confidence))
customer_address = invoice.fields.get("CustomerAddress")
if customer_address:
print("Customer Address: {} has confidence: {}".format(customer_address.value, customer_address.confidence))
Expand All @@ -75,6 +81,51 @@ def recognize_invoice(self):
due_date = invoice.fields.get("DueDate")
if due_date:
print("Due Date: {} has confidence: {}".format(due_date.value, due_date.confidence))
purchase_order = invoice.fields.get("PurchaseOrder")
if purchase_order:
print("Purchase Order: {} has confidence: {}".format(purchase_order.value, purchase_order.confidence))
billing_address = invoice.fields.get("BillingAddress")
if billing_address:
print("Billing Address: {} has confidence: {}".format(billing_address.value, billing_address.confidence))
billing_address_recipient = invoice.fields.get("BillingAddressRecipient")
if billing_address_recipient:
print("Billing Address Recipient: {} has confidence: {}".format(billing_address_recipient.value, billing_address_recipient.confidence))
shipping_address = invoice.fields.get("ShippingAddress")
if shipping_address:
print("Shipping Address: {} has confidence: {}".format(shipping_address.value, shipping_address.confidence))
shipping_address_recipient = invoice.fields.get("ShippingAddressRecipient")
if shipping_address_recipient:
print("Shipping Address Recipient: {} has confidence: {}".format(shipping_address_recipient.value, shipping_address_recipient.confidence))
subtotal = invoice.fields.get("SubTotal")
if subtotal:
print("Subtotal: {} has confidence: {}".format(subtotal.value, subtotal.confidence))
total_tax = invoice.fields.get("TotalTax")
if total_tax:
print("Total Tax: {} has confidence: {}".format(total_tax.value, total_tax.confidence))
previous_unpaid_balance = invoice.fields.get("PreviousUnpaidBalance")
if previous_unpaid_balance:
print("Previous Unpaid Balance: {} has confidence: {}".format(previous_unpaid_balance.value, previous_unpaid_balance.confidence))
amount_due = invoice.fields.get("AmountDue")
if amount_due:
print("Amount Due: {} has confidence: {}".format(amount_due.value, amount_due.confidence))
service_start_date = invoice.fields.get("ServiceStartDate")
if service_start_date:
print("Service Start Date: {} has confidence: {}".format(service_start_date.value, service_start_date.confidence))
service_end_date = invoice.fields.get("ServiceEndDate")
if service_end_date:
print("Service End Date: {} has confidence: {}".format(service_end_date.value, service_end_date.confidence))
service_address = invoice.fields.get("ServiceAddress")
if service_address:
print("Service Address: {} has confidence: {}".format(service_address.value, service_address.confidence))
service_address_recipient = invoice.fields.get("ServiceAddressRecipient")
if service_address_recipient:
print("Service Address Recipient: {} has confidence: {}".format(service_address_recipient.value, service_address_recipient.confidence))
remittance_address = invoice.fields.get("RemittanceAddress")
if remittance_address:
print("Remittance Address: {} has confidence: {}".format(remittance_address.value, remittance_address.confidence))
remittance_address_recipient = invoice.fields.get("RemittanceAddressRecipient")
if remittance_address_recipient:
print("Remittance Address Recipient: {} has confidence: {}".format(remittance_address_recipient.value, remittance_address_recipient.confidence))
# [END recognize_invoices]

if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

GlobalClientPreparer = functools.partial(_GlobalClientPreparer, FormRecognizerClient)


@pytest.mark.skip
class TestBusinessCardFromUrl(FormRecognizerTest):

@FormRecognizerPreparer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

GlobalClientPreparer = functools.partial(_GlobalClientPreparer, FormRecognizerClient)


@pytest.mark.skip
class TestBusinessCardFromUrlAsync(AsyncFormRecognizerTest):

@FormRecognizerPreparer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

GlobalClientPreparer = functools.partial(_GlobalClientPreparer, FormRecognizerClient)


@pytest.mark.skip
class TestInvoiceFromUrl(FormRecognizerTest):

@FormRecognizerPreparer()
Expand Down
Loading

0 comments on commit 630bccc

Please sign in to comment.