"src/diffusers/models/attention2d.py" did not exist on "d8287fcd1d94f33df55b54e2e1c140c2ab15b444"
Unverified Commit 34b563b1 authored by Paul McCann's avatar Paul McCann Committed by GitHub
Browse files

Don't silence errors when loading tasks (#1148)



* Add example failing task

This task includes an invalid import. This will cause an exception and
the task will not be loaded. But this just results in a DEBUG level log
message, so in normal usage you'll see no error, and will be told the
task doesn't exist.

Here's an example command line to run the task:

    python -m lm_eval --model hf --model_args pretrained=rinna/japanese-gpt-1b --tasks fail

This task is based on a Japanese Winograd task, but that's not
important, and was just used due to familiarity.

* Do not ignore errors when loading tasks

* Change how task errors are logged

This makes the proposed changes from PR discussion.

1. Exceptions not related to missing modules/imports are logged as
   warnings.

2. module/import related exceptions are still logged at debug level, but
   if any of them happen there is a warning about it with instructions
   on how to show logs.

* Remove intentionally failing task

---------
Co-authored-by: default avatarPaul O'Leary McCann <polm@dampfkraft.com>
parent 46c79664
...@@ -131,6 +131,9 @@ def include_task_folder(task_dir: str, register_task: bool = True) -> None: ...@@ -131,6 +131,9 @@ def include_task_folder(task_dir: str, register_task: bool = True) -> None:
""" """
Calling this function Calling this function
""" """
# Track whether any tasks failed during loading
import_fail = False
for root, subdirs, file_list in os.walk(task_dir): for root, subdirs, file_list in os.walk(task_dir):
# if (subdirs == [] or subdirs == ["__pycache__"]) and (len(file_list) > 0): # if (subdirs == [] or subdirs == ["__pycache__"]) and (len(file_list) > 0):
for f in file_list: for f in file_list:
...@@ -155,20 +158,27 @@ def include_task_folder(task_dir: str, register_task: bool = True) -> None: ...@@ -155,20 +158,27 @@ def include_task_folder(task_dir: str, register_task: bool = True) -> None:
# Log this silently and show it only when # Log this silently and show it only when
# the user defines the appropriate verbosity. # the user defines the appropriate verbosity.
except ModuleNotFoundError as e: except (ImportError, ModuleNotFoundError) as e:
import_fail = True
eval_logger.debug( eval_logger.debug(
f"{yaml_path}: {e}. Config will not be added to registry." f"{yaml_path}: {e}. Config will not be added to registry."
) )
except Exception as error: except Exception as error:
import traceback import traceback
eval_logger.debug( eval_logger.warning(
"Failed to load config in\n" "Unexpected error loading config in\n"
f" {yaml_path}\n" f" {yaml_path}\n"
" Config will not be added to registry\n" " Config will not be added to registry\n"
f" Error: {error}\n" f" Error: {error}\n"
f" Traceback: {traceback.format_exc()}" f" Traceback: {traceback.format_exc()}"
) )
if import_fail:
eval_logger.warning(
"Some tasks could not be loaded due to missing dependencies."
" Run with `--verbosity DEBUG` for full details."
)
return 0 return 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment