1
1
import re
2
+ import tempfile
2
3
import uuid
3
4
from itertools import tee
4
5
from pathlib import Path
@@ -374,13 +375,15 @@ def test_component_update(self, client: MLClient, randstr: Callable[[str], str])
374
375
@pytest .mark .disable_mock_code_hash
375
376
@pytest .mark .skipif (condition = not is_live (), reason = "reuse test, target to verify service-side behavior" )
376
377
def test_component_create_twice_same_code_arm_id (
377
- self , client : MLClient , randstr : Callable [[str ], str ], tmp_path : Path
378
+ self , client : MLClient , randstr : Callable [[str ], str ]
378
379
) -> None :
379
- component_name = randstr ("component_name" )
380
- # create new component to prevent the issue when same component code got created at the same time
381
- component_path = tmp_path / "component.yml"
382
- component_path .write_text (
383
- f"""
380
+ with tempfile .TemporaryDirectory () as tmp_path :
381
+ tmp_path = Path (tmp_path )
382
+ component_name = randstr ("component_name" )
383
+ # create new component to prevent the issue when same component code got created at the same time
384
+ component_path = tmp_path / "component.yml"
385
+ component_path .write_text (
386
+ f"""
384
387
$schema: https://azuremlschemas.azureedge.net/development/commandComponent.schema.json
385
388
name: { component_name }
386
389
version: 1
@@ -389,13 +392,13 @@ def test_component_create_twice_same_code_arm_id(
389
392
command: echo Hello World
390
393
code: "."
391
394
environment: azureml:AzureML-sklearn-0.24-ubuntu18.04-py37-cpu:1"""
392
- )
393
- # create a component
394
- component_resource1 = create_component (client , component_name , path = component_path )
395
- # create again
396
- component_resource2 = create_component (client , component_name , path = component_path )
397
- # the code arm id should be the same
398
- assert component_resource1 .code == component_resource2 .code
395
+ )
396
+ # create a component
397
+ component_resource1 = create_component (client , component_name , path = component_path )
398
+ # create again
399
+ component_resource2 = create_component (client , component_name , path = component_path )
400
+ # the code arm id should be the same
401
+ assert component_resource1 .code == component_resource2 .code
399
402
400
403
@pytest .mark .skipif (condition = not is_live (), reason = "non-deterministic upload fails in playback on CI" )
401
404
def test_component_update_code (self , client : MLClient , randstr : Callable [[str ], str ], tmp_path : Path ) -> None :
@@ -622,7 +625,7 @@ def test_command_component_get_latest_label(self, client: MLClient, randstr: Cal
622
625
623
626
for version in versions :
624
627
create_component (client , name , params_override = [{"version" : version }])
625
- sleep_if_live (1 )
628
+ sleep_if_live (5 )
626
629
assert client .components .get (name , label = "latest" ).version == version
627
630
628
631
@pytest .mark .skip (reason = "Test fails because MFE index service consistency bug" )
0 commit comments