Add delete method to JobOperations#46787
Open
lavakumarrepala wants to merge 2 commits intomainfrom
Open
Conversation
Add unit test for delete operation in JobOperations.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a public job deletion operation to JobOperations and introduces a unit test intended to validate that the underlying REST begin_delete call is invoked with the correct scope parameters.
Changes:
- Add
JobOperations.delete(name, **kwargs)that forwards to_operation_2023_02_preview.begin_delete(...). - Add a unit test validating the
begin_deletecall arguments.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| sdk/ml/azure-ai-ml/azure/ai/ml/operations/_job_operations.py | Introduces a new delete API that returns an LRO poller and forwards parameters to the generated REST operation. |
| sdk/ml/azure-ai-ml/tests/job_common/unittests/test_job_operations.py | Adds a new unit test for the delete method’s wiring to begin_delete. |
Comment on lines
+269
to
+271
| def test_delete(self, mock_job_operation: JobOperations) -> None: | ||
| mock_job_operation.delete(name="random_name") | ||
| mock_job_operation._operation_2023_02_preview.begin_delete.assert_called_once() |
Comment on lines
+455
to
+473
| @distributed_trace | ||
| @monitor_with_telemetry_mixin(ops_logger, "Job.Delete", ActivityType.PUBLICAPI) | ||
| def delete(self, name: str, **kwargs: Any) -> LROPoller[None]: | ||
| """Deletes a job. | ||
|
|
||
| :param name: The name of the job. | ||
| :type name: str | ||
| :raises azure.core.exceptions.ResourceNotFoundError: Raised if no job with the given name can be found. | ||
| :raises azure.core.exceptions.HttpResponseError: Raised for other service-side errors. | ||
| :return: A poller to track the operation status. | ||
| :rtype: ~azure.core.polling.LROPoller[None] | ||
| """ | ||
| return self._operation_2023_02_preview.begin_delete( | ||
| id=name, | ||
| resource_group_name=self._operation_scope.resource_group_name, | ||
| workspace_name=self._workspace_name, | ||
| **self._kwargs, | ||
| **kwargs, | ||
| ) |
| workspace_name=self._workspace_name, | ||
| **self._kwargs, | ||
| **kwargs, | ||
| ) |
Member
|
@lavakumarrepala Add changelog for this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
_job_operations.py: Added delete(name, **kwargs) -> LROPoller[None] after begin_cancel, following the same decorator and parameter-passing patterns as sibling lifecycle methods (begin_cancel, archive, restore):
@distributed_trace
@monitor_with_telemetry_mixin(ops_logger, "Job.Delete", ActivityType.PUBLICAPI)
def delete(self, name: str, **kwargs: Any) -> LROPoller[None]:
"""Deletes a job.
test_job_operations.py: Added test_delete verifying begin_delete is called with the correct id, resource_group_name, and workspace_name.
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:
General Guidelines and Best Practices
Testing Guidelines