@@ -267,32 +267,29 @@ def _parse_entry(entry: str, cwd: str) -> tuple[str, str]:
267267def _resolve_entry_to_qual_and_source (entry : str , cwd : str ) -> tuple [str , str ]:
268268 target , func = _parse_entry (entry , cwd )
269269
270- # Check if target looks like a file path
270+ # Determine the file path to load
271271 if "/" in target or "\\ " in target or os .path .exists (target ):
272- # It's a file path - convert to absolute and load as module
272+ # It's a file path - convert to absolute
273273 if not os .path .isabs (target ):
274274 target = os .path .abspath (os .path .join (cwd , target ))
275-
276275 if not target .endswith (".py" ):
277276 target = target + ".py"
278-
279277 if not os .path .isfile (target ):
280278 raise ValueError (f"File not found: { target } " )
281-
282- # Import module from file path
283- spec = importlib .util .spec_from_file_location (Path (target ).stem , target )
284- if not spec or not spec .loader :
285- raise ValueError (f"Unable to load module from path: { target } " )
286- module = importlib .util .module_from_spec (spec )
287- sys .modules [spec .name ] = module
288- spec .loader .exec_module (module ) # type: ignore[attr-defined]
289- module_name = spec .name
290279 source_file_path = target
291280 else :
292- # Treat as module path (e.g., "my_package.my_module")
293- module_name = target
294- module = importlib .import_module (module_name )
295- source_file_path = getattr (module , "__file__" , "" ) or ""
281+ # Treat dotted name as a file path
282+ dotted_as_path = target .replace ("." , "/" ) + ".py"
283+ source_file_path = os .path .join (cwd , dotted_as_path )
284+
285+ # Load the module from the file path
286+ spec = importlib .util .spec_from_file_location (Path (source_file_path ).stem , source_file_path )
287+ if not spec or not spec .loader :
288+ raise ValueError (f"Unable to load module from path: { source_file_path } " )
289+ module = importlib .util .module_from_spec (spec )
290+ sys .modules [spec .name ] = module
291+ spec .loader .exec_module (module ) # type: ignore[attr-defined]
292+ module_name = spec .name
296293
297294 if not hasattr (module , func ):
298295 raise ValueError (f"Function '{ func } ' not found in module '{ module_name } '" )
@@ -591,8 +588,7 @@ def upload_command(args: argparse.Namespace) -> int:
591588
592589 print (f"\n Uploading evaluator '{ evaluator_id } ' for { qualname .split ('.' )[- 1 ]} ..." )
593590 try :
594- # Always treat as a single evaluator (single-metric) even if folder has helper modules
595- test_dir = os .path .dirname (source_file_path ) if source_file_path else root
591+ test_dir = root
596592 metric_name = os .path .basename (test_dir ) or "metric"
597593 result = create_evaluation (
598594 evaluator_id = evaluator_id ,
0 commit comments