Skip to content

fix tasks list #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alielfilali01
Copy link
Contributor

feat(tasks): Enhance task discovery and display. Bug mentioned here: #903

This PR improves the task registry to ensure all available task suites, including community, custom, test suites ... are correctly discovered and displayed in the lighteval tasks list command.

The key changes include:

  • Dynamic Community Task Loading: the new function (load_community_tasks) is to dynamically scan the community_tasks directory and load any valid task modules. This process is resilient, as it gracefully handles and logs errors for any malformed task files without interrupting the loading of others.

  • Lazy Loading for Multilingual Tasks: The import for multilingual tasks is now deferred until the task registry is accessed. This prevents crashes when optional dependencies (like langcodes) are not installed and instead logs a helpful warning.

  • Comprehensive Suite Display: The print_all_tasks function has been updated to guarantee that all DEFAULT_SUITES (including custom and test) are always visible in the output, even if they contain no tasks. A "(no tasks in this suite)" message is now shown for empty suites to improve clarity.

These changes provide a more robust and complete discovery mechanism, giving users a reliable view of all available tasks in lighteval.

Before these changes, the command lighteval tasks list used to return about 1500 lines (tasks).
After these changes, the command lighteval tasks list now returns more than 74200 lines (tasks).

add `langcodes` for the multilingual extra group
feat(tasks): Enhance task discovery and display

This commit improves the task registry to ensure all available task suites, including community, multilingual, custom, and test suites, are correctly discovered and displayed in the `lighteval tasks list` command.
@alielfilali01
Copy link
Contributor Author

++ @clefourrier

@alielfilali01
Copy link
Contributor Author

@Winlere check this out if it works for you ?

@HuggingFaceDocBuilderDev
Copy link
Collaborator

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

# Community tasks are in the lighteval directory, not under src
import sys
import os
community_path = os.path.join(os.path.dirname(__file__), "..", "..", "..", "community_tasks")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
community_path = os.path.join(os.path.dirname(__file__), "..", "..", "..", "community_tasks")
community_path = Path(__file__).parent.parent.parent / "community_tasks"

Comment on lines +47 to +48
import sys
import os
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they should be imported at the top of the file.

import sys
import os
community_path = os.path.join(os.path.dirname(__file__), "..", "..", "..", "community_tasks")
if os.path.exists(community_path):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if os.path.exists(community_path):
if not community_path.exists():

Copy link
Member

@NathanHB NathanHB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR !
Overall looks good, i tested it and it works great. Only thing would be to make the code clearer and using pathlib would be cleaner here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants