Skip to content

Commit d998099

Browse files
authored
Merge branch 'main' into fix-translation-release-ci
2 parents 1b85d0f + 64f2093 commit d998099

1,304 files changed

Lines changed: 217425 additions & 98081 deletions

File tree

Some content is hidden

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

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@
112112
/sdk/textanalytics/ @quentinRobinson @wangyuantao
113113

114114
# PRLabel: %Cognitive - Translator
115-
/sdk/translation/ @jrjrguo @SG-MS
115+
/sdk/translation/ @jrjrguo @zhangeugenia
116116

117117
# ServiceLabel: %Cognitive - Translator
118-
# ServiceOwners: @jrjrguo @SG-MS
118+
# ServiceOwners: @jrjrguo @zhangeugenia
119119

120120
# ServiceLabel: %Communication
121121
# PRLabel: %Communication

sdk/ai/azure-ai-agents/azure/ai/agents/_utils/model_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,16 +816,16 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
816816

817817
# is it optional?
818818
try:
819-
if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore
819+
if any(a for a in annotation.__args__ if a == type(None)): # pyright: ignore # pylint: disable=unidiomatic-typecheck
820820
if len(annotation.__args__) <= 2: # pyright: ignore
821821
if_obj_deserializer = _get_deserialize_callable_from_annotation(
822-
next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore
822+
next(a for a in annotation.__args__ if a != type(None)), module, rf # pyright: ignore # pylint: disable=unidiomatic-typecheck
823823
)
824824

825825
return functools.partial(_deserialize_with_optional, if_obj_deserializer)
826826
# the type is Optional[Union[...]], we need to remove the None type from the Union
827827
annotation_copy = copy.copy(annotation)
828-
annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore
828+
annotation_copy.__args__ = [a for a in annotation_copy.__args__ if a != type(None)] # pyright: ignore # pylint: disable=unidiomatic-typecheck
829829
return _get_deserialize_callable_from_annotation(annotation_copy, module, rf)
830830
except AttributeError:
831831
pass

sdk/ai/azure-ai-agents/azure/ai/agents/models/_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ def _map_type(annotation) -> Dict[str, Any]: # pylint: disable=too-many-return-
333333
if origin is Union:
334334
args = get_args(annotation)
335335
# If Union contains None, it is an optional parameter
336-
if type(None) in args:
336+
if type(None) in args: # pylint: disable=unidiomatic-typecheck
337337
# If Union contains only one non-None type, it is a nullable parameter
338-
non_none_args = [arg for arg in args if arg is not type(None)]
338+
non_none_args = [arg for arg in args if arg is not type(None)] # pylint: disable=unidiomatic-typecheck
339339
if len(non_none_args) == 1:
340340
schema = _map_type(non_none_args[0])
341341
if "type" in schema:

sdk/ai/azure-ai-projects/.env.template

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ A2A_USER_INPUT=
5757
AZURE_TEST_RUN_LIVE=false
5858
AZURE_SKIP_LIVE_RECORDING=true
5959

