Migrate AzureBatchHook/Operator to azure-batch 15.x (track 2 SDK)#67600
Open
arieleli01212 wants to merge 2 commits into
Open
Migrate AzureBatchHook/Operator to azure-batch 15.x (track 2 SDK)#67600arieleli01212 wants to merge 2 commits into
arieleli01212 wants to merge 2 commits into
Conversation
…ack 2 SDK) The azure-batch package 15.x is a ground-up rewrite of the Azure SDK for Batch. The old BatchServiceClient and batch_auth module are gone; the new SDK exposes a flat BatchClient that uses azure-identity / AzureNamedKeyCredential. Changes: - Replace BatchServiceClient with BatchClient(endpoint, credential) - Replace batch_auth.SharedKeyCredentials with AzureNamedKeyCredential - Catch ResourceExistsError (azure.core) instead of BatchErrorException - Rename model types: PoolAddParameter → BatchPoolCreateOptions, JobAddParameter → BatchJobCreateOptions, TaskAddParameter → BatchTaskCreateOptions, ImageReference → BatchVmImageReference, PoolInformation → BatchPoolInfo, and Batch-prefixed task/job sub-types - Rename enums: ComputeNodeState → BatchNodeState, TaskState → BatchTaskState, TaskExecutionResult → BatchTaskExecutionResult (SCREAMING_SNAKE_CASE values) - Replace pool.list / compute_node.list / job.list / task.list hierarchy with flat client.list_nodes / list_tasks / list_jobs / list_supported_images calls - Use LRO methods begin_delete_pool / begin_delete_job / begin_terminate_job - Remove CloudServiceConfiguration support (Azure removed cloud-service VMs) - Drop os_family / os_version parameters from AzureBatchOperator (no longer applicable without CloudServiceConfiguration) - Lift azure-batch version cap from <15.0.0 to >=15.0.0 in pyproject.toml - Update all unit tests to use the new SDK classes and method signatures Closes apache#66466
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
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
The
azure-batchpackage underwent a complete API overhaul in version 15.x, moving from the old Azure SDK track 1 (BatchServiceClient,batch_auth) to track 2 (BatchClient, azure-identity). This PR updatesAzureBatchHookandAzureBatchOperatorto work with the new SDK and removes the<15.0.0upper bound cap that was explicitly blocking users from upgrading.Changes
hooks/batch.pyBatchServiceClientwithBatchClient(endpoint, credential)batch_auth.SharedKeyCredentialswithAzureNamedKeyCredentialResourceExistsError(fromazure.core.exceptions) instead ofBatchErrorExceptionPoolAddParameter→BatchPoolCreateOptions,JobAddParameter→BatchJobCreateOptions,TaskAddParameter→BatchTaskCreateOptions,ImageReference→BatchVmImageReference,PoolInformation→BatchPoolInfoBatchNodeState.IDLE,BatchTaskState.COMPLETED,BatchTaskExecutionResult.FAILUREclient.pool.add,client.compute_node.list, etc.) with the new flat API (client.create_pool,client.list_nodes, etc.)begin_delete_pool,begin_delete_job,begin_terminate_jobCloudServiceConfigurationsupport — Azure has retired cloud-service VM poolsoperators/batch.pybatch_job_manager_task,batch_job_preparation_task, etc. to use the newBatch-prefixed namesos_familyandos_versionparameters (no longer applicable withoutCloudServiceConfiguration)BatchNodeState.START_TASK_FAILED / UNUSABLE / IDLEon_kill()andclean_up()to use the LRO methodspyproject.tomlazure-batchconstraint from>=8.0.0,<15.0.0to>=15.0.0Tests
BatchClient, model types, and enum valuesRelates
Fixes the blocking comment left in
pyproject.tomlabout needing a hook rewrite before lifting the<15.0.0cap.closes: #66466
Testing
pytest providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_batch.pyand all tests passpytest providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_batch.pyand all tests pass