Skip to content

Add delete method to JobOperations#46787

Open
lavakumarrepala wants to merge 2 commits intomainfrom
v-rlava/add-deletemethiodinjobops
Open

Add delete method to JobOperations#46787
lavakumarrepala wants to merge 2 commits intomainfrom
v-rlava/add-deletemethiodinjobops

Conversation

@lavakumarrepala
Copy link
Copy Markdown
Member

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.

: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.
: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,
)

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:

  • 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.

Add unit test for delete operation in JobOperations.
Copilot AI review requested due to automatic review settings May 7, 2026 23:42
@lavakumarrepala lavakumarrepala changed the title V rlava/add deletemethiodinjobops Add delete method to JobOperations May 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_delete call 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,
)
@kingernupur
Copy link
Copy Markdown
Member

@lavakumarrepala Add changelog for this PR

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.

3 participants