Skip to content

Commit b044d59

Browse files
jayesh-tannaJayesh Tanna
andauthored
Adding test recording for pause, resume and deployment finetuning fea… (#44428)
* Adding test recording for pause, resume and deployment finetuning features * adding islive condition --------- Co-authored-by: Jayesh Tanna <[email protected]>
1 parent e7688a8 commit b044d59

File tree

4 files changed

+19
-39
lines changed

4 files changed

+19
-39
lines changed

sdk/ai/azure-ai-projects/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ai/azure-ai-projects",
5-
"Tag": "python/ai/azure-ai-projects_1d985f7ba5"
5+
"Tag": "python/ai/azure-ai-projects_5b7a7fa09e"
66
}

sdk/ai/azure-ai-projects/tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ def sanitize_url_paths():
111111
# Sanitize fine-tuning job IDs in URLs and response bodies
112112
add_general_regex_sanitizer(regex=r"ftjob-[a-f0-9]+", value="sanitized-ftjob-id")
113113

114+
# Sanitize deployment names that are derived from job IDs (e.g., test-6158cfe2)
115+
add_general_regex_sanitizer(regex=r"test-[a-f0-9]{8}", value="test-ftjob-id")
116+
114117
# Sanitize file IDs in URLs and response bodies
115118
add_general_regex_sanitizer(regex=r"file-[a-f0-9]+", value="sanitized-file-id")
116119

@@ -160,3 +163,11 @@ def sanitize_url_paths():
160163
# - AZSDK3430: $..id
161164
remove_batch_sanitizers(["AZSDK3493"])
162165
remove_batch_sanitizers(["AZSDK3430"])
166+
167+
# Sanitize ARM operation headers that contain certificates and identifiers
168+
add_general_regex_sanitizer(regex=r"[?&]t=[0-9]+", value="&t=sanitized-timestamp")
169+
add_general_regex_sanitizer(regex=r"[?&]c=[^&\"]+", value="&c=sanitized-certificate")
170+
add_general_regex_sanitizer(regex=r"[?&]s=[^&\"]+", value="&s=sanitized-signature")
171+
add_general_regex_sanitizer(regex=r"[?&]h=[^&\"]+", value="&h=sanitized-hash")
172+
add_general_regex_sanitizer(regex=r"operationResults/[a-f0-9\-]+", value="operationResults/sanitized-operation-id")
173+
add_general_regex_sanitizer(regex=r"https://management\.azure\.com/", value="https://sanitized.azure.com/")

sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from devtools_testutils import (
2121
recorded_by_proxy,
2222
RecordedTransport,
23-
is_live_and_not_recording,
23+
is_live
2424
)
2525
from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient
2626
from azure.mgmt.cognitiveservices.models import Deployment, DeploymentProperties, DeploymentModel, Sku
@@ -346,8 +346,9 @@ def _test_deploy_and_infer_helper(
346346
print(f"[{test_prefix}] Deployment status: {deployment_operation.status()}")
347347

348348
print(f"[{test_prefix}] Deployment completed successfully")
349-
print(f"[{test_prefix}] Waiting for 120 seconds for deployment to be fully ready.")
350-
time.sleep(120)
349+
if is_live():
350+
print(f"[{test_prefix}] Waiting for 10 minutes for deployment to be fully ready.")
351+
time.sleep(600)
351352
print(f"[{test_prefix}] Testing inference on deployment: {deployment_name}")
352353

353354
response = openai_client.responses.create(
@@ -622,10 +623,6 @@ def test_finetuning_list_events(self, **kwargs):
622623
self._cleanup_test_file(openai_client, train_file.id)
623624
self._cleanup_test_file(openai_client, validation_file.id)
624625

625-
@pytest.mark.skipif(
626-
condition=(not is_live_and_not_recording()),
627-
reason="Skipped because not able to pause any job",
628-
)
629626
@servicePreparer()
630627
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
631628
def test_finetuning_pause_job(self, **kwargs):
@@ -658,10 +655,6 @@ def test_finetuning_pause_job(self, **kwargs):
658655

659656
print(f"[test_finetuning_pause_job] Successfully paused and verified job: {running_job_id}")
660657

661-
@pytest.mark.skipif(
662-
condition=(not is_live_and_not_recording()),
663-
reason="Skipped because not able to pause any job",
664-
)
665658
@servicePreparer()
666659
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
667660
def test_finetuning_resume_job(self, **kwargs):
@@ -733,10 +726,6 @@ def test_finetuning_list_checkpoints(self, **kwargs):
733726
f"[test_finetuning_list_checkpoints] Successfully validated {len(checkpoints_list)} checkpoints for job: {completed_job_id}"
734727
)
735728

736-
@pytest.mark.skipif(
737-
condition=(not is_live_and_not_recording()),
738-
reason="Skipped because API not sending completed or failed status despite job being complete",
739-
)
740729
@servicePreparer()
741730
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
742731
def test_finetuning_deploy_and_infer_oai_model_sft_job(self, **kwargs):
@@ -750,12 +739,8 @@ def test_finetuning_deploy_and_infer_oai_model_sft_job(self, **kwargs):
750739
**kwargs,
751740
)
752741

