Python API: Importing QIIME2 plugins

Hi!

Why do I have to import each of qiime2.plugins separately? If I do import qiime2, I must follow it with (e.g.) from qiime2.plugins import diversity. Why doesn’t qiime2.plugins.diversity work after importing
all of qiime2?

thanks,
Tomasz

Hi @tomasz, great question! The qiime2.plugins import path is dynamically generated based on the currently installed plugins, and it can take awhile to generate this API because each plugin must be imported via its respective Python entry point (this is accomplished by qiime2.sdk.PluginManager). We intentionally avoided recursive imports in this manner so that running import qiime2 can be speedy.

Importing all plugins via the PluginManager can be so slow that the QIIME 2 command line interface (q2cli) does quite a bit of work to cache plugin info to disk in order to avoid importing plugins each time a command (or tab completion) is executed.

3 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.