Skip to content

Commit

Permalink
[SDK/CLI] Update SDK restclient 2023-11-23 (#1101)
Browse files Browse the repository at this point in the history
# Description

Please add an informative description that covers that changes made by
the pull request and link all relevant issues.

# All Promptflow Contribution checklist:
- [ ] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **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
- [ ] 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
0mza987 authored Nov 13, 2023
1 parent 283a9bf commit 1c4b194
Show file tree
Hide file tree
Showing 26 changed files with 33,252 additions and 113 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
".gitignore",
"scripts/docs/_build/**",
"src/promptflow/promptflow/azure/_restclient/flow/**",
"src/promptflow/promptflow/azure/_restclient/swagger.json",
"src/promptflow/tests/**",
"src/promptflow-tools/tests/**",
"**/flow.dag.yaml",
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ scripts/docs/_build/
.index
.pdfs
config.json
src/promptflow/promptflow/azure/_restclient/swagger.json

# chat-with-pdf's prebuilt index
!.pdfs/
Expand Down
56 changes: 55 additions & 1 deletion src/promptflow/promptflow/azure/_restclient/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,61 @@ Rest client code in this folder are not manually written, but generated by autor
Download swagger.json from [here](https://int.api.azureml-test.ms/flow/swagger/v1.0/swagger.json) to
[promptflow/azure/_restclient](../promptflow/azure/_restclient)

## update code
## Update code
+ cd to [promptflow/azure/_restclient](../promptflow/azure/_restclient)
+ run `autorest --v3 --python --track2 --version=3.8.0 --use=@autorest/[email protected] --input-file=swagger.json --output-folder=. --namespace=flow --modelerfour.lenient-model-deduplication`
+ don't change `--use`. latest version of `autorest/python` will generate code following different pattern, which is not compatible with our code.

## Update the generation history

- 2023.11.13 - Generated.

## Troubleshooting

### Duplicate object schemas with "xxx" name detected.

This may be caused by the duplicate generated class names.

```json
"FlowFeature": {
"type": "object",
"properties": {
"name": {
"type": "string",
"nullable": true
},
"description": {
"type": "string",
"nullable": true
},
"state": {
"type": "object",
"properties": {
"Runtime": {
"$ref": "#/components/schemas/FlowFeatureState"
},
"Executor": {
"$ref": "#/components/schemas/FlowFeatureState"
},
"PFS": {
"$ref": "#/components/schemas/FlowFeatureState"
}
},
"additionalProperties": false,
"nullable": true
}
},
"additionalProperties": false
},
"FlowFeatureState": {
"enum": [
"Ready",
"E2ETest"
],
"type": "string"
},
```

`FlowFeature` has a nested object field `state`, which will be generated to a new class named `FlowFeatureState`, and it duplicates with the enum `FlowFeatureState`.

To fix this, server side needs to change the class name in the schema, in this case, server side changed the object `state` to `states` and the problem is resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from . import models
from ._configuration import AzureMachineLearningDesignerServiceClientConfiguration
from .operations import BulkRunsOperations, ConnectionOperations, ConnectionsOperations, FlowRunsAdminOperations, FlowRuntimesOperations, FlowSessionsOperations, FlowsOperations, FlowsProviderOperations, ToolsOperations
from .operations import BulkRunsOperations, ConnectionOperations, ConnectionsOperations, FlowRunsAdminOperations, FlowRuntimesOperations, FlowRuntimesWorkspaceIndependentOperations, FlowSessionsOperations, FlowsOperations, FlowsProviderOperations, ToolsOperations

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
Expand All @@ -33,6 +33,10 @@ class AzureMachineLearningDesignerServiceClient(object):
:vartype flow_runs_admin: flow.operations.FlowRunsAdminOperations
:ivar flow_runtimes: FlowRuntimesOperations operations
:vartype flow_runtimes: flow.operations.FlowRuntimesOperations
:ivar flow_runtimes_workspace_independent: FlowRuntimesWorkspaceIndependentOperations
operations
:vartype flow_runtimes_workspace_independent:
flow.operations.FlowRuntimesWorkspaceIndependentOperations
:ivar flows: FlowsOperations operations
:vartype flows: flow.operations.FlowsOperations
:ivar flow_sessions: FlowSessionsOperations operations
Expand Down Expand Up @@ -66,6 +70,7 @@ def __init__(
self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_runs_admin = FlowRunsAdminOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_runtimes = FlowRuntimesOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_runtimes_workspace_independent = FlowRuntimesWorkspaceIndependentOperations(self._client, self._config, self._serialize, self._deserialize)
self.flows = FlowsOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_sessions = FlowSessionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.flows_provider = FlowsProviderOperations(self._client, self._config, self._serialize, self._deserialize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from .. import models
from ._configuration import AzureMachineLearningDesignerServiceClientConfiguration
from .operations import BulkRunsOperations, ConnectionOperations, ConnectionsOperations, FlowRunsAdminOperations, FlowRuntimesOperations, FlowSessionsOperations, FlowsOperations, FlowsProviderOperations, ToolsOperations
from .operations import BulkRunsOperations, ConnectionOperations, ConnectionsOperations, FlowRunsAdminOperations, FlowRuntimesOperations, FlowRuntimesWorkspaceIndependentOperations, FlowSessionsOperations, FlowsOperations, FlowsProviderOperations, ToolsOperations

class AzureMachineLearningDesignerServiceClient:
"""AzureMachineLearningDesignerServiceClient.
Expand All @@ -28,6 +28,10 @@ class AzureMachineLearningDesignerServiceClient:
:vartype flow_runs_admin: flow.aio.operations.FlowRunsAdminOperations
:ivar flow_runtimes: FlowRuntimesOperations operations
:vartype flow_runtimes: flow.aio.operations.FlowRuntimesOperations
:ivar flow_runtimes_workspace_independent: FlowRuntimesWorkspaceIndependentOperations
operations
:vartype flow_runtimes_workspace_independent:
flow.aio.operations.FlowRuntimesWorkspaceIndependentOperations
:ivar flows: FlowsOperations operations
:vartype flows: flow.aio.operations.FlowsOperations
:ivar flow_sessions: FlowSessionsOperations operations
Expand Down Expand Up @@ -60,6 +64,7 @@ def __init__(
self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_runs_admin = FlowRunsAdminOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_runtimes = FlowRuntimesOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_runtimes_workspace_independent = FlowRuntimesWorkspaceIndependentOperations(self._client, self._config, self._serialize, self._deserialize)
self.flows = FlowsOperations(self._client, self._config, self._serialize, self._deserialize)
self.flow_sessions = FlowSessionsOperations(self._client, self._config, self._serialize, self._deserialize)
self.flows_provider = FlowsProviderOperations(self._client, self._config, self._serialize, self._deserialize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from ._connections_operations import ConnectionsOperations
from ._flow_runs_admin_operations import FlowRunsAdminOperations
from ._flow_runtimes_operations import FlowRuntimesOperations
from ._flow_runtimes_workspace_independent_operations import FlowRuntimesWorkspaceIndependentOperations
from ._flows_operations import FlowsOperations
from ._flow_sessions_operations import FlowSessionsOperations
from ._flows_provider_operations import FlowsProviderOperations
Expand All @@ -20,6 +21,7 @@
'ConnectionsOperations',
'FlowRunsAdminOperations',
'FlowRuntimesOperations',
'FlowRuntimesWorkspaceIndependentOperations',
'FlowsOperations',
'FlowSessionsOperations',
'FlowsProviderOperations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from ... import models as _models
from ..._vendor import _convert_request
from ...operations._bulk_runs_operations import build_cancel_flow_run_request, build_clone_flow_from_flow_run_request, build_get_flow_child_runs_request, build_get_flow_node_runs_request, build_get_flow_run_info_request, build_get_flow_run_log_content_request, build_submit_bulk_run_request
from ...operations._bulk_runs_operations import build_cancel_flow_run_request, build_clone_flow_from_flow_run_request, build_get_flow_child_runs_request, build_get_flow_node_run_base_path_request, build_get_flow_node_runs_request, build_get_flow_run_info_request, build_get_flow_run_log_content_request, build_submit_bulk_run_request
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]

Expand Down Expand Up @@ -452,6 +452,69 @@ async def get_flow_node_runs(
get_flow_node_runs.metadata = {'url': '/flow/api/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/BulkRuns/{flowRunId}/nodeRuns/{nodeName}'} # type: ignore


@distributed_trace_async
async def get_flow_node_run_base_path(
self,
subscription_id: str,
resource_group_name: str,
workspace_name: str,
flow_run_id: str,
node_name: str,
**kwargs: Any
) -> "_models.FlowRunBasePath":
"""get_flow_node_run_base_path.
: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 flow_run_id:
:type flow_run_id: str
:param node_name:
:type node_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: FlowRunBasePath, or the result of cls(response)
:rtype: ~flow.models.FlowRunBasePath
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.FlowRunBasePath"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))


request = build_get_flow_node_run_base_path_request(
subscription_id=subscription_id,
resource_group_name=resource_group_name,
workspace_name=workspace_name,
flow_run_id=flow_run_id,
node_name=node_name,
template_url=self.get_flow_node_run_base_path.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('FlowRunBasePath', pipeline_response)

if cls:
return cls(pipeline_response, deserialized, {})

return deserialized

get_flow_node_run_base_path.metadata = {'url': '/flow/api/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/BulkRuns/{flowRunId}/nodeRuns/{nodeName}/basePath'} # type: ignore


@distributed_trace_async
async def get_flow_run_log_content(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from ... import models as _models
from ..._vendor import _convert_request
from ...operations._connections_operations import build_create_connection_request, build_delete_connection_request, build_get_connection_request, build_list_azure_open_ai_deployments_request, build_list_connection_specs_request, build_list_connections_request, build_update_connection_request
from ...operations._connections_operations import build_create_connection_request, build_delete_connection_request, build_get_connection_request, build_get_connection_with_secrets_request, build_list_azure_open_ai_deployments_request, build_list_connection_specs_request, build_list_connections_request, build_update_connection_request
T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]

Expand Down Expand Up @@ -299,6 +299,65 @@ async def delete_connection(
delete_connection.metadata = {'url': '/flow/api/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/Connections/{connectionName}'} # type: ignore


@distributed_trace_async
async def get_connection_with_secrets(
self,
subscription_id: str,
resource_group_name: str,
workspace_name: str,
connection_name: str,
**kwargs: Any
) -> "_models.ConnectionDto":
"""get_connection_with_secrets.
: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 connection_name:
:type connection_name: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: ConnectionDto, or the result of cls(response)
:rtype: ~flow.models.ConnectionDto
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["_models.ConnectionDto"]
error_map = {
401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError
}
error_map.update(kwargs.pop('error_map', {}))


request = build_get_connection_with_secrets_request(
subscription_id=subscription_id,
resource_group_name=resource_group_name,
workspace_name=workspace_name,
connection_name=connection_name,
template_url=self.get_connection_with_secrets.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('ConnectionDto', pipeline_response)

if cls:
return cls(pipeline_response, deserialized, {})

return deserialized

get_connection_with_secrets.metadata = {'url': '/flow/api/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/Connections/{connectionName}/listsecrets'} # type: ignore


@distributed_trace_async
async def list_connections(
self,
Expand Down
Loading

0 comments on commit 1c4b194

Please sign in to comment.