@@ -85,7 +85,6 @@ def artifact_linker(
85
85
model : Optional [Model ] = None ,
86
86
is_model_artifact : bool = False ,
87
87
is_deployment_artifact : bool = False ,
88
- do_link : bool = True ,
89
88
) -> None :
90
89
"""Step linking an artifact to a model via function or implicit."""
91
90
@@ -96,7 +95,7 @@ def artifact_linker(
96
95
is_deployment_artifact = is_deployment_artifact ,
97
96
)
98
97
99
- if do_link :
98
+ if model :
100
99
link_artifact_to_model (
101
100
artifact_version_id = artifact .id ,
102
101
model = model ,
@@ -502,9 +501,7 @@ def my_pipeline(is_consume: bool):
502
501
def test_link_artifact_via_function (self , clean_client : "Client" ):
503
502
"""Test that user can link artifacts via function to a model version."""
504
503
505
- @pipeline (
506
- enable_cache = False ,
507
- )
504
+ @pipeline
508
505
def _inner_pipeline (
509
506
model : Model = None ,
510
507
is_model_artifact : bool = False ,
@@ -520,46 +517,48 @@ def _inner_pipeline(
520
517
name = MODEL_NAME ,
521
518
)
522
519
523
- # no context, no model
524
- with pytest .raises (RuntimeError ):
525
- _inner_pipeline ()
520
+ # no context, no model, artifact produced but not linked
521
+ _inner_pipeline ()
522
+ artifact = clean_client .get_artifact_version ("manual_artifact" )
523
+ assert int (artifact .version ) == 1
526
524
527
- # use context
525
+ # pipeline will run in a model context and will use cached step version
528
526
_inner_pipeline .with_options (model = mv_in_pipe )()
529
527
530
528
mv = Model (name = MODEL_NAME , version = "latest" )
531
529
assert mv .number == 1
532
- assert mv .get_artifact ("manual_artifact" ).load () == "Hello, World!"
530
+ artifact = mv .get_artifact ("manual_artifact" )
531
+ assert artifact .load () == "Hello, World!"
532
+ assert int (artifact .version ) == 1
533
533
534
- # use custom model version
534
+ # use custom model version (cache invalidated)
535
535
_inner_pipeline (model = Model (name = "custom_model_version" ))
536
536
537
537
mv_custom = Model (name = "custom_model_version" , version = "latest" )
538
538
assert mv_custom .number == 1
539
- assert (
540
- mv_custom . get_artifact ( "manual_artifact" ) .load () == "Hello, World!"
541
- )
539
+ artifact = mv_custom . get_artifact ( "manual_artifact" )
540
+ assert artifact .load () == "Hello, World!"
541
+ assert int ( artifact . version ) == 2
542
542
543
- # use context + model
543
+ # use context + model (cache invalidated)
544
544
_inner_pipeline .with_options (model = mv_in_pipe )(is_model_artifact = True )
545
545
546
546
mv = Model (name = MODEL_NAME , version = "latest" )
547
547
assert mv .number == 2
548
- assert (
549
- mv . get_model_artifact ( "manual_artifact" ) .load () == "Hello, World!"
550
- )
548
+ artifact = mv . get_artifact ( "manual_artifact" )
549
+ assert artifact .load () == "Hello, World!"
550
+ assert int ( artifact . version ) == 3
551
551
552
- # use context + deployment
552
+ # use context + deployment (cache invalidated)
553
553
_inner_pipeline .with_options (model = mv_in_pipe )(
554
554
is_deployment_artifact = True
555
555
)
556
556
557
557
mv = Model (name = MODEL_NAME , version = "latest" )
558
558
assert mv .number == 3
559
- assert (
560
- mv .get_deployment_artifact ("manual_artifact" ).load ()
561
- == "Hello, World!"
562
- )
559
+ artifact = mv .get_deployment_artifact ("manual_artifact" )
560
+ assert artifact .load () == "Hello, World!"
561
+ assert int (artifact .version ) == 4
563
562
564
563
# link outside of a step
565
564
artifact = save_artifact (data = "Hello, World!" , name = "manual_artifact" )
@@ -570,7 +569,9 @@ def _inner_pipeline(
570
569
571
570
mv = Model (name = MODEL_NAME , version = "latest" )
572
571
assert mv .number == 4
573
- assert mv .get_artifact ("manual_artifact" ).load () == "Hello, World!"
572
+ artifact = mv .get_artifact ("manual_artifact" )
573
+ assert artifact .load () == "Hello, World!"
574
+ assert int (artifact .version ) == 5
574
575
575
576
def test_link_artifact_via_save_artifact (self , clean_client : "Client" ):
576
577
"""Test that artifacts are auto-linked to a model version on call of `save_artifact`."""
@@ -585,7 +586,6 @@ def _inner_pipeline(
585
586
artifact_linker (
586
587
is_model_artifact = is_model_artifact ,
587
588
is_deployment_artifact = is_deployment_artifact ,
588
- do_link = False ,
589
589
)
590
590
591
591
mv_in_pipe = Model (
0 commit comments