@@ -12,7 +12,7 @@ class InfrahubObjectFileData(BaseModel):
1212 data : list [dict [str , Any ]] = Field (default_factory = list )
1313
1414 @classmethod
15- def enrich_node (cls , data : dict ) -> dict :
15+ def enrich_node (cls , data : dict , context : dict ) -> dict :
1616 return data
1717
1818 @classmethod
@@ -52,13 +52,19 @@ async def create_node(
5252 remaining_rels .append (key )
5353
5454 if context :
55- clean_data .update (context )
55+ clean_context = {
56+ ckey : cvalue
57+ for ckey , cvalue in context .items ()
58+ if ckey in schema .relationship_names + schema .attribute_names
59+ }
60+ clean_data .update (clean_context )
5661
57- clean_data = cls .enrich_node (data = clean_data )
62+ clean_data = cls .enrich_node (data = clean_data , context = context or {} )
5863
5964 node = await client .create (kind = schema .kind , branch = branch , data = clean_data )
6065 await node .save (allow_upsert = True )
61- print (f"Created Node: { node .get_human_friendly_id_as_string ()} " )
66+ display_label = node .get_human_friendly_id_as_string () or f"{ node .get_kind ()} : { node .id } "
67+ client .log .info (f"Node: { display_label } " )
6268
6369 for rel in remaining_rels :
6470 # identify what is the name of the relationship on the other side
@@ -90,7 +96,8 @@ async def create_node(
9096 )
9197
9298 elif rel_schema .cardinality == "many" and isinstance (rel_data , list ):
93- for peer_data in rel_data :
99+ for idx , peer_data in enumerate (rel_data ):
100+ context ["list_index" ] = idx
94101 await cls .create_node (
95102 client = client ,
96103 schema = peer_schema ,
0 commit comments