753-
@pytest.mark.skipif(
754-
condition=(not is_live_and_not_recording()),
755-
reason="Skipped because not able to complete any RFT job",
756-
)
757742
@servicePreparer()
758-
@recorded_by_proxy
743+
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
759744
def test_finetuning_deploy_and_infer_oai_model_rft_job(self, **kwargs):
760745
completed_job_id = kwargs.get("azure_ai_projects_tests_completed_oai_model_rft_fine_tuning_job_id")
761746
self._test_deploy_and_infer_helper(
@@ -767,10 +752,6 @@ def test_finetuning_deploy_and_infer_oai_model_rft_job(self, **kwargs):
767752
**kwargs,
768753
)
769754

770-
@pytest.mark.skipif(
771-
condition=(not is_live_and_not_recording()),
772-
reason="Skipped because API not sending completed or failed status despite job being complete",
773-
)
774755
@servicePreparer()
775756
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
776757
def test_finetuning_deploy_and_infer_oai_model_dpo_job(self, **kwargs):
@@ -784,10 +765,6 @@ def test_finetuning_deploy_and_infer_oai_model_dpo_job(self, **kwargs):
784765
**kwargs,
785766
)
786767

787-
@pytest.mark.skipif(
788-
condition=(not is_live_and_not_recording()),
789-
reason="Skipped because API not sending completed or failed status despite job being complete",
790-
)
791768
@servicePreparer()
792769
@recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
793770
def test_finetuning_deploy_and_infer_oss_model_sft_job(self, **kwargs):

sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning_async.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ async def _test_deploy_and_infer_helper_async(
351351
print(f"[{test_prefix}] Deployment status: {deployment_operation.status()}")
352352

353353
print(f"[{test_prefix}] Deployment completed successfully")
354-
print(f"[{test_prefix}] Waiting for 120 seconds for deployment to be fully ready.")
355-
await asyncio.sleep(120)
354+
print(f"[{test_prefix}] Waiting for 10 minutes for deployment to be fully ready.")
355+
await asyncio.sleep(600)
356356
print(f"[{test_prefix}] Testing inference on deployment: {deployment_name}")
357357

358358
response = await openai_client.responses.create(
@@ -654,10 +654,6 @@ async def test_finetuning_list_events_async(self, **kwargs):
654654
await self._cleanup_test_file_async(openai_client, train_file.id)
655655
await self._cleanup_test_file_async(openai_client, validation_file.id)
656656

657-
@pytest.mark.skipif(
658-
condition=(not is_live_and_not_recording()),
659-
reason="Skipped because not able to pause any job",
660-
)
661657
@servicePreparer()
662658
@recorded_by_proxy_async(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
663659
async def test_finetuning_pause_job_async(self, **kwargs):
@@ -691,10 +687,6 @@ async def test_finetuning_pause_job_async(self, **kwargs):
691687
print(f"[test_finetuning_pause_job] Job status after pause: {paused_job.status}")
692688
print(f"[test_finetuning_pause_job] Successfully paused and verified job: {running_job_id}")
693689

694-
@pytest.mark.skipif(
695-
condition=(not is_live_and_not_recording()),
696-
reason="Skipped because not able to pause any job",
697-
)
698690
@servicePreparer()
699691
@recorded_by_proxy_async(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX)
700692
async def test_finetuning_resume_job_async(self, **kwargs):

0 commit comments

Comments
 (0)