Skip to content

Commit f7e8164

Browse files
Add TypeSpec migration plan for azure-ai-ml restclients
1 parent b66e922 commit f7e8164

1 file changed

Lines changed: 216 additions & 0 deletions

File tree

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# Azure AI ML: Autorest → TypeSpec Migration Plan
2+
3+
## Background
4+
5+
Two companion PRs initiated the migration from autorest-generated REST clients to TypeSpec-generated ones:
6+
7+
- **Spec PR**: [Azure/azure-rest-api-specs#40758](https://github.com/Azure/azure-rest-api-specs/pull/40758) — Authored TypeSpec definitions for 6 services (1 mgmt + 5 data-plane), merged Mar 26, 2026.
8+
- **SDK PR**: [Azure/azure-sdk-for-python#45389](https://github.com/Azure/azure-sdk-for-python/pull/45389) — Consumed the TypeSpec specs to generate new Python clients, deleted some old GA versioned folders, merged Mar 27, 2026.
9+
10+
### What Those PRs Did
11+
1. Created TypeSpec definitions in `azure-rest-api-specs` for:
12+
- `MachineLearningServices.Management` (ARM)
13+
- `AzureAI.RegistryDiscovery` (data-plane)
14+
- `AzureAI.WorkspaceDataplane` (data-plane)
15+
- `AzureAI.DatasetDataplane` (data-plane)
16+
- `AzureAI.ModelDataplane` (data-plane)
17+
- `AzureAI.RunHistory` (data-plane)
18+
2. Generated TypeSpec-based Python clients in `_restclient/`
19+
3. Removed old GA autorest client _full_ packages (kept models/operations stubs for backward compat)
20+
4. Updated all imports in the SDK codebase to point to new TypeSpec clients where possible
21+
5. Modernized packaging (setup.py → pyproject.toml, dropped msrest/azure-common)
22+
23+
---
24+
25+
## Current State (Post-Migration PR)
26+
27+
### TypeSpec-Generated Clients (DONE ✅)
28+
29+
| Client Folder | TypeSpec Spec Path | API Version | Status |
30+
|---|---|---|---|
31+
| `arm_ml_service/` | `MachineLearningServices.Management` | 2025-12-01 | ✅ Generated & in use |
32+
| `registry_discovery/` | `AzureAI.RegistryDiscovery` | v1.0 | ✅ Generated & in use |
33+
| `workspace_dataplane/` | `AzureAI.WorkspaceDataplane` || ✅ Generated & in use |
34+
| `dataset_dataplane/` | `AzureAI.DatasetDataplane` | 1.5.0 | ✅ Generated & in use |
35+
| `model_dataplane/` | `AzureAI.ModelDataplane` | 1.0.0 | ✅ Generated & in use |
36+
| `runhistory/` | `AzureAI.RunHistory` | v1.0 | ✅ Generated & in use |
37+
| `azure_ai_assets_v2024_04_01/` | `AzureAI.Assets` | 2024-04-01 | ✅ Generated & in use |
38+
39+
### GA Versions — Already Migrated ✅
40+
41+
The following GA versions were fully deleted by PR #45389. Their functionality is now covered by the TypeSpec `arm_ml_service` client (2025-12-01):
42+
- 2022-05-01
43+
- 2022-10-01
44+
- 2023-04-01
45+
- 2023-10-01
46+
47+
(Local `__pycache__` remnants may exist but no source files remain; these folders are not tracked in git.)
48+
49+
### Remaining Autorest Clients (STILL TO MIGRATE ❌)
50+
51+
| Folder | API Version | Key Usage | Priority |
52+
|---|---|---|---|
53+
| `v2020_09_01_dataplanepreview/` | 2020-09-01-dataplanepreview | BatchJobResource, DataVersion, UriFileJobOutput models | Low (legacy) |
54+
| `v2021_10_01_dataplanepreview/` | 2021-10-01-dataplanepreview | AzureMachineLearningWorkspaces client, ModelVersionData | Low (legacy) |
55+
| `v2022_01_01_preview/` | 2022-01-01-preview | Identity models (RestIdentityConfiguration, RestUserAssignedIdentity) | Medium |
56+
| `v2022_02_01_preview/` | 2022-02-01-preview | ServiceClient, DeploymentLogsRequest, JobBaseData, KeyType, operations | Medium |
57+
| `v2022_10_01_preview/` | 2022-10-01-preview | ServiceClient102022, UsageUnit | Medium |
58+
| `v2022_12_01_preview/` | 2022-12-01-preview | (check usage) | Medium |
59+
| `v2023_02_01_preview/` | 2023-02-01-preview | (check usage) | Medium |
60+
| `v2023_04_01_preview/` | 2023-04-01-preview | ServiceClient022023Preview, many models (JobInput, JobOutput, Datastore creds, Identity, etc.) | **HIGH** |
61+
| `v2023_06_01_preview/` | 2023-06-01-preview | ServiceClient062023Preview, models | Medium |
62+
| `v2023_08_01_preview/` | 2023-08-01-preview | ServiceClient082023Preview, JobType, ListViewType, ModelVersion | Medium |
63+
| `v2024_01_01_preview/` | 2024-01-01-preview | ServiceClient012024, TriggerOnceRequest, ComponentVersion, ComputeInstanceDataMount, JobBase | **HIGH** |
64+
| `v2024_04_01_dataplanepreview/` | 2024-04-01-preview (dataplane) | (check usage) | Medium — TypeSpec available via `AzureAI.Assets` |
65+
| `v2024_04_01_preview/` | 2024-04-01-preview | ServiceClient042024Preview, SsoSetting, models | **HIGH** |
66+
| `v2024_07_01_preview/` | 2024-07-01-preview | ServiceClient072024Preview, Datastore models, SecretExpiry | **HIGH** |
67+
| `v2024_10_01_preview/` | 2024-10-01-preview | ServiceClient102024Preview, ManagedNetworkProvisionOptions, OutboundRuleBasicResource, JobType | **HIGH** |
68+
| `v2025_01_01_preview/` | 2025-01-01-preview | ServiceClient012025Preview | **HIGH** |
69+
70+
---
71+
72+
## Work Required
73+
74+
### Phase 1: TypeSpec Spec Authoring (azure-rest-api-specs repo)
75+
76+
For each remaining API version, swagger must be converted to TypeSpec in the `azure-rest-api-specs` repo. The ARM client already uses TypeSpec with versioning (via `@versioned` enum).
77+
78+
**Current TypeSpec coverage in spec repo (`MachineLearningServices.Management`):**
79+
- 2024-10-01-preview ✅
80+
- 2025-10-01-preview ✅
81+
- 2025-12-01 ✅
82+
- 2026-01-15-preview ✅
83+
- 2026-03-01 ✅
84+
- 2026-03-15-preview ✅
85+
86+
**Current TypeSpec coverage for dataplane projects:**
87+
- `data-plane/DatasetDataplane` → 1.5.0 ✅
88+
- `data-plane/ModelDataplane` → 1.0.0 ✅
89+
- `data-plane/RunHistory` → v1.0 ✅
90+
- `data-plane/RegistryDiscovery` → v1.0 ✅
91+
- `data-plane/WorkspaceDataplane` → 2023-06-01-preview ✅
92+
- `AzureAI.Assets` → 2024-04-01-preview, 2024-05-01-preview ✅
93+
94+
**Versions that NEED TypeSpec authoring (not yet in spec repo):**
95+
96+
| API Version | Type | Swagger Exists | Action Needed |
97+
|---|---|---|---|
98+
| 2020-09-01-dataplanepreview | Dataplane || Add to TypeSpec or deprecate |
99+
| 2021-10-01-dataplanepreview | Dataplane || Add to TypeSpec or deprecate |
100+
| 2022-01-01-preview | ARM || Add to `@versioned` enum |
101+
| 2022-02-01-preview | ARM || Add to `@versioned` enum |
102+
| 2022-10-01-preview | ARM || Add to `@versioned` enum |
103+
| 2022-12-01-preview | ARM || Add to `@versioned` enum |
104+
| 2023-02-01-preview | ARM || Add to `@versioned` enum |
105+
| 2023-04-01-preview | ARM || Add to `@versioned` enum |
106+
| 2023-06-01-preview | ARM || Add to `@versioned` enum |
107+
| 2023-08-01-preview | ARM || Add to `@versioned` enum |
108+
| 2024-01-01-preview | ARM || Add to `@versioned` enum |
109+
| 2024-04-01-preview | ARM || Add to `@versioned` enum |
110+
| 2024-04-01-preview (dp) | Dataplane || ✅ Already available via `AzureAI.Assets` TypeSpec |
111+
| 2024-07-01-preview | ARM || Add to `@versioned` enum |
112+
| 2025-01-01-preview | ARM || Add to `@versioned` enum |
113+
114+
**Note:** The ARM TypeSpec was auto-generated from swagger using `@autorest/openapi-to-typespec` converter (v0.11.12). Adding older versions requires adding `@added(Versions.vXXXX)` decorators to models/operations and extending the Versions enum.
115+
116+
**Action Required:** We need TypeSpec definitions authored for all remaining autorest restclient API versions listed above. Each version's swagger needs to be converted and added to the `@versioned` enum in the `MachineLearningServices.Management` TypeSpec project (for ARM versions) or to the respective dataplane TypeSpec projects (for dataplane versions). Once the TypeSpec specs exist, we can generate the Python clients and replace the old autorest code.
117+
118+
### Phase 2: Generate TypeSpec Clients (azure-sdk-for-python repo)
119+
120+
Once specs are authored, generate clients using TypeSpec emitter and replace the autorest folders.
121+
122+
### Phase 3: Update Imports & Remove Old Clients
123+
124+
For each migrated version:
125+
1. Update all imports in `azure/ai/ml/` to use the new TypeSpec-generated client
126+
2. Run tests to validate no regressions
127+
3. Delete old autorest folder
128+
129+
### Phase 4: Clean Up Local Artifacts
130+
131+
Remove leftover `__pycache__` directories from the deleted GA folders (v2022_05_01, v2022_10_01, v2023_04_01, v2023_10_01) — these are already untracked in git.
132+
133+
---
134+
135+
## Immediate Action: Versions With TypeSpec Already Available
136+
137+
The following 2 remaining autorest clients **already have TypeSpec definitions** in the spec repo and should be converted first:
138+
139+
| Autorest Client | API Version | TypeSpec Path in `azure-rest-api-specs` | Status |
140+
|---|---|---|---|
141+
| `v2024_10_01_preview/` | 2024-10-01-preview | `specification/machinelearningservices/MachineLearningServices.Management` (in `@versioned` enum) | Ready to generate |
142+
| `v2024_04_01_dataplanepreview/` | 2024-04-01-preview (dataplane) | `specification/machinelearningservices/AzureAI.Assets` (version `2024-04-01-preview`) | Ready to generate |
143+
144+
**These should be the starting point** — generate TypeSpec clients for these versions, update imports, and remove the old autorest folders.
145+
146+
### How to Generate a REST Client from TypeSpec
147+
148+
From the `sdk/ml/azure-ai-ml/azure/ai/ml/_restclient` directory, use the `tsp-client` tool:
149+
150+
```bash
151+
# Generate a specific client (e.g., arm_ml_service)
152+
tsp-client update -d ./arm_ml_service
153+
154+
# Or to generate all clients listed in the batch tsp-location.yaml
155+
tsp-client update
156+
```
157+
158+
Each client subfolder has its own `tsp-location.yaml` pointing to the TypeSpec spec:
159+
```yaml
160+
directory: specification/machinelearningservices/MachineLearningServices.Management
161+
commit: <commit-sha>
162+
repo: Azure/azure-rest-api-specs
163+
additionalDirectories: []
164+
```
165+
166+
To target a specific commit or branch of the spec repo, update the `commit` field in the `tsp-location.yaml` before running `tsp-client update`.
167+
168+
## Versions Without TypeSpec (Require Spec Authoring First)
169+
170+
The following **14 versions** do NOT have TypeSpec definitions yet. Swagger-to-TypeSpec conversion is needed before these can be migrated:
171+
172+
| Autorest Client | API Version | Type |
173+
|---|---|---|
174+
| `v2020_09_01_dataplanepreview/` | 2020-09-01-dataplanepreview | Dataplane |
175+
| `v2021_10_01_dataplanepreview/` | 2021-10-01-dataplanepreview | Dataplane |
176+
| `v2022_01_01_preview/` | 2022-01-01-preview | ARM |
177+
| `v2022_02_01_preview/` | 2022-02-01-preview | ARM |
178+
| `v2022_10_01_preview/` | 2022-10-01-preview | ARM |
179+
| `v2022_12_01_preview/` | 2022-12-01-preview | ARM |
180+
| `v2023_02_01_preview/` | 2023-02-01-preview | ARM |
181+
| `v2023_04_01_preview/` | 2023-04-01-preview | ARM |
182+
| `v2023_06_01_preview/` | 2023-06-01-preview | ARM |
183+
| `v2023_08_01_preview/` | 2023-08-01-preview | ARM |
184+
| `v2024_01_01_preview/` | 2024-01-01-preview | ARM |
185+
| `v2024_04_01_preview/` | 2024-04-01-preview | ARM |
186+
| `v2024_07_01_preview/` | 2024-07-01-preview | ARM |
187+
| `v2025_01_01_preview/` | 2025-01-01-preview | ARM |
188+
189+
---
190+
191+
## Recommended Execution Order
192+
193+
1. **Start with the 2 versions that have TypeSpec available now** (`v2024_10_01_preview`, `v2024_04_01_dataplanepreview`) — generate clients and migrate.
194+
2. **Then target recent ARM previews** (2025-01-01-preview, 2024-07-01-preview, 2024-04-01-preview, 2024-01-01-preview) once their TypeSpecs are authored.
195+
3. **Work backwards** through 2023-08-01-preview, 2023-06-01-preview, 2023-04-01-preview, etc.
196+
4. **Legacy dataplane versions** (2020/2021) should be assessed for deprecation rather than migration — they may only be needed for very old model compatibility.
197+
198+
---
199+
200+
## Key Decisions Needed
201+
202+
1. **Multi-version vs single-latest**: Should the TypeSpec ARM client expose multiple API versions (via `@versioned`), or should old version imports be remapped to use the latest API version?
203+
2. **Deprecation of legacy dataplane versions**: Can `v2020_09_01_dataplanepreview` and `v2021_10_01_dataplanepreview` be dropped entirely, or are they needed for live service compatibility?
204+
3. **Model-only stubs**: Can GA stub folders be deleted if their models are re-exported from `arm_ml_service`?
205+
4. **Incremental vs big-bang**: Migrate one API version at a time (safer) or batch multiple together?
206+
207+
---
208+
209+
## Summary Metrics
210+
211+
| Category | Count |
212+
|---|---|
213+
| TypeSpec clients already generated | 7 (+ 4 GA versions fully migrated) |
214+
| Autorest clients still remaining | 16 preview versions |
215+
| High-priority migrations | 6 (2023-04-01-preview through 2025-01-01-preview) |
216+
| Legacy candidates for deprecation | 2 (2020/2021 dataplane) |

0 commit comments

Comments
 (0)