60+
#Used by hosted agent
61+
FOUNDRY_HOSTED_AGENT_NAME=
62+
6063
# Used in Fine-tuning tests
6164
COMPLETED_OAI_MODEL_SFT_FINE_TUNING_JOB_ID=
6265
COMPLETED_OAI_MODEL_RFT_FINE_TUNING_JOB_ID=
@@ -88,6 +91,6 @@ RUN_EXTENDED_FINE_TUNING_LIVE_TESTS=false
8891
# - SAMPLE_TEST_ERROR_LOG: Sample crashed with an exception during execution
8992
# - SAMPLE_TEST_FAILED_LOG: Sample ran successfully but LLM validation failed (incorrect output)
9093
# - SAMPLE_TEST_PASSED_LOG: Sample ran successfully and LLM validation passed (correct output)
91-
# SAMPLE_TEST_PASSED_LOG=<sample_filename>_success_<timestamp>.log
92-
# SAMPLE_TEST_FAILED_LOG=<sample_filename>_failed_<timestamp>.log
93-
# SAMPLE_TEST_ERROR_LOG=<sample_filename>_errors_<timestamp>.log
94+
SAMPLE_TEST_PASSED_LOG=<sample_filename>_success_<timestamp>.log
95+
SAMPLE_TEST_FAILED_LOG=<sample_filename>_failed_<timestamp>.log
96+
SAMPLE_TEST_ERROR_LOG=<sample_filename>_errors_<timestamp>.log
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# CoPilot skills for azure-ai-projects development
2+
3+
## Prerequisite
4+
5+
* Clone the `azure-sdk-for-python` repo to your local machine, if you don't already have it:
6+
```
7+
git clone https://github.com/Azure/azure-sdk-for-python.git
8+
```
9+
* Change to the directory `sdk\ai\azure-ai-projects`.
10+
* Switch to the current feature branch: `git switch feature/azure-ai-projects/2.2.0`.
11+
* Make sure you don't have any files edited or added in this branch (clean `git status` state).
12+
13+
## Emit from TypeSpec and create a PR
14+
15+
### Using GitHub CoPilot in VSCode
16+
17+
* Open VSCode in the current folder.
18+
* Open the CoPilot chat window ("Toggle Chat").
19+
* Make sure you are in "Agent" mode.
20+
* Start typing `/azure-ai-projects` and press tab to auto complete it to `/azure-ai-projects-emit-from-typespec`, then press Enter.
21+
* Answer some questions and approve execution to go through the workflow
22+
23+
### Using CoPilot CLI or Agency Copilot CLI
24+
25+
* Install [GitHub CoPilot CLI](https://docs.github.com/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli) or [Agency CoPilot CLI](https://aka.ms/agency) (VPN required) if you don't already have it.
26+
* Run CoPilot CLI by typing `copilot`
27+
* Start typing `/azure-ai-projects` and press tab to auto complete it to `/azure-ai-projects-emit-from-typespec`, then press Enter.
28+
* Answer some questions and approve execution to go through the workflow
29+
30+
31+
32+
33+
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
---
2+
name: azure-ai-projects-emit-from-typespec
3+
license: MIT
4+
metadata:
5+
version: "1.0.0"
6+
distribution: local
7+
description: "Emit the azure-ai-projects Python SDK from TypeSpec, apply post-emitter fixes, update changelog, and create a Pull Request. WHEN: \"emit SDK from TypeSpec\", \"generate azure-ai-projects SDK\", \"update azure-ai-projects from TypeSpec\", \"emit from TypeSpec\", \"regenerate azure-ai-projects\". DO NOT USE FOR: other Azure SDK packages, manual code edits without TypeSpec. INVOKES: azsdk-common-generate-sdk-locally skill, post-emitter-fixes.cmd script, git commands, gh CLI for PR creation."
8+
compatibility:
9+
requires: "azure-sdk-mcp server, local azure-sdk-for-python clone, git, gh CLI"
10+
---
11+
12+
# Emit azure-ai-projects Python SDK from TypeSpec
13+
14+
This skill guides Copilot through emitting the azure-ai-projects Python SDK from TypeSpec,
15+
applying post-emitter fixes, updating the changelog, installing package from sources and creating a Pull Request.
16+
17+
**Working directory:** `sdk/ai/azure-ai-projects`
18+
19+
**Skills:** This workflow relies on skills defined under `.github/skills/` at the root of the repository. Use those skills for SDK generation, building, changelog updates, and other SDK lifecycle operations instead of running commands directly. In particular:
20+
21+
- **`azsdk-common-generate-sdk-locally`** – For generating SDK from TypeSpec, building, running checks/tests, updating changelog, metadata, and version.
22+
23+
---
24+
25+
## Step 1: Gather information from the user
26+
27+
Ask the user the following questions **one at a time**, waiting for each answer before proceeding.
28+
29+
### 1a. Topic branch name
30+
31+
Ask the user to choose **one** of the following two options for the target topic branch:
32+
33+
1. **Create a new topic branch (with default branch name)** – Create a new topic branch for the emitted changes. If selected, this default branch name will be used "<github-userid>/<emit-from-typespec-DD-MM-HH-MM>", where `github-userid` is the user's GitHub ID and `DD-MM-HHMM` is the current date-time using date, month, hour and minute. For example, if the GitHub ID is "dargilco" and the current date and time is May 1st, 2026 at 8:13am, the default branch name would be `dargilco/emit-from-typespec-01-05-0813`. This should be the default option, and the default branch name should be displayed. If you press enter without typing anything, this option will be selected.
34+
35+
2. **Create a new topic branch (branch name given by user)** - Ask the user for the branch name. Mention that a common format is "<github-userid>/<work-title>". If the user enters a branch name `feature/azure-ai-projects/2.2.0` then stop and report that they cannot emit directly to the current feature branch.
36+
37+
3. **Emit to current branch** – Emit directly to the current branch without creating a new topic branch. This is not common, but may be necessary if the user is re-running this workflow because of a previous failure, where the topic branch was already created. If the current branch is named `feature/azure-ai-projects/2.2.0` then stop and report that they cannot emit directly to the current feature branch.
38+
39+
### 1b. TypeSpec source
40+
41+
Ask the user to choose **one** of the following three options for the TypeSpec source:
42+
43+
1. **Latest commit on `feature/foundry-release`** – Automatically find the latest commit to the `feature/foundry-release` branch in [Azure/azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) that touched files under `specification/ai-foundry/data-plane/Foundry`, and use that commit hash. This should be the default option. If you press enter without typing anything, this option will be selected.
44+
45+
2. **Local TypeSpec folder** – Emit from a local clone of the [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) repository. If selected, ask for the **full folder path** to the TypeSpec project. This is the folder ending with `\specification\ai-foundry\data-plane\Foundry`. If it does not end with that string, stop and report the error to the user. Do not continue.
46+
47+
3. **TypeSpec commit hash** – Emit from a specific commit in the [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) repository. If selected, ask for the **full commit SHA** (40 characters).
48+
49+
50+
---
51+
52+
## Step 2: Record the current branch
53+
54+
Before creating the topic branch, record the name of the **current Git branch**. This is the branch that the topic branch will be created from, and the branch the PR will target.
55+
56+
```
57+
git branch --show-current
58+
```
59+
60+
Save this as `BASE_BRANCH`.
61+
62+
---
63+
64+
## Step 3: Create the topic branch
65+
66+
Create the topic branch off the current branch and switch to it:
67+
68+
```
69+
git fetch
70+
git switch -c <topic-branch> origin/<BASE_BRANCH>
71+
```
72+
73+
Replace `<topic-branch>` with the name provided by the user in Step 1a.
74+
75+
---
76+
77+
## Step 4: Emit SDK from TypeSpec
78+
79+
Use the **`azsdk-common-generate-sdk-locally`** skill to generate the SDK code. The skill knows how to invoke `azsdk_package_generate_code` and related MCP tools.
80+
81+
Provide the skill with the TypeSpec source selected by the user. With is either:
82+
83+
- **Local folder:** Pass the local spec repo path for local generation. Or,
84+
- **Commit hash:** Update `commit:` in `tsp-location.yaml` to the full SHA first, then invoke the skill for generation.
85+
86+
Note:
87+
- You are only allowed to use the `tsp-client update` command. Do not use any of the other `tsp-client` commands.
88+
- If you are generating from local TypeSpec folder, do not edit the file `tsp-location.yaml`. Leave it as is. It should not be used by the emitter.
89+
- If you are generating from local TypeSpec folder, make sure that the local folder path you provide `tsp-client update --local-spec-repo` ends with `specification\ai-foundry\data-plane\Foundry`.
90+
- **If the generation fails**, stop and report the error to the user. Do not continue.
91+
92+
---
93+
94+
## Step 5: Revert changes to file pyproject.toml
95+
96+
After the emit, there will be changes to `pyproject.toml` that are not needed. Revert any changes to `pyproject.toml` by running:
97+
98+
```
99+
git restore pyproject.toml
100+
```
101+
102+
---
103+
104+
## Step 6: Commit and push
105+
106+
Stage all changes (excluding file names that start with `.env`), commit, and push the topic branch:
107+
108+
```
109+
git add -A -- ':!.env*'
110+
git commit -m "Part 1: Emit SDK from TypeSpec"
111+
112+
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>"
113+
git push -u origin <topic-branch>
114+
```
115+
116+
---
117+
118+
## Step 7: Run post-emitter fixes
119+
120+
After a successful emit, run the post-emitter fix script located in the `sdk/ai/azure-ai-projects` folder:
121+
122+
```
123+
post-emitter-fixes.cmd
124+
```
125+
126+
This script applies azure-ai-projects-specific corrections to the emitted code (restores `pyproject.toml`, fixes enum names, patches Sphinx doc-string issues, and runs `black` formatting).
127+
128+
**If the script fails**, stop and report the error to the user. Do not continue. Do not attempt to analyze the script failures and fix them with Copilot. The script should be fixed by the engineering team if it is not working.
129+
130+
---
131+
132+
## Step 8: Commit and push
133+
134+
Stage all changes (excluding file names that start with `.env`), commit, and push the topic branch:
135+
136+
```
137+
git add -A -- ':!.env*'
138+
git commit -m "Part 2: Apply post-emitter-fixes.cmd"
139+
140+
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>"
141+
git push -u origin <topic-branch>
142+
```
143+
144+
---
145+
146+
## Step 9: Fix patched code related to preview feature headers
147+
148+
The emitted code may have introduced another beta sub-client (a new property on class `BetaOperations`). It may have also added another enum value to the existing internal class `_FoundryFeaturesOptInKeys`. This means that the client library needs to set a new HTTP request header when making REST API calls to the service, to opt-in to the new service features which are still in preview. If that's the case, do the following:
149+
150+
* Update the dictionary `_BETA_OPERATION_FEATURE_HEADERS` defined in `azure\ai\projects\models\_patch.py`, to include a new key-value pair to map the new beta sub-client name to the proper value from `_FoundryFeaturesOptInKeys`. If no new beta sub-client was introduced, but a new enum value was added to `_FoundryFeaturesOptInKeys`, you will need to update one of the existing key-value pairs in `_BETA_OPERATION_FEATURE_HEADERS` to a comma-separated join of multiple values from `_FoundryFeaturesOptInKeys`.
151+
152+
* Do a similar change to the dictionary `EXPECTED_FOUNDRY_FEATURES` defined in the test file `tests\foundry_features_header\foundry_features_header_test_base.py`: add a new key-value pair if a new beta sub-client was introduced, or update an existing key-value pair to include the new enum value if no new beta sub-client was introduced.
153+
154+
* Finally, look at the two files `azure\ai\projects\operations\_patch.py` and `azure\ai\projects\aio\operations\_patch.py`. They define the public `BetaOperations` classes for the sync and async clients. To support a new sub-client, you will need to add a new property to this class with the proper doc string. You will need to update the import statement at the top of the file to import the new sub-client class. And you will need to update `__all__` statement at the bottom of the file to include the new sub-client class name. Follow the examples you see there for `BetaDatasetsOperations` or `BetaSkillsOperations`.
155+
156+
If a new enum value was added to `_AgentDefinitionOptInKeys`, please print a note on screen that mentions which value was added, and tell the user that a review is needed to make sure this new value is properly used. But otherwise continue on.
157+
158+
Important: Under the `azure\ai\projects` folder, you are only allowed to edit Python source files that start with "_patch". If you see that changes are needed in other files, stop and report this to the user instead of making the changes yourself.
159+
160+
---
161+
162+
## Step 10: Update samples and tests
163+
164+
If there were any breaking changes in existing APIs, like class or method renames:
165+
* update the patched code accordingly in the client library to reflect those changes. Changes should be made to Python source file names that start with "_patch", under the `azure\ai\projects` folder.
166+
* update the samples accordingly to reflect those changes. Changes should be made under `sdk/ai/azure-ai-projects/samples` folder.
167+
* update the tests accordingly to reflect those changes. Changes should be made under `sdk/ai/azure-ai-projects/tests` folder.
168+
169+
---
170+
171+
## Step 11: Install package from sources
172+
173+
In the folder `sdk\ai\azure-ai-projects`, run `pip install -e .` to install the package from sources. If there are any errors, stop and report the error to the user. Do not continue.
174+
175+
---
176+
177+
## Step 12: Update CHANGELOG.md
178+
179+
Use the **`azsdk-common-generate-sdk-locally`** skill's changelog capability (`azsdk_package_update_changelog_content`) to update `CHANGELOG.md` in the `sdk/ai/azure-ai-projects` folder with a summary of changes from the TypeSpec emit. Some guidelines to follow:
180+
* Start by examining the public SDK API surface of the latest released version of the azure-ai-projects package. The source code for this version can be found in the Main branch of the `azure-sdk-for-python` repository, in the folder `sdk\ai\azure-ai-projects`.
181+
* Then compare it to the public SDK API surface of current version in this topic branch.
182+
* Look at the existing change log from the latest version (if exists) and edit or add to it to capture all the changes you see. If a change log does not exist for the current version at the top of `CHANGELOG.md`, create a new one.
183+
* If a new method was added, there is no need to add the list of all new classes that define the inputs and output of the method. It's enough to mention that the new method was added.
184+
* Show the user the proposed changelog entry and ask for confirmation or edits before saving.
185+
186+
---
187+
188+
## Step 13: Commit and push
189+
190+
Stage all changes (excluding file names that start with `.env`), commit, and push the topic branch:
191+
192+
```
193+
git add -A -- ':!.env*'
194+
git commit -m "Part 3: Additional edits"
195+
196+
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>"
197+
git push -u origin <topic-branch>
198+
```
199+
200+
---
201+
202+
## Step 14: Create a Pull Request
203+
204+
Create a draft PR from the **topic branch** to the **base branch** (recorded in Step 2):
205+
206+
```
207+
gh pr create --draft --base <BASE_BRANCH> --head <topic-branch> --assignee @me --title "<PR title>" --body "<PR body>"
208+
```
209+
210+
- **Title:** Use a descriptive title such as `[azure-ai-projects] Emit SDK from TypeSpec (<short description>)`.
211+
- **Body:** Include which TypeSpec source was used and a summary of the changelog entry.
212+
213+
You must show the user the resulting PR URL on screen when done, before you continue to the next step.
214+
215+
Open a new tab in the default browser and navigate to the PR URL.
216+
217+
---
218+
219+
## Step 15: Optionally run tests locally
220+
221+
Prompt the user with this message: "Tests will run as part of the Pull Request. However, you can optionally run tests locally in a Python virtual environment, right now. It will take a few minutes. Do you want to run tests locally? (yes/no)"
222+
223+
If the user answers "yes", run all tests from recordings. Follow these guidelines:
224+
* Run tests in a local Python virtual environment. Create this virtual environment if it does not already exists:
225+
```
226+
python -m venv .venv
227+
```
228+
and activate it:
229+
```
230+
.venv\Scripts\activate
231+
```
232+
* Show test progress on screen, as tests are run.
233+
234+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)