44
55from typing import Any
66
7+ from bloom_lims .domain .v0_graph import attach_bloom_v0_edge , object_evidence
78from bloom_lims .tapdb_adapter import get_child_lineages , get_parent_lineages
89from bloom_lims .template_identity import instance_semantic_category
910
@@ -22,9 +23,81 @@ class _BetaLabReferenceMixin:
2223 "beta_pool_member" ,
2324 "beta_sequenced_library_assignment" ,
2425 "beta_sequencing_run" ,
26+ "HOLDS_MATERIAL" ,
27+ "RUN_CONSUMED" ,
28+ "RUN_PRODUCED" ,
29+ "DERIVED_FROM" ,
2530 }
2631 )
2732
33+ def _attach_v0_edge_to_lineage (
34+ self ,
35+ lineage ,
36+ * ,
37+ edge_type : str ,
38+ source_euid : str ,
39+ target_euid : str ,
40+ source_role : str ,
41+ target_role : str ,
42+ evidence_refs : list [dict [str , Any ]],
43+ correlation_id : str ,
44+ causation_id : str ,
45+ source_system : str = "bloom" ,
46+ target_system : str = "bloom" ,
47+ ):
48+ return attach_bloom_v0_edge (
49+ lineage ,
50+ edge_type = edge_type ,
51+ source_euid = source_euid ,
52+ target_euid = target_euid ,
53+ source_role = source_role ,
54+ target_role = target_role ,
55+ source_system = source_system ,
56+ target_system = target_system ,
57+ evidence_refs = evidence_refs ,
58+ correlation_id = correlation_id ,
59+ causation_id = causation_id ,
60+ )
61+
62+ def _attach_bloom_v0_lineage (
63+ self ,
64+ parent_euid : str ,
65+ child_euid : str ,
66+ * ,
67+ relationship_type : str ,
68+ edge_type : str ,
69+ source_euid : str ,
70+ target_euid : str ,
71+ source_role : str ,
72+ target_role : str ,
73+ source_system : str = "bloom" ,
74+ target_system : str = "bloom" ,
75+ extra_evidence_refs : list [dict [str , Any ]] | None = None ,
76+ ):
77+ lineage = self .bobj .create_generic_instance_lineage_by_euids (
78+ parent_euid ,
79+ child_euid ,
80+ relationship_type = relationship_type ,
81+ )
82+ evidence_refs = [
83+ object_evidence (parent_euid , role = "tapdb_lineage_parent" ),
84+ object_evidence (child_euid , role = "tapdb_lineage_child" ),
85+ * (extra_evidence_refs or []),
86+ ]
87+ return self ._attach_v0_edge_to_lineage (
88+ lineage ,
89+ edge_type = edge_type ,
90+ source_euid = source_euid ,
91+ target_euid = target_euid ,
92+ source_role = source_role ,
93+ target_role = target_role ,
94+ source_system = source_system ,
95+ target_system = target_system ,
96+ evidence_refs = evidence_refs ,
97+ correlation_id = f"{ relationship_type } :{ parent_euid } :{ child_euid } " ,
98+ causation_id = f"bloom:{ relationship_type } :{ parent_euid } :{ child_euid } " ,
99+ )
100+
28101 def _resolve_fulfillment_item_context (
29102 self ,
30103 instance ,
@@ -367,11 +440,38 @@ def _replace_fulfillment_item_references(
367440 self .EXTERNAL_REFERENCE_TEMPLATE_CODE ,
368441 {"json_addl" : {"properties" : properties }},
369442 )
370- self .bobj .create_generic_instance_lineage_by_euids (
443+ lineage = self .bobj .create_generic_instance_lineage_by_euids (
371444 instance .euid ,
372445 ref_obj .euid ,
373446 relationship_type = self .EXTERNAL_REFERENCE_RELATIONSHIP ,
374447 )
448+ self ._attach_v0_edge_to_lineage (
449+ lineage ,
450+ edge_type = "SLOT_SATISFIED_BY" ,
451+ source_euid = atlas_fulfillment_slot_euid ,
452+ target_euid = instance .euid ,
453+ source_role = "fulfillment_slot" ,
454+ target_role = "satisfying_bloom_object" ,
455+ source_system = "atlas" ,
456+ target_system = "bloom" ,
457+ evidence_refs = [
458+ object_evidence (
459+ atlas_fulfillment_slot_euid ,
460+ role = "fulfillment_slot" ,
461+ system = "atlas" ,
462+ ),
463+ object_evidence (instance .euid , role = "satisfying_bloom_object" ),
464+ object_evidence (ref_obj .euid , role = "atlas_reference_link" ),
465+ ],
466+ correlation_id = (
467+ f"SLOT_SATISFIED_BY:{ atlas_fulfillment_slot_euid } :"
468+ f"{ instance .euid } "
469+ ),
470+ causation_id = (
471+ f"bloom:atlas_fulfillment_reference:"
472+ f"{ atlas_fulfillment_slot_euid } :{ instance .euid } "
473+ ),
474+ )
375475 self ._sync_atlas_tapdb_graph_refs (
376476 instance , additional_payloads = created_payloads
377477 )
0 commit comments