Skip to content

Commit

Permalink
[SchemaRegistry] avro sphinx docs/typing-extensions dependency (Azure…
Browse files Browse the repository at this point in the history
  • Loading branch information
swathipil authored Apr 1, 2022
1 parent e53a1db commit d202434
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,12 @@
"unpartial",
"alru"
]
},
{
"filename": "sdk/schemaregistry/azure-schemaregistry-avroencoder/doc/*.rst",
"words": [
"undoc"
]
}
],
"allowCompoundWords": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ include azure/__init__.py
include azure/schemaregistry/__init__.py
recursive-include tests *.py
recursive-include samples *.py
include azure/schemaregistry/encoder/avroencoder/py.typed
include azure/schemaregistry/encoder/avroencoder/py.typed
recursive-include doc *.rst
5 changes: 3 additions & 2 deletions sdk/schemaregistry/azure-schemaregistry-avroencoder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pip install azure-schemaregistry-avroencoder azure-identity
### Prerequisites:
To use this package, you must have:
* Azure subscription - [Create a free account][azure_sub]
* [Azure Schema Registry][schemaregistry_service]
* [Azure Schema Registry][schemaregistry_service] - [Here is the quickstart guide][quickstart_guide] to create a Schema Registry group using the Azure portal.
* Python 3.6 or later - [Install Python][python]

### Authenticate the client
Expand Down Expand Up @@ -326,4 +326,5 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
[schemaregistry_service]: https://aka.ms/schemaregistry
[eventhubs_repo]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/eventhub/azure-eventhub
[token_credential_interface]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/core/azure-core/azure/core/credentials.py
[pypi_azure_identity]: https://pypi.org/project/azure-identity/
[pypi_azure_identity]: https://pypi.org/project/azure-identity/
[quickstart_guide]: https://docs.microsoft.com/azure/event-hubs/create-schema-registry
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ def validate_message(message: Union[MessageType, MessageContent]):

try:
content_type_parts = content_type.split("+")
if len(content_type_parts) != 2:
if len(content_type_parts) != 2 or content_type_parts[0] != AVRO_MIME_TYPE:
raise InvalidContentError(
"Content type was not in the expected format of MIME type + schema ID."
f"Content type {content_type} was not in the expected format of Avro MIME type + schema ID."
)
schema_id = content_type_parts[1]
except AttributeError:
raise InvalidContentError(
f"Content type {content_type} was not in the expected format of MIME type + schema ID."
f"Content type {content_type} was not in the expected format of Avro MIME type + schema ID."
)

return schema_id, content
Expand Down
15 changes: 15 additions & 0 deletions sdk/schemaregistry/azure-schemaregistry-avroencoder/doc/azure.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
azure package
=============

.. automodule:: azure
:members:
:undoc-members:
:inherited-members:

Subpackages
-----------

.. toctree::
:maxdepth: 4

azure.schemaregistry
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
azure.schemaregistry.encoder.avroencoder.aio package
====================================================

.. automodule:: azure.schemaregistry.encoder.avroencoder.aio
:members:
:undoc-members:
:inherited-members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
azure.schemaregistry.encoder.avroencoder package
================================================

.. automodule:: azure.schemaregistry.encoder.avroencoder
:members:
:undoc-members:
:inherited-members:
:special-members: __message_content__

Subpackages
-----------

.. toctree::
:maxdepth: 4

azure.schemaregistry.encoder.avroencoder.aio
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
azure.schemaregistry.encoder package
====================================

.. automodule:: azure.schemaregistry.encoder
:members:
:undoc-members:
:inherited-members:

Subpackages
-----------

.. toctree::
:maxdepth: 4

azure.schemaregistry.encoder.avroencoder
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
azure.schemaregistry package
============================

.. automodule:: azure.schemaregistry
:members:
:undoc-members:
:inherited-members:

Subpackages
-----------

.. toctree::
:maxdepth: 4

azure.schemaregistry.encoder
19 changes: 6 additions & 13 deletions sdk/schemaregistry/azure-schemaregistry-avroencoder/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys
import os.path
from io import open
from setuptools import find_packages, setup
from setuptools import find_namespace_packages, setup

