Skip to content

Commit

Permalink
[python] ignore final envelope result models for DI (#5290)
Browse files Browse the repository at this point in the history
Co-authored-by: iscai-msft <[email protected]>
Co-authored-by: Yuchao Yan <[email protected]>
  • Loading branch information
3 people authored Dec 9, 2024
1 parent e70c152 commit f132db1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
6 changes: 6 additions & 0 deletions packages/http-client-python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log - @typespec/http-client-python

## 0.4.1

### Bug Fixes

- Ignore models only used as LRO envelope results because we don't do anything with them

## 0.4.0

### Features
Expand Down
16 changes: 16 additions & 0 deletions packages/http-client-python/emitter/src/code-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
}
// loop through models and enums since there may be some orphaned models needs to be generated
for (const model of sdkPackage.models) {
if (isAzureCoreModel(model)) {
continue;
}
// filter out spread models
if (
model.name === "" ||
Expand All @@ -278,6 +281,16 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
) {
continue;
}
// filter out models only used for polling and or envelope result
if (
((model.usage & UsageFlags.LroInitial) > 0 ||
(model.usage & UsageFlags.LroFinalEnvelope) > 0 ||
(model.usage & UsageFlags.LroPolling) > 0) &&
(model.usage & UsageFlags.Input) === 0 &&
(model.usage & UsageFlags.Output) === 0
) {
continue;
}
// filter out specific models not used in python, e.g., pageable models
if (disableGenerationMap.has(model)) {
continue;
Expand All @@ -289,6 +302,9 @@ export function emitCodeModel<TServiceOperation extends SdkServiceOperation>(
getType(sdkContext, model);
}
for (const sdkEnum of sdkPackage.enums) {
if (isAzureCoreModel(sdkEnum)) {
continue;
}
// filter out api version enum since python do not generate it
if (sdkEnum.usage === UsageFlags.ApiVersionEnum) {
continue;
Expand Down
14 changes: 7 additions & 7 deletions packages/http-client-python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/http-client-python/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typespec/http-client-python",
"version": "0.4.0",
"version": "0.4.1",
"author": "Microsoft Corporation",
"description": "TypeSpec emitter for Python SDKs",
"homepage": "https://typespec.io",
Expand Down Expand Up @@ -60,7 +60,7 @@
"@azure-tools/typespec-azure-resource-manager": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.48.0 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.48.0 <3.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.48.0 <1.0.0"
"@azure-tools/typespec-client-generator-core": ">=0.48.5 <1.0.0"
},
"dependencies": {
"js-yaml": "~4.1.0",
Expand All @@ -77,7 +77,7 @@
"@azure-tools/typespec-azure-core": "~0.48.0",
"@azure-tools/typespec-azure-rulesets": "~0.48.0",
"@azure-tools/typespec-azure-resource-manager": "~0.48.0",
"@azure-tools/typespec-client-generator-core": "~0.48.0",
"@azure-tools/typespec-client-generator-core": "~0.48.5",
"@azure-tools/cadl-ranch-specs": "~0.39.1",
"@azure-tools/cadl-ranch-expect": "~0.15.6",
"@types/js-yaml": "~4.0.5",
Expand Down

0 comments on commit f132db1

Please sign in to comment.