Skip to content

Commit ba4d6fe

Browse files
authored
Initial test framework for emitter (#1394)
* Initial test framework for emitter * Remove the modules folder
1 parent d3ec4d1 commit ba4d6fe

File tree

579 files changed

+157416
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

579 files changed

+157416
-1
lines changed

.azure-pipelines/test-emitter.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
pool: pool-windows-2019
2+
3+
steps:
4+
- task: NodeTool@0
5+
displayName: 'Use Node 18'
6+
inputs:
7+
versionSpec: 18.x
8+
9+
- task: Npm@1
10+
displayName: 'Install @typespec/compiler@latest'
11+
inputs:
12+
command: custom
13+
verbose: false
14+
customCommand: 'install -g "@typespec/compiler"'
15+
16+
- task: Npm@1
17+
displayName: 'Install @microsoft/rush'
18+
inputs:
19+
command: custom
20+
verbose: false
21+
customCommand: 'install -g @microsoft/[email protected]'
22+
23+
- task: CmdLine@2
24+
displayName: 'Rush sync-versions'
25+
inputs:
26+
script: 'rush sync-versions'
27+
28+
- task: CmdLine@2
29+
displayName: 'Rush Update'
30+
inputs:
31+
script: 'rush update'
32+
33+
- task: CmdLine@2
34+
displayName: 'Rush Rebuild'
35+
inputs:
36+
script: 'rush rebuild'
37+
38+
- script: npm install
39+
displayName: 'Run npm install in tests-emitter'
40+
workingDirectory: 'tests-upgrade/tests-emitter'
41+
42+
- pwsh: |
43+
./EmitterTest.ps1 -AllowList
44+
workingDirectory: 'tests-upgrade/tests-emitter'
45+
displayName: 'Verify Typespec emitter'
46+
47+
- task: PublishPipelineArtifact@0
48+
displayName: 'Save artifacts'
49+
inputs:
50+
artifactName: CompareResult
51+
targetPath: tests-upgrade/tests-emitter/CompareResult
52+
condition: succeededOrFailed()

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,4 +382,13 @@ package-deps.json
382382

383383
!/tests/**/test/*
384384

385-
.vscode/
385+
.vscode/
386+
387+
# Ignore generated files for tests-emitter
388+
tests-upgrade/tests-emitter/*/generated/
389+
tests-upgrade/tests-emitter/*/target/generated/modules/
390+
tests-upgrade/tests-emitter/*/tsp-output/
391+
tests-upgrade/tests-emitter/CompareResult
392+
393+
# Ignore the node_modules directory for tests-emitter
394+
tests-upgrade/tests-emitter/node_modules/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
import "./main.tsp";
3+
4+
using Azure.ClientGenerator.Core;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import "@typespec/rest";
2+
import "@typespec/versioning";
3+
import "@azure-tools/typespec-azure-core";
4+
import "@azure-tools/typespec-azure-resource-manager";
5+
6+
using TypeSpec.Http;
7+
using TypeSpec.Rest;
8+
using TypeSpec.Versioning;
9+
using Azure.Core;
10+
11+
namespace Microsoft.MachineLearningServices;
12+
13+
@doc("Metadata pertaining to creation and last modification of the resource.")
14+
model SystemData {
15+
@visibility("read")
16+
@doc("The timestamp the resource was created at.")
17+
createdAt?: utcDateTime;
18+
19+
@visibility("read")
20+
@doc("The identity that created the resource.")
21+
createdBy?: string;
22+
23+
@visibility("read")
24+
@doc("The identity type that created the resource.")
25+
createdByType?: string;
26+
27+
@visibility("read")
28+
@doc("The timestamp of resource last modification (UTC)")
29+
lastModifiedAt?: utcDateTime;
30+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import "@typespec/http";
2+
import "@typespec/rest";
3+
import "@typespec/versioning";
4+
import "@azure-tools/typespec-azure-core";
5+
import "./routes.tsp";
6+
7+
using TypeSpec.Http;
8+
using TypeSpec.Rest;
9+
using TypeSpec.Versioning;
10+
using Azure.Core;
11+
using Azure.Core.Traits;
12+
13+
@useAuth(
14+
OAuth2Auth<[
15+
{
16+
type: OAuth2FlowType.implicit,
17+
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
18+
scopes: ["https://ml.azure.com/.default"],
19+
}
20+
]>
21+
)
22+
@service({
23+
title: "Azure Machine Learning Data Plane Services",
24+
})
25+
@server(
26+
"{endpoint}/genericasset/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}",
27+
"Machinelearning Services Asset APIs",
28+
{
29+
@doc("""
30+
Supported Azure-AI asset endpoints.
31+
""")
32+
endpoint: url,
33+
34+
@doc("The ID of the target subscription.")
35+
subscriptionId: string,
36+
37+
@doc("The name of the Resource Group.")
38+
resourceGroupName: string,
39+
40+
@doc("The name of the AzureML workspace or AI project.")
41+
workspaceName: string,
42+
}
43+
)
44+
@versioned(Versions)
45+
namespace Microsoft.MachineLearningServices;
46+
47+
@doc("Azure Machine Learning Services api versions.")
48+
enum Versions {
49+
@doc("Azure Machine Learning Services api version 2024-04-01-preview.")
50+
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
51+
`2024-04-01-preview`,
52+
53+
@doc("Azure Machine Learning Services api version 2024-05-01-preview.")
54+
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
55+
`2024-05-01-preview`,
56+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import "@typespec/rest";
2+
import "@azure-tools/typespec-autorest";
3+
import "@typespec/versioning";
4+
import "@azure-tools/typespec-azure-core";
5+
import "./common.tsp";
6+
import "@typespec/openapi";
7+
import "@typespec/versioning";
8+
9+
using TypeSpec.OpenAPI;
10+
using TypeSpec.Http;
11+
using TypeSpec.Rest;
12+
using TypeSpec.Versioning;
13+
using Azure.Core;
14+
using Azure.Core.Traits;
15+
16+
namespace Microsoft.MachineLearningServices;
17+
18+
@doc("AssetVersion Definition")
19+
model AssetVersion {
20+
@doc("Fully qualified resource Id: azureml://workspace/{workspaceName}/indexes/{name}/versions/{version} of the index.")
21+
@visibility("read")
22+
id: string;
23+
24+
@doc("Update stage to 'Archive' to archive the asset. Default is Development, which means the asset is under development.")
25+
stage?: string = "Development";
26+
27+
@doc("Description information of the asset.")
28+
description?: string;
29+
30+
@doc("Metadata containing createdBy and modifiedBy information.")
31+
@visibility("read")
32+
systemData?: SystemData;
33+
34+
@doc("Asset's tags. Unlike properties, tags are fully mutable.")
35+
tags?: Record<string>;
36+
37+
@doc("Asset's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed.")
38+
properties?: Record<string>;
39+
}
40+
41+
@doc("Index resource Definition")
42+
model Index is AssetVersion {
43+
@doc("Default workspace blob storage Uri. Should work across storage types and auth scenarios.")
44+
storageUri: string;
45+
}
46+
47+
@doc("Paged collection of IndexVersion items.")
48+
@pagedResult
49+
model PagedIndex {
50+
@doc("The list of Indexes.")
51+
@extension("x-ms-identifiers", [])
52+
@items
53+
value: Index[];
54+
55+
@doc("The link to the next page of items")
56+
@nextLink
57+
nextLink?: ResourceLocation<Index>;
58+
}
59+
60+
@doc("Prompt resource definition")
61+
@added(Versions.`2024-05-01-preview`)
62+
model Prompt is AssetVersion {
63+
@doc("Default workspace blob storage Ui. Should work across storage types and auth scenarios.")
64+
dataUri: string;
65+
66+
@doc("Relative path of the prompt data file at the dataUri location")
67+
templatePath: string;
68+
}
69+
70+
@doc("Paged collection of PromptVersion items")
71+
@pagedResult
72+
@added(Versions.`2024-05-01-preview`)
73+
model PagedPrompt {
74+
@doc("The list of Prompts.")
75+
@extension("x-ms-identifiers", [])
76+
@items
77+
value: Prompt[];
78+
79+
@doc("The link to the next page of items")
80+
@nextLink
81+
nextLink?: ResourceLocation<Prompt>;
82+
}
83+
84+
@doc("Next version definition.")
85+
model VersionInfo {
86+
@doc("Next version as defined by the server. The server keeps track of all versions that are string-representations of integers. If one exists, the nextVersion will be a string representation of the highest integer value + 1. Otherwise, the nextVersion will default to '1'.")
87+
nextVersion?: int64;
88+
89+
@doc("Current latest version of the resource.")
90+
latestVersion: string;
91+
}
92+
93+
#suppress "@azure-tools/typespec-providerhub/no-inline-model" "Need to create reponses correctly"
94+
alias ResourceCreatedResponse<T extends TypeSpec.Reflection.Model> = TypeSpec.Http.Response<201> &
95+
T;
96+
97+
#suppress "@azure-tools/typespec-providerhub/no-inline-model" "Need to create reponses correctly"
98+
alias ResourceCreatedOrOkResponse<T extends TypeSpec.Reflection.Model> = ResourceCreatedResponse<T> | (TypeSpec.Http.Response<200> &
99+
T);

0 commit comments

Comments
 (0)