# This source code is licensed under the license found in the LICENSE file in
# This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
# can be found in the PATENTS file in the same directory.
importargparse
importimportlib
importimportlib
importos
importos
...
@@ -20,7 +20,26 @@ def setup_task(args):
...
@@ -20,7 +20,26 @@ def setup_task(args):
defregister_task(name):
defregister_task(name):
"""Decorator to register a new task."""
"""
New tasks can be added to fairseq with the
:func:`~fairseq.tasks.register_task` function decorator.
For example::
@register_task('classification')
class ClassificationTask(FairseqTask):
(...)
.. note::
All Tasks must implement the :class:`~fairseq.tasks.FairseqTask`
interface.
Please see the
Args:
name (str): the name of the task
"""
defregister_task_cls(cls):
defregister_task_cls(cls):
ifnameinTASK_REGISTRY:
ifnameinTASK_REGISTRY:
...
@@ -39,5 +58,17 @@ def register_task(name):
...
@@ -39,5 +58,17 @@ def register_task(name):
# automatically import any Python files in the tasks/ directory
# automatically import any Python files in the tasks/ directory