diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 6970bee9583e..5ac5bdf2969d 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -71,6 +71,8 @@ "sdk/keyvault/azure-keyvault-certificates/tests/certs.py", "sdk/keyvault/azure-keyvault-keys/tests/keys.py", "sdk/modelsrepository/azure-iot-modelsrepository/**", + "sdk/remoterendering/test-resources.json", + "sdk/remoterendering/azure-mixedreality-remoterendering/swagger/azure/mixedreality/remoterendering/mr-arr.json", "sdk/servicefabric/azure-servicefabric/**", "sdk/search/azure-search-documents/**", "sdk/storage/azure-storage-blob-changefeed/**", diff --git a/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_api_version.py b/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_api_version.py index afdea2dd4969..14e9ad16b56c 100644 --- a/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_api_version.py +++ b/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_api_version.py @@ -15,17 +15,24 @@ class RemoteRenderingApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): V2021_01_01 = "2021-01-01" +DEFAULT_VERSION = RemoteRenderingApiVersion.V2021_01_01 + def validate_api_version(api_version): # type: (str) -> None - """Raise ValueError if api_version is invalid """ + """Raise ValueError if api_version is invalid + + :param api_version: The api version + :type api_version: str + + """ if not api_version: return try: api_version = RemoteRenderingApiVersion(api_version) - except ValueError: + except ValueError as exc: raise ValueError( "Unsupported API version '{}'. Please select from:\n{}".format( api_version, ", ".join(v.value for v in RemoteRenderingApiVersion) ) - ) + ) from exc diff --git a/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_remote_rendering_client.py b/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_remote_rendering_client.py index e1ef95afca49..2139011e4a04 100644 --- a/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_remote_rendering_client.py +++ b/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/_remote_rendering_client.py @@ -1,9 +1,12 @@ # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. +# Licensed under the MIT License. See License.txt in the project root for +# license information. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING + + +from typing import TYPE_CHECKING, Any, Callable, Union from azure.core.credentials import AccessToken, AzureKeyCredential from azure.core.paging import ItemPaged @@ -11,7 +14,7 @@ from azure.core.polling import LROPoller from azure.core.tracing.decorator import distributed_trace -from ._api_version import RemoteRenderingApiVersion, validate_api_version +from ._api_version import validate_api_version, DEFAULT_VERSION from ._generated import RemoteRenderingRestClient from ._generated.models import (AssetConversion, AssetConversionInputSettings, @@ -30,13 +33,12 @@ from ._version import SDK_MONIKER if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Union - from azure.core.credentials import TokenCredential +# pylint: disable=unsubscriptable-object -class RemoteRenderingClient(object): + +class RemoteRenderingClient: """A client for the Azure Remote Rendering Service. This client offers functionality to convert assets to the format expected by the runtime, and also to manage the @@ -52,17 +54,29 @@ class RemoteRenderingClient(object): :param credential: Authentication for the Azure Remote Rendering account. Can be of the form of an AzureKeyCredential, TokenCredential or an AccessToken acquired from the Mixed Reality Secure Token Service (STS). - :type credential: Union[TokenCredential, AzureKeyCredential, AccessToken] + :type credential: Union[AzureKeyCredential, TokenCredential, AccessToken] :keyword api_version: The API version of the service to use for requests. It defaults to the latest service version. Setting to an older version may result in reduced feature compatibility. - :paramtype api_version: str or ~azure.mixedreality.remoterenderings.RemoteRenderingApiVersion + :type api_version: str or ~azure.mixedreality.remoterenderings.RemoteRenderingApiVersion + :keyword polling_interval: + Seconds to wait between each check, whether the session is ready yet. + :type polling_interval: int + :keyword authentication_endpoint_url: + Overwrite for the authentication endpoint. Usually using account_domain for the authentication domain is enough. + If used, specify the whole authentication url including the schema. + :type authentication_endpoint_url: str """ - def __init__(self, endpoint, account_id, account_domain, credential, **kwargs): - # type: (str, str, str, Union[TokenCredential, AccessToken], Any) -> None + def __init__(self, + endpoint: str, + account_id: str, + account_domain: str, + credential: Union[AzureKeyCredential, 'TokenCredential', AccessToken], + **kwargs) -> None: + self._api_version = kwargs.pop( - "api_version", RemoteRenderingApiVersion.V2021_01_01 + "api_version", DEFAULT_VERSION ) validate_api_version(self._api_version) @@ -78,20 +92,23 @@ def __init__(self, endpoint, account_id, account_domain, credential, **kwargs): if not credential: raise ValueError("credential cannot be None") + self.polling_interval = kwargs.pop("polling_interval", 5) + endpoint_url = kwargs.pop('authentication_endpoint_url', construct_endpoint_url(account_domain)) + + cred: Any + if isinstance(credential, AccessToken): - cred = StaticAccessTokenCredential(credential) # type: TokenCredential + cred = StaticAccessTokenCredential(credential) elif isinstance(credential, AzureKeyCredential): - cred = MixedRealityAccountKeyCredential( - account_id=account_id, account_key=credential) + cred = MixedRealityAccountKeyCredential(account_id=account_id, account_key=credential) else: cred = credential - self.polling_interval = kwargs.pop("polling_interval", 5) - endpoint_url = kwargs.pop( - 'authentication_endpoint_url', construct_endpoint_url(account_domain)) - # otherwise assume it is a TokenCredential and simply pass it through pipeline_credential = get_mixedreality_credential( - account_id=account_id, account_domain=account_domain, credential=cred, endpoint_url=endpoint_url) + account_id=account_id, + account_domain=account_domain, + credential=cred, + endpoint_url=endpoint_url) if pipeline_credential is None: raise ValueError("credential is not of type TokenCredential, AzureKeyCredential or AccessToken") @@ -136,9 +153,11 @@ def begin_asset_conversion(self, conversion_id, input_settings, output_settings, **kwargs) polling_method = ConversionPolling(account_id=self._account_id, polling_interval=polling_interval) + deserialization_method: Callable[[Any], Any] = lambda _: None + return LROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace @@ -195,17 +214,20 @@ def get_asset_conversion_poller(self, **kwargs): conversion_id=conversion_id, **kwargs) + deserialization_method: Callable[[Any], Any] = lambda _: None + return LROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace def list_asset_conversions(self, **kwargs): # type: (...) -> ItemPaged[AssetConversion] - """ Gets conversions for the remote rendering account. + """ Returns list of conversions for the remote rendering account. :rtype: ItemPaged[AssetConversion] :raises ~azure.core.exceptions.HttpResponseError: + :return: List of conversion for the remote rendering account. """ return self._client.remote_rendering.list_conversions(account_id=self._account_id, **kwargs) # type: ignore @@ -234,9 +256,10 @@ def begin_rendering_session(self, session_id, size, lease_time_minutes, **kwargs **kwargs) polling_interval = kwargs.pop("polling_interval", self.polling_interval) polling_method = SessionPolling(account_id=self._account_id, polling_interval=polling_interval) + deserialization_method: Callable[[Any], Any] = lambda _: None return LROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace @@ -254,6 +277,7 @@ def get_rendering_session(self, session_id, **kwargs): session_id=session_id, **kwargs) + @distributed_trace def get_rendering_session_poller(self, **kwargs): # type: (Any) -> LROPoller[RenderingSession] """ @@ -292,9 +316,10 @@ def get_rendering_session_poller(self, **kwargs): **kwargs) polling_method = SessionPolling(account_id=self._account_id, polling_interval=polling_interval) + deserialization_method: Callable[[Any], Any] = lambda _: None return LROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace @@ -340,10 +365,11 @@ def update_rendering_session(self, session_id, **kwargs): def list_rendering_sessions(self, **kwargs): # type: (...) -> ItemPaged[RenderingSession] """ - List rendering sessions in the 'Ready' or 'Starting' state. Does not return stopped or failed rendering - sessions. + Returns list of rendering sessions in the 'Ready' or 'Starting' state. + Does not return stopped or failed rendering sessions. :rtype: ItemPaged[RenderingSession] :raises ~azure.core.exceptions.HttpResponseError: + :return: List of rendering sessions in the 'Ready' or 'Starting' state. """ return self._client.remote_rendering.list_sessions(account_id=self._account_id, **kwargs) # type: ignore diff --git a/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/aio/_remote_rendering_client_async.py b/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/aio/_remote_rendering_client_async.py index bf10e1ecd877..d77116ba3c3b 100644 --- a/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/aio/_remote_rendering_client_async.py +++ b/sdk/remoterendering/azure-mixedreality-remoterendering/azure/mixedreality/remoterendering/aio/_remote_rendering_client_async.py @@ -1,4 +1,5 @@ -# ------------------------------------------------------------------------- +# coding=utf-8 +# -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. @@ -13,7 +14,7 @@ from azure.core.polling import AsyncLROPoller from azure.core.tracing.decorator_async import distributed_trace_async -from .._api_version import RemoteRenderingApiVersion, validate_api_version +from .._api_version import validate_api_version, DEFAULT_VERSION from .._generated.aio import RemoteRenderingRestClient from .._generated.models import (AssetConversion, AssetConversionInputSettings, AssetConversionOutputSettings, @@ -57,27 +58,32 @@ class RemoteRenderingClient(object): :param credential: Authentication for the Azure Remote Rendering account. Can be of the form of an AzureKeyCredential, AsyncTokenCredential or an AccessToken acquired from the Mixed Reality Secure Token Service (STS). - :type credential: Union[AsyncTokenCredential, AzureKeyCredential, AccessToken] + :type credential: Union[AzureKeyCredential, AsyncTokenCredential, AccessToken] :keyword api_version: The API version of the service to use for requests. It defaults to the latest service version. Setting to an older version may result in reduced feature compatibility. - :paramtype api_version: str or ~azure.mixedreality.remoterenderings.RemoteRenderingApiVersion + :type api_version: str or ~azure.mixedreality.remoterenderings.RemoteRenderingApiVersion + :keyword polling_interval: + Seconds to wait between each check, whether the session is ready yet. + :type polling_interval: int + :keyword authentication_endpoint_url: + Overwrite for the authentication endpoint. Usually using account_domain for the authentication domain is enough. + If used, specify the whole authentication url including the schema. + :type authentication_endpoint_url: str """ def __init__(self, endpoint: str, account_id: str, account_domain: str, - credential: Union["AsyncTokenCredential", AzureKeyCredential, AccessToken], + credential: Union[AzureKeyCredential, 'AsyncTokenCredential', AccessToken], **kwargs) -> None: self._api_version = kwargs.pop( - "api_version", RemoteRenderingApiVersion.V2021_01_01 + "api_version", DEFAULT_VERSION ) validate_api_version(self._api_version) - self._account_id = account_id - if not endpoint: raise ValueError("endpoint cannot be None") @@ -90,21 +96,26 @@ def __init__(self, if not credential: raise ValueError("credential cannot be None") - endpoint_url = kwargs.pop( - 'authentication_endpoint_url', construct_endpoint_url(account_domain)) # type: str + self.polling_interval = kwargs.pop("polling_interval", 5) + endpoint_url = kwargs.pop('authentication_endpoint_url', construct_endpoint_url(account_domain)) + + cred: Any if isinstance(credential, AccessToken): - cred = StaticAccessTokenCredential(credential) # type: AsyncTokenCredential + cred = StaticAccessTokenCredential(credential) elif isinstance(credential, AzureKeyCredential): - cred = MixedRealityAccountKeyCredential( - account_id=account_id, account_key=credential) + cred = MixedRealityAccountKeyCredential(account_id=account_id, account_key=credential) else: cred = credential - # otherwise assume it is a TokenCredential and simply pass it through + pipeline_credential = get_mixedreality_credential( - account_id=account_id, account_domain=account_domain, credential=cred, endpoint_url=endpoint_url) + account_id=account_id, + account_domain=account_domain, + credential=cred, + endpoint_url=endpoint_url) - self.polling_interval = kwargs.pop("polling_interval", 5) + if pipeline_credential is None: + raise ValueError("credential is not of type TokenCredential, AzureKeyCredential or AccessToken") authentication_policy = AsyncBearerTokenCredentialPolicy( pipeline_credential, endpoint_url + '/.default') @@ -131,7 +142,7 @@ async def begin_asset_conversion(self, contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 256 characters. :param ~azure.mixedreality.remoterendering.AssetConversionInputSettings input_settings: Options for the - input of the conversion + input of the conversion. :param ~azure.mixedreality.remoterendering.AssetConversionOutputSettings output_settings: Options for the output of the conversion. :return: A poller for the created asset conversion @@ -145,9 +156,11 @@ async def begin_asset_conversion(self, body=CreateAssetConversionSettings( settings=settings), **kwargs) + deserialization_method: Callable[[Any], Any] = lambda _: None + return AsyncLROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace_async @@ -163,6 +176,7 @@ async def get_asset_conversion(self, conversion_id: str, **kwargs) -> AssetConve conversion_id=conversion_id, **kwargs) + @distributed_trace_async async def get_asset_conversion_poller(self, **kwargs): # type: (Any) -> AsyncLROPoller[AssetConversion] """ @@ -201,17 +215,20 @@ async def get_asset_conversion_poller(self, **kwargs): conversion_id=conversion_id, **kwargs) + deserialization_method: Callable[[Any], Any] = lambda _: None + return AsyncLROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace_async async def list_asset_conversions(self, **kwargs): # type: (...) -> AsyncItemPaged[AssetConversion] """ - Gets conversions for the remote rendering account. + Returns list of conversions for the remote rendering account. :rtype: AsyncItemPaged[AssetConversion] + :return: List of conversions for the remote rendering account. """ return self._client.remote_rendering.list_conversions(account_id=self._account_id, **kwargs) # type: ignore @@ -243,9 +260,12 @@ async def begin_rendering_session(self, session_id=session_id, body=settings, **kwargs) + + deserialization_method: Callable[[Any], Any] = lambda _: None + return AsyncLROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace_async @@ -258,6 +278,7 @@ async def get_rendering_session(self, session_id: str, **kwargs) -> RenderingSes ''' return await self._client.remote_rendering.get_session(self._account_id, session_id=session_id, **kwargs) + @distributed_trace_async async def get_rendering_session_poller(self, **kwargs): # type: (Any) -> AsyncLROPoller[RenderingSession] """ @@ -295,9 +316,11 @@ async def get_rendering_session_poller(self, **kwargs): session_id=session_id, **kwargs) + deserialization_method: Callable[[Any], Any] = lambda _: None + return AsyncLROPoller(client=self._client, initial_response=initial_state, - deserialization_callback=lambda: None, + deserialization_callback=deserialization_method, polling_method=polling_method) @distributed_trace_async @@ -341,9 +364,10 @@ async def list_rendering_sessions( **kwargs): # type: (...) -> AsyncItemPaged[RenderingSession] """ - List rendering sessions in the 'Ready' or 'Starting' state. Does not return stopped or failed rendering - sessions. + Returns list of rendering sessions in the 'Ready' or 'Starting' state. + Does not return stopped or failed rendering sessions. :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mixedreality.remoterendering.RenderingSession] + :return: List of rendering sessions in the 'Ready' or 'Starting' state. """ return self._client.remote_rendering.list_sessions(account_id=self._account_id, **kwargs) # type: ignore diff --git a/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample.py b/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample.py index f17be5426a15..20cc52d96d0b 100644 --- a/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample.py +++ b/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample.py @@ -25,10 +25,11 @@ import logging import os import sys -import time +from typing import Optional, Union, cast import uuid +from datetime import datetime -from azure.core.credentials import AzureKeyCredential +from azure.core.credentials import AzureKeyCredential, AccessToken, TokenCredential from azure.core.pipeline.policies import NetworkTraceLoggingPolicy from azure.mixedreality.authentication import MixedRealityStsClient from azure.mixedreality.remoterendering import (AssetConversion, @@ -37,7 +38,8 @@ AssetConversionStatus, RemoteRenderingClient, RenderingSessionSize, - RenderingSessionStatus) + RenderingSessionStatus, + AssetConversionOutput) # Create a logger for the 'azure' SDK logger = logging.getLogger("azure") @@ -72,21 +74,23 @@ if not account_key: raise ValueError("Set ARR_ACCOUNT_KEY env before run this sample.") -storage_container_uri = os.environ.get("ARR_STORAGE_CONTAINER_URI", None) -if not storage_container_uri: +storage_container_uri_optional: Optional[str] = os.environ.get("ARR_STORAGE_CONTAINER_URI", None) +if not storage_container_uri_optional: raise ValueError("Set ARR_STORAGE_CONTAINER_URI env before run this sample.") +storage_container_uri: str = storage_container_uri_optional input_blob_prefix = os.environ.get("ARR_STORAGE_INPUT_BLOB_PREFIX", None) # if no input_blob_prefix is specified the whole content of the storage container will be retrieved for conversions # this is not recommended since copying lots of unneeded files will slow down conversions -relative_input_asset_path = os.environ.get("ARR_STORAGE_INPUT_ASSET_PATH", None) -if not relative_input_asset_path: +relative_input_asset_path_optional: Optional[str] = os.environ.get("ARR_STORAGE_INPUT_ASSET_PATH", None) +if not relative_input_asset_path_optional: raise ValueError("Set ARR_STORAGE_INPUT_ASSET_PATH env before run this sample.") +relative_input_asset_path: str = relative_input_asset_path_optional # use AzureKeyCredentials to authenticate to the service - other auth options include AAD and getting # STS token using the mixed reality STS client -key_credential = AzureKeyCredential(account_key) +key_credential: Union[AzureKeyCredential, TokenCredential, AccessToken] = AzureKeyCredential(account_key) client = RemoteRenderingClient( endpoint=arr_endpoint, @@ -128,7 +132,10 @@ def perform_asset_conversion(): print("conversion with id:", conversion_id, "created. Waiting for completion.") conversion = conversion_poller.result() print("conversion with id:", conversion_id, "finished with result:", conversion.status) - print(conversion.output.asset_uri) + if conversion.output is not None: + print(conversion.output.asset_uri) + else: + print("conversion had no output asset_uri") # a poller can also be acquired by id # id_poller = await client.get_asset_conversion_poller(conversion_id=conversion_id) @@ -151,7 +158,10 @@ def list_all_asset_conversions(): created_on = c.created_on.strftime("%m/%d/%Y, %H:%M:%S") print("\t conversion: id:", c.id, "status:", c.status, "created on:", created_on) if c.status == AssetConversionStatus.SUCCEEDED: - print("\t\tconversion result URI:", c.output.asset_uri) + if c.output is not None: + print("\t\tconversion result URI:", c.output.asset_uri) + else: + print("conversion result returned with empty URI") def demonstrate_rendering_session_lifecycle(): @@ -179,9 +189,9 @@ def demonstrate_rendering_session_lifecycle(): # if the session should run longer than initially requested we can extend the lifetime of the session session = client.get_rendering_session(session_id) - if session.lease_time_minutes - session.elapsed_time_minutes < 2: + if cast(int, session.lease_time_minutes) - cast(int, session.elapsed_time_minutes) < 2: session = client.update_rendering_session( - session_id=session_id, lease_time_minutes=session.lease_time_minutes + 10) + session_id=session_id, lease_time_minutes=cast(int, session.lease_time_minutes) + 10) print("session with id:", session.id, "updated. New lease time:", session.lease_time_minutes, "minutes",) # once we do not need the session anymore we can stop the session @@ -196,7 +206,7 @@ def list_all_rendering_sessions(): print("sessions:") rendering_sessions = client.list_rendering_sessions() for session in rendering_sessions: - created_on = session.created_on.strftime("%m/%d/%Y, %H:%M:%S") + created_on = cast(datetime, session.created_on).strftime("%m/%d/%Y, %H:%M:%S") print("\t session: id:", session.id, "status:", session.status, "created on:", created_on,) diff --git a/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample_async.py b/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample_async.py index 7f7f2c8fa0a1..a30ec141f1c6 100644 --- a/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample_async.py +++ b/sdk/remoterendering/azure-mixedreality-remoterendering/samples/remote_rendering_client_sample_async.py @@ -26,14 +26,17 @@ import logging import os import sys -import time +from typing import Optional, cast import uuid +from datetime import datetime from azure.core.async_paging import AsyncItemPaged from azure.core.credentials import AzureKeyCredential +from azure.core.pipeline import policies from azure.mixedreality.remoterendering import (AssetConversionInputSettings, AssetConversionOutputSettings, AssetConversionStatus, + AssetConversionOutput, RenderingSession, RenderingSessionSize, RenderingSessionStatus) @@ -53,7 +56,7 @@ logging_policy = None if logging_policy_enabled: - logging_policy = NetworkTraceLoggingPolicy() + logging_policy = policies.NetworkTraceLoggingPolicy() logging_policy.enable_http_logger = True arr_endpoint = os.environ.get("ARR_SERVICE_ENDPOINT", None) @@ -72,17 +75,19 @@ if not account_key: raise ValueError("Set ARR_ACCOUNT_KEY env before run this sample.") -storage_container_uri = os.environ.get("ARR_STORAGE_CONTAINER_URI", None) -if not storage_container_uri: +storage_container_uri_optional: Optional[str] = os.environ.get("ARR_STORAGE_CONTAINER_URI", None) +if not storage_container_uri_optional: raise ValueError("Set ARR_STORAGE_CONTAINER_URI env before run this sample.") +storage_container_uri: str = storage_container_uri_optional input_blob_prefix = os.environ.get("ARR_STORAGE_INPUT_BLOB_PREFIX", None) # if no input_blob_prefix is specified the whole content of the storage container will be retrieved for conversions # this is not recommended since copying lots of unneeded files will slow down conversions -relative_input_asset_path = os.environ.get("ARR_STORAGE_INPUT_ASSET_PATH", None) -if not relative_input_asset_path: +relative_input_asset_path_optional: Optional[str] = os.environ.get("ARR_STORAGE_INPUT_ASSET_PATH", None) +if not relative_input_asset_path_optional: raise ValueError("Set ARR_STORAGE_INPUT_ASSET_PATH env before run this sample.") +relative_input_asset_path: str = relative_input_asset_path_optional # use AzureKeyCredentials to authenticate to the service - other auth options include AAD and getting # STS token using the mixed reality STS client @@ -128,7 +133,10 @@ async def perform_asset_conversion(): print("conversion with id:", conversion_id, "created. Waiting for completion.") conversion = await conversion_poller.result() print("conversion with id:", conversion_id, "finished with result:", conversion.status) - print(conversion.output.asset_uri) + if conversion.output is not None: + print(conversion.output.asset_uri) + else: + print("conversion had no output asset_uri") # a poller can also be acquired by id # id_poller = await client.get_asset_conversion_poller(conversion_id=conversion_id) @@ -151,7 +159,10 @@ async def list_all_asset_conversions(): created_on = c.created_on.strftime("%m/%d/%Y, %H:%M:%S") print("\t conversion: id:", c.id, "status:", c.status, "created on:", created_on) if c.status == AssetConversionStatus.SUCCEEDED: - print("\t\tconversion result URI:", c.output.asset_uri) + if c.output is not None: + print("\t\tconversion result URI:", c.output.asset_uri) + else: + print("conversion result returned with empty URI") async def demonstrate_rendering_session_lifecycle(): @@ -178,10 +189,10 @@ async def demonstrate_rendering_session_lifecycle(): print(session) # if the session should run longer than initially requested we can extend the lifetime of the session - session = client.get_rendering_session(session_id) - if session.lease_time_minutes - session.elapsed_time_minutes < 2: + session = await client.get_rendering_session(session_id) + if cast(int, session.lease_time_minutes) - cast(int, session.elapsed_time_minutes) < 2: session = await client.update_rendering_session( - session_id=session_id, lease_time_minutes=session.lease_time_minutes + 10) + session_id=session_id, lease_time_minutes=cast(int, session.lease_time_minutes) + 10) print("session with id:", session.id, "updated. New lease time:", session.lease_time_minutes, "minutes") # once we do not need the session anymore we can stop the session @@ -197,7 +208,7 @@ async def list_all_rendering_sessions(): rendering_sessions = await client.list_rendering_sessions() async for session in rendering_sessions: print("\t session: id:", session.id, "status:", session.status, - "created on:", session.created_on.strftime("%m/%d/%Y, %H:%M:%S")) + "created on:", cast(datetime, session.created_on).strftime("%m/%d/%Y, %H:%M:%S")) async def main(): diff --git a/sdk/remoterendering/azure-mixedreality-remoterendering/swagger/AUTOREST.md b/sdk/remoterendering/azure-mixedreality-remoterendering/swagger/AUTOREST.md index 75a096c51a67..180f93b315da 100644 --- a/sdk/remoterendering/azure-mixedreality-remoterendering/swagger/AUTOREST.md +++ b/sdk/remoterendering/azure-mixedreality-remoterendering/swagger/AUTOREST.md @@ -17,7 +17,7 @@ autorest AUTOREST.md ```yaml title: RemoteRenderingRestClient -input-file: https://raw.githubusercontent.com/rikogeln/azure-rest-api-specs/c90870a194ab90b29760ab06ea7d18c4573a7d93/specification/mixedreality/data-plane/Microsoft.MixedReality/stable/2021-01-01/mr-arr.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/2a65b0a2bbd9113b91c889f187d8778c2725c0b9/specification/mixedreality/data-plane/Microsoft.MixedReality/stable/2021-01-01/mr-arr.json output-folder: ../azure/mixedreality/remoterendering/_generated namespace: azure.mixedreality.remoterendering._generated no-namespace-folders: true @@ -161,7 +161,6 @@ directive: $["x-ms-client-name"] = "leaseTimeMinutes"; ``` - ### Directive renaming conversion settings inputLocation property to inputSettings ``` yaml diff --git a/sdk/remoterendering/cspell.json b/sdk/remoterendering/cspell.json deleted file mode 100644 index 41cd0f7ddf15..000000000000 --- a/sdk/remoterendering/cspell.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": "0.2", - "language": "en", - "ignorePaths": [ - "./test-resources.json" - ] -} \ No newline at end of file