Repository navigation
Conversation
Custom tasks could not use a language or input type that WorkRB does not ship, because both enums were closed (reported in #56, which proposed dropping the Enum base). Keep the enums and add a register() classmethod to both instead, e.g. Language.register("sw"), as agreed on the issue. Registered values resolve through the normal Language("sw") lookup, so no task or model code changes. Unregistered values still raise ValueError, and non-lowercase values are rejected so case variants cannot become separate result rows. Existing members and behaviour are unchanged. Registered values do not appear when iterating the enum. Also update the custom task example and docs, including how to define a custom task group by subclassing BaseTaskGroup. Closes #56
Collaborator
Author
|
Converted your issue to a PR. What are your thoughts on this? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Custom tasks could not use a language or input type that WorkRB does not ship, because
LanguageandModelInputTypewere closed enums (#56).This keeps both enums and adds a
register()classmethod, as agreed on the issue:Language("sw")lookup, so no task or model code changes. Everything is contained insrc/workrb/types.py.ValueError, so typos such aslanguages=["deu"]are still caught.Limitations
register()once at import time.list(Language)), and"sw" in Languagedoes not reliably see them across Python versions. UseLanguage("sw")to check a value.Docs and example
BaseTaskGroup.examples/custom_task_example.pynow uses a registered input type and its own task group.Testing
tests/test_types.pycovers lookup, idempotent registration, isolation between the two enums, rejected values, pickling, and a task that uses a registered language, input type and custom task group.poe lintpasses.Closes #56