-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable multi container based on environment variable (#2313)
# Description This pull request primarily introduces the ability to enable multi-container functionality and expands the capabilities of the Azure Machine Learning Designer Service Client. The most significant changes include the addition of a new constant, the creation of a function to check if multi-container functionality is enabled, and the extension of the Azure Machine Learning Designer Service Client's operations. **Addition of Multi-Container Functionality:** * [`src/promptflow/promptflow/_constants.py`](diffhunk://#diff-0d3cf5f31883ff073bf1e11cb2e17db5cc8fe6e5e38cbb4af7b99f37ac31d41aR14): Added a new constant `ENABLE_MULTI_CONTAINER_KEY` to enable multi-container functionality. * [`src/promptflow/promptflow/_sdk/_utils.py`](diffhunk://#diff-47208ac35b30920275fcd5e55d662647ef360129359bdc77fddd2a2157b6f47eL35-R41): Imported the new constant and added a new function `is_multi_container_enabled()` to check if multi-container functionality is enabled. [[1]](diffhunk://#diff-47208ac35b30920275fcd5e55d662647ef360129359bdc77fddd2a2157b6f47eL35-R41) [[2]](diffhunk://#diff-47208ac35b30920275fcd5e55d662647ef360129359bdc77fddd2a2157b6f47eR983-R988) * [`src/promptflow/promptflow/_sdk/entities/_run.py`](diffhunk://#diff-14f4d7a1d9b077c7b749230a92628782f990e1fc7cb741b20ff894f868327020R43): Imported the new function and used it in the `_to_rest_object()` method. [[1]](diffhunk://#diff-14f4d7a1d9b077c7b749230a92628782f990e1fc7cb741b20ff894f868327020R43) [[2]](diffhunk://#diff-14f4d7a1d9b077c7b749230a92628782f990e1fc7cb741b20ff894f868327020R593) **Expansion of Azure Machine Learning Designer Service Client Operations:** * `src/promptflow/promptflow/azure/_restclient/flow/_azure_machine_learning_designer_service_client.py`, `src/promptflow/promptflow/azure/_restclient/flow/aio/_azure_machine_learning_designer_service_client.py`: Added `ExperimentsOperations` and `ExperimentTemplatesOperations` to the Azure Machine Learning Designer Service Client's operations. [[1]](diffhunk://#diff-0d897b1801e67d281d2e78b96e4735815629d7341c4ba5bb328326bd917719d9L15-R15) [[2]](diffhunk://#diff-0d897b1801e67d281d2e78b96e4735815629d7341c4ba5bb328326bd917719d9R32-R35) [[3]](diffhunk://#diff-0d897b1801e67d281d2e78b96e4735815629d7341c4ba5bb328326bd917719d9R75-R76) [[4]](diffhunk://#diff-b86b4b5a24655b993946a74b33780deb5eeab5452feb269e74456ba3871de495L16-R16) [[5]](diffhunk://#diff-b86b4b5a24655b993946a74b33780deb5eeab5452feb269e74456ba3871de495R27-R30) [[6]](diffhunk://#diff-b86b4b5a24655b993946a74b33780deb5eeab5452feb269e74456ba3871de495R69-R70) * [`src/promptflow/promptflow/azure/_restclient/flow/aio/operations/__init__.py`](diffhunk://#diff-f5d068b386d3698c8836998d281dbf65844be98620f017683ab25632bd7f4e29R10-R11): Imported the new operations. [[1]](diffhunk://#diff-f5d068b386d3698c8836998d281dbf65844be98620f017683ab25632bd7f4e29R10-R11) [[2]](diffhunk://#diff-f5d068b386d3698c8836998d281dbf65844be98620f017683ab25632bd7f4e29R24-R25) * [`src/promptflow/promptflow/azure/_restclient/flow/aio/operations/_experiment_templates_operations.py`](diffhunk://#diff-ac47ed666715906825cc330909c705299ad504c397818b964e5313c12e84fb8fR1-R171): Added a new file to implement the `ExperimentTemplatesOperations`. # All Promptflow Contribution checklist: - [x] **The pull request does not introduce [breaking changes].** - [x] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [x] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [x] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [x] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [ ] Pull request includes test coverage for the included changes.
- Loading branch information
Showing
20 changed files
with
33,271 additions
and
30,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
...flow/promptflow/azure/_restclient/flow/aio/operations/_experiment_templates_operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.8.0, generator: @autorest/[email protected]) | ||
# Changes may cause incorrect behavior and will be lost if the code is regenerated. | ||
# -------------------------------------------------------------------------- | ||
import functools | ||
from typing import Any, Callable, Dict, Generic, Optional, TypeVar | ||
import warnings | ||
|
||
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error | ||
from azure.core.pipeline import PipelineResponse | ||
from azure.core.pipeline.transport import AsyncHttpResponse | ||
from azure.core.rest import HttpRequest | ||
from azure.core.tracing.decorator_async import distributed_trace_async | ||
|
||
from ... import models as _models | ||
from ..._vendor import _convert_request | ||
from ...operations._experiment_templates_operations import build_create_experiment_template_request, build_get_experiment_template_request | ||
T = TypeVar('T') | ||
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] | ||
|
||
class ExperimentTemplatesOperations: | ||
"""ExperimentTemplatesOperations async operations. | ||
You should not instantiate this class directly. Instead, you should create a Client instance that | ||
instantiates it for you and attaches it as an attribute. | ||
:ivar models: Alias to model classes used in this operation group. | ||
:type models: ~flow.models | ||
:param client: Client for service requests. | ||
:param config: Configuration of service client. | ||
:param serializer: An object model serializer. | ||
:param deserializer: An object model deserializer. | ||
""" | ||
|
||
models = _models | ||
|
||
def __init__(self, client, config, serializer, deserializer) -> None: | ||
self._client = client | ||
self._serialize = serializer | ||
self._deserialize = deserializer | ||
self._config = config | ||
|
||
@distributed_trace_async | ||
async def create_experiment_template( | ||
self, | ||
subscription_id: str, | ||
resource_group_name: str, | ||
workspace_name: str, | ||
experiment_template_id: str, | ||
body: Optional["_models.CreateExperimentTemplateRequest"] = None, | ||
**kwargs: Any | ||
) -> "_models.ExperimentTemplateDto": | ||
"""create_experiment_template. | ||
:param subscription_id: The Azure Subscription ID. | ||
:type subscription_id: str | ||
:param resource_group_name: The Name of the resource group in which the workspace is located. | ||
:type resource_group_name: str | ||
:param workspace_name: The name of the workspace. | ||
:type workspace_name: str | ||
:param experiment_template_id: | ||
:type experiment_template_id: str | ||
:param body: | ||
:type body: ~flow.models.CreateExperimentTemplateRequest | ||
:keyword callable cls: A custom type or function that will be passed the direct response | ||
:return: ExperimentTemplateDto, or the result of cls(response) | ||
:rtype: ~flow.models.ExperimentTemplateDto | ||
:raises: ~azure.core.exceptions.HttpResponseError | ||
""" | ||
cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentTemplateDto"] | ||
error_map = { | ||
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError | ||
} | ||
error_map.update(kwargs.pop('error_map', {})) | ||
|
||
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] | ||
|
||
if body is not None: | ||
_json = self._serialize.body(body, 'CreateExperimentTemplateRequest') | ||
else: | ||
_json = None | ||
|
||
request = build_create_experiment_template_request( | ||
subscription_id=subscription_id, | ||
resource_group_name=resource_group_name, | ||
workspace_name=workspace_name, | ||
experiment_template_id=experiment_template_id, | ||
content_type=content_type, | ||
json=_json, | ||
template_url=self.create_experiment_template.metadata['url'], | ||
) | ||
request = _convert_request(request) | ||
request.url = self._client.format_url(request.url) | ||
|
||
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) | ||
response = pipeline_response.http_response | ||
|
||
if response.status_code not in [200]: | ||
map_error(status_code=response.status_code, response=response, error_map=error_map) | ||
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) | ||
raise HttpResponseError(response=response, model=error) | ||
|
||
deserialized = self._deserialize('ExperimentTemplateDto', pipeline_response) | ||
|
||
if cls: | ||
return cls(pipeline_response, deserialized, {}) | ||
|
||
return deserialized | ||
|
||
create_experiment_template.metadata = {'url': '/flow/api/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/ExperimentTemplates/{experimentTemplateId}'} # type: ignore | ||
|
||
|
||
@distributed_trace_async | ||
async def get_experiment_template( | ||
self, | ||
subscription_id: str, | ||
resource_group_name: str, | ||
workspace_name: str, | ||
experiment_template_id: str, | ||
**kwargs: Any | ||
) -> "_models.ExperimentTemplateDto": | ||
"""get_experiment_template. | ||
:param subscription_id: The Azure Subscription ID. | ||
:type subscription_id: str | ||
:param resource_group_name: The Name of the resource group in which the workspace is located. | ||
:type resource_group_name: str | ||
:param workspace_name: The name of the workspace. | ||
:type workspace_name: str | ||
:param experiment_template_id: | ||
:type experiment_template_id: str | ||
:keyword callable cls: A custom type or function that will be passed the direct response | ||
:return: ExperimentTemplateDto, or the result of cls(response) | ||
:rtype: ~flow.models.ExperimentTemplateDto | ||
:raises: ~azure.core.exceptions.HttpResponseError | ||
""" | ||
cls = kwargs.pop('cls', None) # type: ClsType["_models.ExperimentTemplateDto"] | ||
error_map = { | ||
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError | ||
} | ||
error_map.update(kwargs.pop('error_map', {})) | ||
|
||
|
||
request = build_get_experiment_template_request( | ||
subscription_id=subscription_id, | ||
resource_group_name=resource_group_name, | ||
workspace_name=workspace_name, | ||
experiment_template_id=experiment_template_id, | ||
template_url=self.get_experiment_template.metadata['url'], | ||
) | ||
request = _convert_request(request) | ||
request.url = self._client.format_url(request.url) | ||
|
||
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) | ||
response = pipeline_response.http_response | ||
|
||
if response.status_code not in [200]: | ||
map_error(status_code=response.status_code, response=response, error_map=error_map) | ||
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) | ||
raise HttpResponseError(response=response, model=error) | ||
|
||
deserialized = self._deserialize('ExperimentTemplateDto', pipeline_response) | ||
|
||
if cls: | ||
return cls(pipeline_response, deserialized, {}) | ||
|
||
return deserialized | ||
|
||
get_experiment_template.metadata = {'url': '/flow/api/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/ExperimentTemplates/{experimentTemplateId}'} # type: ignore | ||
|
Oops, something went wrong.