Allennlp: A list of all classes -> names they're registered as would be useful

Created on 11 Jan 2019  路  8Comments  路  Source: allenai/allennlp

Maybe this is me, but I've realized that it's pretty hard to figure out what various classes are registered as unless you go spelunking into the actual library code.

We should expose this information in a more user-friendly manner (and something simpler than running the config wizard), maybe a list in the docs or something?

Contributions welcome

Most helpful comment

python -c"import allennlp.training; from allennlp.common.registrable import Registrable; print(Registrable._registry)"

馃槈

All 8 comments

also: it seems like the docs for the classes themselves don't mention what they're registered as in the library, so it would be great to add that as well.

We can clearly auto-generate this, as the config wizard does it. So whatever the solution is, it should not be maintained by hand.

python -c"import allennlp.training; from allennlp.common.registrable import Registrable; print(Registrable._registry)"

馃槈

Could be good to expose this as a high level api, e.g:

import allennlp

print(allennlp.registerable_classes())
["Trainer", "Seq2SeqEncoder", "Attention", etc]

print(allennlp.registerable_options_for("Trainer"))
{"SingleTaskTrainer": "single_task"}

or something similar

for the second, probably makes sense to add it as a method on Registrable itself, so you could do like

from allennlp.models import Model
print(Model.known_subclasses())

or something like that (probably with a better name)

the challenge for the former is that they're not "known" until those modules load, so if you just import allennlp top level the registry is empty, so we'd have to do something ugly to force loading.

Maybe that's overkill and we just need something in the docs.

We think the right fix here is to have a script that lists the registered names.

The right fix is to find this issue, see the one-liner, and run it? Or use the config wizard? Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings