subcommand
allennlp.commands.subcommand
Base class for subcommands under allennlp.run
.
T#
T = TypeVar("T", bound="Subcommand")
Subcommand#
class Subcommand(Registrable)
An abstract class representing subcommands for allennlp.run.
If you wanted to (for example) create your own custom special-evaluate
command to use like
allennlp special-evaluate ...
you would create a Subcommand
subclass and then pass it as an override to
main
.
requires_plugins#
class Subcommand(Registrable):
| ...
| requires_plugins: bool = True
If True
, the sub-command will trigger a call to import_plugins()
(except for custom
subcommands which come from plugins, since plugins will already have been imported by the
time the subcommand is discovered), and will also have an additional --include-package
flag.
add_subparser#
class Subcommand(Registrable):
| ...
| def add_subparser(
| self,
| parser: argparse._SubParsersAction
| ) -> argparse.ArgumentParser
register#
class Subcommand(Registrable):
| ...
| @classmethod
| @overrides
| def register(
| cls: Type[T],
| name: str,
| constructor: Optional[str] = None,
| exist_ok: bool = False
| ) -> Callable[[Type[T]], Type[T]]
name#
class Subcommand(Registrable):
| ...
| @property
| def name(self) -> str