@@ -350,25 +350,86 @@ def test_create_without_created_by(self, session_factory, service):
350350 result = _create_run (session_factory , service , root_task = _make_task_spec ())
351351 assert result .created_by is None
352352
353- def test_create_writes_created_by_annotation (self , session_factory , service ):
353+ def test_create_mirrors_name_and_created_by (self , session_factory , service ):
354354 run = _create_run (
355355 session_factory ,
356356 service ,
357- root_task = _make_task_spec (),
358- created_by = "alice@example.com " ,
357+ root_task = _make_task_spec ("my-pipeline" ),
358+ created_by = "alice" ,
359359 )
360360 with session_factory () as session :
361361 annotations = service .list_annotations (session = session , id = run .id )
362- assert annotations [filter_query_sql .SystemKey .CREATED_BY ] == "alice@example.com"
362+ assert annotations [filter_query_sql .SystemKey .NAME ] == "my-pipeline"
363+ assert annotations [filter_query_sql .SystemKey .CREATED_BY ] == "alice"
363364
364- def test_create_without_created_by_no_annotation (self , session_factory , service ):
365- run = _create_run (session_factory , service , root_task = _make_task_spec ())
365+ def test_create_mirrors_name_only (self , session_factory , service ):
366+ run = _create_run (
367+ session_factory ,
368+ service ,
369+ root_task = _make_task_spec ("solo-pipeline" ),
370+ )
366371 with session_factory () as session :
367372 annotations = service .list_annotations (session = session , id = run .id )
373+ assert annotations [filter_query_sql .SystemKey .NAME ] == "solo-pipeline"
374+ assert filter_query_sql .SystemKey .CREATED_BY not in annotations
375+
376+ def test_create_mirrors_created_by_only (self , session_factory , service ):
377+ task_spec = _make_task_spec ("placeholder" )
378+ task_spec .component_ref .spec .name = None
379+ run = _create_run (
380+ session_factory , service , root_task = task_spec , created_by = "alice"
381+ )
382+ with session_factory () as session :
383+ annotations = service .list_annotations (session = session , id = run .id )
384+ assert annotations [filter_query_sql .SystemKey .CREATED_BY ] == "alice"
385+ assert filter_query_sql .SystemKey .NAME not in annotations
386+
387+ def test_create_skips_mirror_when_empty_values (self , session_factory , service ):
388+ run = _create_run (
389+ session_factory ,
390+ service ,
391+ root_task = _make_task_spec ("" ),
392+ created_by = "" ,
393+ )
394+ with session_factory () as session :
395+ annotations = service .list_annotations (session = session , id = run .id )
396+ assert filter_query_sql .SystemKey .NAME not in annotations
397+ assert filter_query_sql .SystemKey .CREATED_BY not in annotations
398+
399+ def test_create_skips_mirror_when_both_absent (self , session_factory , service ):
400+ task_spec = _make_task_spec ("placeholder" )
401+ task_spec .component_ref .spec .name = None
402+ run = _create_run (session_factory , service , root_task = task_spec )
403+ with session_factory () as session :
404+ annotations = service .list_annotations (session = session , id = run .id )
405+ assert filter_query_sql .SystemKey .NAME not in annotations
368406 assert filter_query_sql .SystemKey .CREATED_BY not in annotations
369407
370408
371409class TestPipelineRunAnnotationCrud :
410+ def test_system_annotations_coexist_with_user_annotations (
411+ self , session_factory , service
412+ ):
413+ run = _create_run (
414+ session_factory ,
415+ service ,
416+ root_task = _make_task_spec ("my-pipeline" ),
417+ created_by = "alice" ,
418+ )
419+ with session_factory () as session :
420+ service .set_annotation (
421+ session = session ,
422+ id = run .id ,
423+ key = "team" ,
424+ value = "ml-ops" ,
425+ user_name = "alice" ,
426+ )
427+ with session_factory () as session :
428+ annotations = service .list_annotations (session = session , id = run .id )
429+ assert annotations ["team" ] == "ml-ops"
430+ assert annotations [filter_query_sql .SystemKey .NAME ] == "my-pipeline"
431+ assert annotations [filter_query_sql .SystemKey .CREATED_BY ] == "alice"
432+
372433 def test_set_annotation (self , session_factory , service ):
373434 run = _create_run (
374435 session_factory ,
@@ -441,11 +502,11 @@ def test_delete_annotation(self, session_factory, service):
441502 annotations = service .list_annotations (session = session , id = run .id )
442503 assert "team" not in annotations
443504
444- def test_list_annotations_empty (self , session_factory , service ):
505+ def test_list_annotations_only_system (self , session_factory , service ):
445506 run = _create_run (session_factory , service , root_task = _make_task_spec ())
446507 with session_factory () as session :
447508 annotations = service .list_annotations (session = session , id = run .id )
448- assert annotations == {}
509+ assert annotations == {filter_query_sql . SystemKey . NAME : "test-pipeline" }
449510
450511 def test_set_annotation_rejects_system_key (self , session_factory , service ):
451512 run = _create_run (
0 commit comments