@@ -145,6 +145,13 @@ def index(self, source_obj: Any, target: Optional[str] = None) -> None:
145145 else :
146146 self .object_index = ObjectIndex (source_obj , schemaview = self .source_schemaview )
147147
148+ # Developer Note:
149+ # This method has grown large. When modifying it, consider extracting to
150+ # private methods and adding tests using the scaffold-based testing pattern.
151+ # See EXTRACT markers below for candidates.
152+ #
153+ # See: tests/README.md for testing guidance
154+ # Tracking: https://github.com/linkml/linkml-map/issues/104
148155 def map_object (
149156 self ,
150157 source_obj : OBJECT_TYPE ,
@@ -161,6 +168,7 @@ def map_object(
161168 :return: transformed data, either as type target_type or a dictionary
162169 """
163170 sv = self .source_schemaview
171+ # EXTRACT: _resolve_source_type(sv, source_obj) -> str
164172 if source_type is None and sv is None :
165173 # TODO: use smarter method
166174 source_type = next (iter (self .specification .class_derivations .values ())).name
@@ -227,6 +235,7 @@ def map_object(
227235 v = self ._perform_melt (
228236 slot_derivation .pivot_operation , source_obj , slot_derivation
229237 )
238+ # EXTRACT: _derive_from_expr(slot_derivation, source_obj, source_obj_typed, source_type, sv) -> Any
230239 elif slot_derivation .expr :
231240 if bindings is None :
232241 bindings = Bindings (
@@ -248,6 +257,7 @@ def map_object(
248257 aeval = Interpreter (usersyms = {"src" : ctxt_obj , "target" : None })
249258 aeval (slot_derivation .expr )
250259 v = aeval .symtable ["target" ]
260+ # EXTRACT: _derive_from_populated_from(slot_derivation, source_obj, sv, source_type) -> tuple[Any, SlotDefinition]
251261 elif slot_derivation .populated_from :
252262 populated_from = slot_derivation .populated_from
253263 fk_resolution = resolve_fk_path (sv , source_type , populated_from )
@@ -309,6 +319,7 @@ def map_object(
309319 logger .debug (
310320 f"Pop slot { slot_derivation .name } => { v } using { slot_derivation .populated_from } // { source_obj } "
311321 )
322+ # EXTRACT: _derive_from_object_derivations(slot_derivation, source_obj, source_type, target_type) -> Any
312323 elif slot_derivation .object_derivations :
313324 # We'll collect all derived objects here
314325 derived_objs = []
@@ -337,6 +348,7 @@ def map_object(
337348 else :
338349 source_class_slot = sv .induced_slot (slot_derivation .name , source_type )
339350 v = source_obj .get (slot_derivation .name , None )
351+ # EXTRACT: _post_process_slot_value(v, source_class_slot, slot_derivation, class_deriv) -> Any
340352 if source_class_slot and v is not None :
341353 # slot is mapped and there is a value in the assignment
342354 target_range = slot_derivation .range
0 commit comments