# Change the PACKAGE_NAME only to change folder and different name
PACKAGE_NAME = "azure-schemaregistry-avroencoder"
Expand All @@ -32,16 +32,10 @@
with open('CHANGELOG.md', encoding='utf-8') as f:
changelog = f.read()

exclude_packages = [
'tests',
'samples',
# Exclude packages that will be covered by PEP420 or nspkg
'azure',
'azure.schemaregistry',
]
install_packages = [
'azure-schemaregistry>=1.0.0,<2.0.0',
'avro>=1.11.0'
'avro>=1.11.0',
"typing-extensions>=4.0.1",
]

setup(
Expand All @@ -67,9 +61,8 @@
],
python_requires=">=3.6",
zip_safe=False,
packages=[
'azure.schemaregistry.encoder.avroencoder',
'azure.schemaregistry.encoder.avroencoder.aio',
],
packages=find_namespace_packages(
include=['azure.schemaregistry.encoder.*'] # Exclude packages that will be covered by PEP420 or nspkg
),
install_requires=install_packages
)
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def test_basic_sr_avro_encoder_with_auto_register_schemas(self, **kwargs):
assert decoded_content["favorite_color"] == u"red"

# bad content type
mime_type, schema_id = encoded_content_dict["content_type"].split("+")
encoded_content_dict["content_type"] = "binary/fake+" + schema_id
with pytest.raises(InvalidContentError) as e:
decoded_content = sr_avro_encoder.decode(encoded_content_dict)

encoded_content_dict["content_type"] = 'a+b+c'
with pytest.raises(InvalidContentError) as e:
decoded_content = sr_avro_encoder.decode(encoded_content_dict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ async def test_basic_sr_avro_encoder_with_auto_register_schemas(self, schemaregi
assert decoded_content["favorite_color"] == u"red"

# bad content type
mime_type, schema_id = encoded_content_dict["content_type"].split("+")
encoded_content_dict["content_type"] = "binary/fake+" + schema_id
with pytest.raises(InvalidContentError) as e:
decoded_content = await sr_avro_encoder.decode(encoded_content_dict)

encoded_content_dict["content_type"] = 'a+b+c'
with pytest.raises(InvalidContentError) as e:
decoded_content = await sr_avro_encoder.decode(encoded_content_dict)
Expand Down
5 changes: 3 additions & 2 deletions sdk/schemaregistry/azure-schemaregistry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pip install azure-schemaregistry
### Prerequisites:
To use this package, you must have:
* Azure subscription - [Create a free account][azure_sub]
* [Azure Schema Registry][schemaregistry_service]
* [Azure Schema Registry][schemaregistry_service] - [Here is the quickstart guide][quickstart_guide] to create a Schema Registry group using the Azure portal.
* Python 3.6 or later - [Install Python][python]

### Authenticate the client
Expand Down Expand Up @@ -235,4 +235,5 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
[schemaregistry_service]: https://aka.ms/schemaregistry
[schemaregistry_avroserializer_pypi]: https://pypi.org/project/azure-schemaregistry-avroserializer/
[token_credential_interface]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/core/azure-core/azure/core/credentials.py
[pypi_azure_identity]: https://pypi.org/project/azure-identity/
[pypi_azure_identity]: https://pypi.org/project/azure-identity/
[quickstart_guide]: https://docs.microsoft.com/azure/event-hubs/create-schema-registry
1 change: 1 addition & 0 deletions shared_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ chardet<5,>=3.0.2
#override azure-security-attestation azure-core<2.0.0,>=1.8.2
#override azure-data-tables msrest>=0.6.19
#override azure-schemaregistry azure-core<2.0.0,>=1.20.0
#override azure-schemaregistry-avroencoder typing-extensions>=4.0.1
opencensus>=0.6.0
opencensus-ext-threading
opencensus-ext-azure>=0.3.1
Expand Down

0 comments on commit d202434

Please sign in to comment.