Skip to content

SDK operations for Models, Unit tests and Sample notebook#46842

Open
kshitij-microsoft wants to merge 18 commits into
Azure:feature/azure-ai-projects/2.2.0from
kshitij-microsoft:kchawla/models
Open

SDK operations for Models, Unit tests and Sample notebook#46842
kshitij-microsoft wants to merge 18 commits into
Azure:feature/azure-ai-projects/2.2.0from
kshitij-microsoft:kchawla/models

Conversation

@kshitij-microsoft
Copy link
Copy Markdown
Member

Description

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

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK 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.

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.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Comment thread sdk/ai/azure-ai-projects/samples/models/sample_models.ipynb Outdated
Comment thread sdk/ai/azure-ai-projects/samples/models/sample_models.ipynb Outdated
Comment thread sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_models.py Outdated
Comment thread sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_models.py Outdated
Comment thread sdk/ai/azure-ai-projects/samples/models/sample_models_basic.py
Comment thread sdk/ai/azure-ai-projects/CHANGELOG.md Outdated
Comment thread sdk/ai/azure-ai-projects/tests/samples/llm_instructions.py
Comment thread sdk/ai/azure-ai-projects/pyproject.toml Outdated
Comment thread sdk/ai/azure-ai-projects/CHANGELOG.md
Comment thread sdk/ai/azure-ai-projects/CHANGELOG.md Outdated
* New optional `force` parameter on `agents.delete` and `agents.delete_version` methods.
* New optional `blueprint_reference` parameters on `agents.create_version` method.

* New `.beta.models` sub-client for registering and managing local model weights as Foundry `ModelVersion` resources. Generated operations: `list`, `list_versions`, `get`, `update`, `delete`, `pending_upload`, `create_async`, `get_credentials`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already have a line for ".beta.models" above. Please merge.

Comment thread sdk/ai/azure-ai-projects/CHANGELOG.md Outdated
@@ -20,6 +20,8 @@
* New optional `force` parameter on `agents.delete` and `agents.delete_version` methods.
* New optional `blueprint_reference` parameters on `agents.create_version` method.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove space line

"azure.ai.projects.models.AgentCardSkill": "Azure.AI.Projects.AgentCardSkill",
"azure.ai.projects.models.InsightRequest": "Azure.AI.Projects.InsightRequest",
"azure.ai.projects.models.AgentClusterInsightRequest": "Azure.AI.Projects.AgentClusterInsightRequest",
"azure.ai.projects.models.InsightResult": "Azure.AI.Projects.InsightResult",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect to see anything here change in this file in your PR... is there some issue with resolving conflict after a merge?

Comment thread sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py
Copy link
Copy Markdown
Member

@howieleung howieleung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feedback

Comment thread sdk/ai/azure-ai-projects/samples/models/sample_models.py Outdated
Comment thread sdk/ai/azure-ai-projects/samples/models/sample_models_basic.py
Comment thread sdk/ai/azure-ai-projects/samples/models/sample_models_basic.py
creds = project_client.beta.models.get_credentials(
name=model_name,
version=model_version,
body=ModelCredentialRequest(blob_uri=model.blob_uri),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be model.blob_uri? blob_uri is a property of ModelVersion
But after correction, I still see error on VS code. model can be None,

Image

Darren (dargilco):

- D1: Merge feature/azure-ai-projects/2.2.0 into branch (separate merge commit).

- D2: Remove duplicate '.beta.models' CHANGELOG bullet.

- D3: Remove stray blank line in CHANGELOG.

- D4: Revert apiview-properties.json to base.

- D5: Wire async patched BetaModelsOperations into aio/operations/_patch.py;

  add azure/ai/projects/aio/operations/_patch_models_async.py with async create_version()

  using azure.storage.blob.aio.ContainerClient.

Howie (howieleung):

- H1: Rename helper models_create -> create_version (and validator).

- H2: Rename sample_models{,_async}.py -> sample_models_basic{,_async}.py.

- H3: Print friendly per-field summaries in samples instead of raw model repr.

- H4: Guard against None return from create_version before accessing fields.

Also follows TypeSpec rename: generated create_async() -> pending_create_version().
- Renames patched BetaModelsOperations.create_version() to create() (sync + async).

- Renames internal validator _validate_create_version_inputs -> _validate_create_inputs.

- Updates samples, tests, README, and CHANGELOG to use the new name.

- Leaves generated spec method pending_create_version unchanged.
- Add parameterized sample tests test_models_samples (sync + async).

- Add slim modelsServicePreparer (only foundry_project_endpoint).

- Add sanitizers for random model name, Foundry storage account/container,

  /workspaces/<name>, azureai:// asset URIs, account/project from FOUNDRY_PROJECT_ENDPOINT,

  and SAS query parameters (sig, skoid, sktid).

- Use per-recording random MODEL_NAME (recsmplmdl<hex>) and sanitize to a stable

  value on playback (Foundry asset-store reserves <name>/<version> permanently).

- Update assets.json tag to point at the new recordings.

Bug fixes surfaced by live runs (renamed generated kwargs):

- pending_upload: body= -> pending_upload_request=

- pending_create_version: body= -> model_version=

- get_credentials: body= -> credential_request=

Applied to patched create() helper (sync + async), all three model samples,

and the test_patch_models mock.

Notes:

- sample_models_basic.py (which uses AzCopy) is excluded from the parameterized

  sample tests because AzCopy traffic isn't captured by the test proxy.

- LLM print-call validation is not invoked for models tests (canary project

  has no Azure OpenAI connection).
The multi-step orchestrator helper performs local input validation before any HTTP call, so the test framework's synthetic placeholder args (e.g. source={}) cause it to raise TypeError before _RequestCaptured is ever raised. Add a shared EXCLUDED_BETA_METHODS mapping and skip excluded methods in both sync and async discovery. The header invariant is still enforced for every underlying HTTP method create() calls (pending_upload, pending_create_version, get).
- Replace hasattr-based duck typing with isinstance(dict) check so pyright can narrow types correctly on _extract_pending_upload_targets.
- Remove unused HttpResponseError import.
- Suppress do-not-import-asyncio for asyncio.sleep used in the async polling loop (transport sleep is not applicable).
- Add :param/:keyword/:return/:rtype docstring sections on private helpers to satisfy azure-pylint-guidelines-checker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants